dev_yi #1
@ -66,6 +66,8 @@ int main(int argc, char const *argv[]) try
|
||||
display_vector(tc.get_annotoations(), std::clog, '\n');
|
||||
display_vector(tc.get_head_records(), std::clog, '\n');
|
||||
|
||||
tc.disable_column("elevation (m)");
|
||||
|
||||
_1s_vector s = tc.get_tags();
|
||||
s.push_back("Elev = 1000");
|
||||
tc.set_tags(s);
|
||||
|
@ -74,6 +74,7 @@ void gctl::dsv_io::clear()
|
||||
destroy_vector(annotates_);
|
||||
destroy_vector(tags_);
|
||||
destroy_vector(table_);
|
||||
destroy_vector(bool_table_);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -148,6 +149,16 @@ void gctl::dsv_io::load_text(std::string filename, std::string file_exten, table
|
||||
}
|
||||
}
|
||||
|
||||
bool_table_.resize(row_num_);
|
||||
for (size_t i = 0; i < row_num_; i++)
|
||||
{
|
||||
bool_table_[i].resize(col_num_);
|
||||
for (size_t j = 0; j < col_num_; j++)
|
||||
{
|
||||
bool_table_[i][j] = true;
|
||||
}
|
||||
}
|
||||
|
||||
thead_ = t;
|
||||
file_ = filename + file_exten;
|
||||
destroy_vector(lines);
|
||||
@ -181,12 +192,25 @@ void gctl::dsv_io::save_text(std::string filename, std::string file_exten)
|
||||
outfile << "# " << annotates_[i] << std::endl;
|
||||
}
|
||||
|
||||
bool line_st;
|
||||
for (int i = 0; i < row_num_; i++)
|
||||
{
|
||||
outfile << table_[i][0].str_;
|
||||
line_st = false;
|
||||
|
||||
if (bool_table_[i][0])
|
||||
{
|
||||
outfile << table_[i][0].str_;
|
||||
line_st = true;
|
||||
}
|
||||
|
||||
for (size_t j = 1; j < col_num_; j++)
|
||||
{
|
||||
outfile << deli_sym_ << table_[i][j].str_;
|
||||
if (line_st && bool_table_[i][j]) outfile << deli_sym_ << table_[i][j].str_; // line started
|
||||
else if (bool_table_[i][j]) // line not started
|
||||
{
|
||||
outfile << table_[i][j].str_;
|
||||
line_st = true; // start line
|
||||
}
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
@ -269,6 +293,9 @@ void gctl::dsv_io::info()
|
||||
|
||||
for (size_t i = 0; i < col_num_; i++)
|
||||
{
|
||||
// skip disabled columns
|
||||
if (!bool_table_[0][i]) continue;
|
||||
|
||||
if (thead_ == ColumnHead || thead_ == BothHead)
|
||||
{
|
||||
std::clog << table_[0][i].str_ << ": " << table_[1][i].str_ << " -> " << table_[row_num_ - 1][i].str_ << "\n";
|
||||
@ -316,6 +343,46 @@ int gctl::dsv_io::name_index(std::string name, bool iter_row)
|
||||
}
|
||||
}
|
||||
|
||||
void gctl::dsv_io::disable_column(int idx)
|
||||
{
|
||||
if (idx >= col_num_)
|
||||
{
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid column index.");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < row_num_; i++)
|
||||
{
|
||||
bool_table_[i][idx] = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::dsv_io::disable_column(std::string name)
|
||||
{
|
||||
disable_column(name_index(name));
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::dsv_io::disable_row(int idx)
|
||||
{
|
||||
if (idx >= row_num_)
|
||||
{
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid row index.");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < col_num_; i++)
|
||||
{
|
||||
bool_table_[idx][i] = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void gctl::dsv_io::disable_row(std::string name)
|
||||
{
|
||||
disable_row(name_index(name));
|
||||
return;
|
||||
}
|
||||
|
||||
gctl::geodsv_io::geodsv_io(){}
|
||||
|
||||
gctl::geodsv_io::~geodsv_io(){}
|
||||
|
@ -102,6 +102,7 @@ namespace gctl
|
||||
std::vector<std::string> heads_, annotates_, tags_;
|
||||
// 内容表格
|
||||
std::vector<std::vector<table_cell> > table_;
|
||||
std::vector<std::vector<bool> > bool_table_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -274,6 +275,34 @@ namespace gctl
|
||||
*/
|
||||
int name_index(std::string name, bool iter_row = false);
|
||||
|
||||
/**
|
||||
* @brief 屏蔽列
|
||||
*
|
||||
* @param idx 列索引
|
||||
*/
|
||||
void disable_column(int idx);
|
||||
|
||||
/**
|
||||
* @brief 屏蔽列
|
||||
*
|
||||
* @param name 列名称
|
||||
*/
|
||||
void disable_column(std::string name);
|
||||
|
||||
/**
|
||||
* @brief 屏蔽行
|
||||
*
|
||||
* @param idx 行索引
|
||||
*/
|
||||
void disable_row(int idx);
|
||||
|
||||
/**
|
||||
* @brief 屏蔽行
|
||||
*
|
||||
* @param name 行名称
|
||||
*/
|
||||
void disable_row(std::string name);
|
||||
|
||||
/**
|
||||
* @brief 填充表格
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user