ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::tools::writefile Class Reference

文件写入类。 More...

#include <tools_file.h>

Public Member Functions

 writefile (const std::string &filename)
 构造函数,打开或创建指定文件。
 ~writefile ()
 析构函数,自动关闭文件。
void write (const std::string &aneirong)
 向文件写入内容。

Detailed Description

文件写入类。

封装std::ofstream,提供简单的文件写入功能。

Note
不可拷贝,构造时打开文件,析构时自动关闭。

Constructor & Destructor Documentation

◆ writefile()

ngl::tools::writefile::writefile ( const std::string & filename)

构造函数,打开或创建指定文件。

构造函数,打开文件进行写入

Parameters
filename文件路径
filename要打开的文件名

以二进制模式打开文件,创建新文件或覆盖已有文件

◆ ~writefile()

ngl::tools::writefile::~writefile ( )

析构函数,自动关闭文件。

析构函数,确保文件被正确关闭

使用try-catch确保析构函数不会抛出异常

Member Function Documentation

◆ write()

void ngl::tools::writefile::write ( const std::string & aneirong)

向文件写入内容。

写入内容到文件

Parameters
aneirong要写入的内容
aneirong要写入的内容

检查内容大小是否超过streamsize最大值 如果超过,记录错误日志并返回


The documentation for this class was generated from the following files: