|
ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
|
文件写入类。 More...
#include <tools_file.h>
Public Member Functions | |
| writefile (const std::string &filename) | |
| 构造函数,打开或创建指定文件。 | |
| ~writefile () | |
| 析构函数,自动关闭文件。 | |
| void | write (const std::string &aneirong) |
| 向文件写入内容。 | |
文件写入类。
封装std::ofstream,提供简单的文件写入功能。
| ngl::tools::writefile::writefile | ( | const std::string & | filename | ) |
构造函数,打开或创建指定文件。
构造函数,打开文件进行写入
| filename | 文件路径 |
| filename | 要打开的文件名 |
以二进制模式打开文件,创建新文件或覆盖已有文件
| ngl::tools::writefile::~writefile | ( | ) |
析构函数,自动关闭文件。
析构函数,确保文件被正确关闭
使用try-catch确保析构函数不会抛出异常
| void ngl::tools::writefile::write | ( | const std::string & | aneirong | ) |
向文件写入内容。
写入内容到文件
| aneirong | 要写入的内容 |
| aneirong | 要写入的内容 |
检查内容大小是否超过streamsize最大值 如果超过,记录错误日志并返回