tmp
This commit is contained in:
parent
39eed90abb
commit
4c9cdb32d6
@ -59,8 +59,8 @@ int main(int argc, char const *argv[]) try
|
||||
}
|
||||
|
||||
std::clog << x.back() << "," << y.back() << "," << z.back() << "\n";
|
||||
display_vector(tc.annotates_, std::clog, '\n');
|
||||
display_vector(tc.tags_, std::clog, '\n');
|
||||
display_vector(tc.annotates_, std::clog, '\n');
|
||||
display_vector(tc.heads_, std::clog, '\n');
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ gctl::text_content::text_content()
|
||||
{
|
||||
// 设置基础参数
|
||||
att_sym_ = '#';
|
||||
tag_sym_ = '>';
|
||||
tag_sym_ = '!';
|
||||
deli_sym_ = ' ';
|
||||
head_num_ = 0;
|
||||
}
|
||||
@ -45,7 +45,7 @@ gctl::text_content::text_content(std::string filename, std::string file_exten, b
|
||||
{
|
||||
// 设置基础参数
|
||||
att_sym_ = '#';
|
||||
tag_sym_ = '>';
|
||||
tag_sym_ = '!';
|
||||
deli_sym_ = ' ';
|
||||
head_num_ = 0;
|
||||
// 载入文本内容
|
||||
@ -80,7 +80,7 @@ void gctl::text_content::load_text(std::string filename, std::string file_exten,
|
||||
|
||||
std::string tmp_line;
|
||||
std::stringstream tmp_ss;
|
||||
for (int i = 0; i < head_num_; i++)
|
||||
for (int i = 0; i < head_num_; i++) // 跳过前n行 包括空行 但不会保存空行
|
||||
{
|
||||
std::getline(infile, tmp_line);
|
||||
if (!tmp_line.empty()) heads_.push_back(tmp_line);
|
||||
@ -88,21 +88,25 @@ void gctl::text_content::load_text(std::string filename, std::string file_exten,
|
||||
|
||||
while (std::getline(infile, tmp_line))
|
||||
{
|
||||
if (tmp_line[0] == att_sym_)
|
||||
if (tmp_line.empty()) continue; // 跳过空行
|
||||
else if (tmp_line[0] == att_sym_) // 注释行或者标记行 # #!
|
||||
{
|
||||
tmp_line = tmp_line.substr(1);
|
||||
if (tmp_line[1] == tag_sym_) // #!
|
||||
{
|
||||
tmp_line = tmp_line.substr(2); // 去掉前两个字符
|
||||
tmp_line.erase(0, tmp_line.find_first_not_of(" \t"));
|
||||
tmp_line.erase(tmp_line.find_last_not_of(" \t") + 1);
|
||||
tags_.push_back(tmp_line);
|
||||
continue;
|
||||
}
|
||||
|
||||
// #
|
||||
tmp_line = tmp_line.substr(1); // 去掉第一个字符
|
||||
tmp_line.erase(0, tmp_line.find_first_not_of(" \t"));
|
||||
tmp_line.erase(tmp_line.find_last_not_of(" \t") + 1);
|
||||
annotates_.push_back(tmp_line);
|
||||
}
|
||||
else if (tmp_line[0] == tag_sym_)
|
||||
{
|
||||
tmp_line = tmp_line.substr(1);
|
||||
tmp_line.erase(0, tmp_line.find_first_not_of(" \t"));
|
||||
tmp_line.erase(tmp_line.find_last_not_of(" \t") + 1);
|
||||
tags_.push_back(tmp_line);
|
||||
}
|
||||
else if (!tmp_line.empty()) lines_.push_back(tmp_line);
|
||||
else lines_.push_back(tmp_line);
|
||||
}
|
||||
|
||||
infile.close();
|
||||
@ -139,7 +143,7 @@ void gctl::text_content::save_text(std::string filename, std::string file_exten,
|
||||
|
||||
for (int i = 0; i < tags_.size(); i++)
|
||||
{
|
||||
outfile << "> " << tags_[i] << std::endl;
|
||||
outfile << "#! " << tags_[i] << std::endl;
|
||||
}
|
||||
|
||||
for (int i = 0; i < annotates_.size(); i++)
|
||||
|
@ -92,7 +92,7 @@ namespace gctl
|
||||
* @param deli 分割符
|
||||
* @param h_num 头信息行数
|
||||
*/
|
||||
void set(char deli_sym = ' ', int h_num = 0, char att_sym = '#', char tag_sym = '>');
|
||||
void set(char deli_sym = ' ', int h_num = 0, char att_sym = '#', char tag_sym = '!');
|
||||
|
||||
/**
|
||||
* @brief 清理字符串向量对象
|
||||
|
Loading…
Reference in New Issue
Block a user