📄 template.cpp
字号:
/** * Before using Template, even though slower, I think used less * memory without this class .. can't remember. */#include "Template.h"#include "Kernel.h"// Can't do the auto-reloading from inside the Template function .. it's just// plain wrong!// Need a static function to reload the AIML (if required), then forward the// request on to the actual Template .. somehow :Pvector<string> Template::filenames;vector<long> Template::filesizes;string Template::fetch() { // Get the filename .. const char *filename = Template::getFilename(filenameIx); // When have <template/> if (end == start) { return ""; } int length = end - start; ifstream fin(filename, ios::in | ios::binary); char *input = new char[length+1]; if(!fin.good()) return "Error reading file"; fin.seekg(start); fin.read(input, length); fin.close(); input[length] = '\0'; string ret(input); delete [] input; return ret;}const char *Template::getFilename(int index) { return filenames[index].c_str();}void Template::reloadFile(int index) { string fn = filenames[index]; long fs = filesizes[index]; ifstream fin; fin.open(fn.c_str(), ios::in | ios::binary); fin.seekg(0, ios::end); int s = fin.tellg(); if (s != fs) { // Reload .. return true filesizes[index] = s; Kernel::load(fn); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -