From 1296f153871234ac09b70a39321969a5291731c3 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Wed, 25 Dec 2024 19:06:27 +0800 Subject: [PATCH] tmp --- lib/io/dsv_io.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/io/dsv_io.cpp b/lib/io/dsv_io.cpp index a7723dd..7773e71 100644 --- a/lib/io/dsv_io.cpp +++ b/lib/io/dsv_io.cpp @@ -82,20 +82,12 @@ void gctl::dsv_io::load_text(std::string filename, std::string file_exten, table std::ifstream infile; open_infile(infile, filename, file_exten); + int h = 0; std::string tmp_line; - std::stringstream tmp_ss; - for (int i = 0; i < head_num_; i++) // 跳过前n行 包括空行 但不会保存空行 - { - std::getline(infile, tmp_line); - if (!tmp_line.empty()) heads_.push_back(tmp_line); - } - // 校正头信息行数 - head_num_ = heads_.size(); - std::vector lines; while (std::getline(infile, tmp_line)) { - if (tmp_line.empty()) continue; // 跳过空行 + if (tmp_line.empty()) continue; // 跳过空行 空行不会并记入头信息计数中 else if (tmp_line[0] == att_sym_) // 注释行或者标记行 # #! { if (tmp_line[1] == tag_sym_) // #! @@ -113,6 +105,11 @@ void gctl::dsv_io::load_text(std::string filename, std::string file_exten, table tmp_line.erase(tmp_line.find_last_not_of(" \t") + 1); annotates_.push_back(tmp_line); } + else if (h < head_num_) //读入到头信息中 + { + heads_.push_back(tmp_line); + h++; + } else lines.push_back(tmp_line); } infile.close();