void CConfigFileReader::_LoadFile(const char* filename) { m_config_file.clear(); m_config_file.append(filename); FILE* fp = fopen(filename, "r"); if (!fp) { log("can not open %s\n", filename); return; } char buf[256]; for (;;) { char* p = fgets(buf, 256, fp); if (!p) break; size_t len = strlen(buf); if (buf[len - 1] == '\n') buf[len - 1] = 0; // remove \n at the end char* ch = strchr(buf, '#'); // remove string start with # if (ch) *ch = 0; if (strlen(buf) == 0) continue; _ParseLine(buf); } fclose(fp); m_load_ok = true; }
int Cluster::_Parse(vector<string> terms) { for (int k = 0; k < terms.size(); k++) { _ParseLine(terms[k]); } //save some memory terms.clear(); return 0; }