📄 tool.h
字号:
#ifndef TOOL_H_#define TOOL_H_#include <sstream>using namespace std;#define MAX_LEN 256/** *初始化文件目录,创建/home/baicai/database 的目录 * 如果该目录已经存在,则什么都不作 * */char* getDir();void createFile(const char* name);void inits();/** * 向一个文件中添加新行 * 参数file是文件的名字,line是添加的内容。 * 文件在这个函数中打开,并在这个函数中关闭. * */ void addLineToFile(const char * file,const char * line); /** * 从文件中删除一行 * 参数file是文件的名字,line是删除的内容。 * 文件在这个函数中打开,并在这个函数中关闭. * */void deleteOneLine(const char * file,const char * content);/** * 打开一个文件,以作为读取行的开始 * 返回文件描述符必须先调用openFile()再调用getNextLine(),再调用closeFile() * 如果读的过程中又打开了一个文件,则现在处理的不件就不能再读了!!!!!! * */ int openFile(const char * file); /** * 关闭文件,以作为读取完的结束 * */ void closeFile(int fd);/** * 因为这个程序大多数都是处理一行一行的,所以用此函数将一个字符串中的下一行取出. * fd为文件的描述符 *读到的一行放入linebuffer中. * 返回NULL表示已经到了文件末尾 * */char* getNextLine(int fd);/** * 查看文件是否存在,存在返回true,不存在返回false; * */ bool hasFile(const char * name);/** * 删除该文件 * */ void deleteFile(const char *name);/** * 查看文件是否存在,不存在则创建一个文件. *参数 file是文件的名字 * */ void checkFileExist(const char * file); /** * 查看文件夹是否存在,不存在的话创建一个 * 参数file是文件夹的名字 * */void checkDirectoryExist(const char * file);class StringToken{ private: string content; uint position; char buffer[MAX_LEN]; char point; public: //创建一个内容为str 以point为分割token的token流 StringToken(const char * str,char point); bool hasMore(); char * next();};#endif /*TOOL_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -