add functions
This commit is contained in:
parent
2215a17d5f
commit
51bca90178
@ -142,7 +142,7 @@ void gctl::dsv_io::row_type(table_cell_type t, int idx)
|
||||
{
|
||||
if (idx > row_num_ || idx <= 0)
|
||||
{
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid column index.");
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid row index.");
|
||||
}
|
||||
|
||||
for (size_t i = 0; i <= col_num_; i++)
|
||||
@ -156,6 +156,21 @@ void gctl::dsv_io::row_type(table_cell_type t, std::string name)
|
||||
row_type(t, name_index(name, true));
|
||||
}
|
||||
|
||||
gctl::table_cell_type gctl::dsv_io::row_type(int idx)
|
||||
{
|
||||
if (idx > row_num_ || idx <= 0)
|
||||
{
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid row index.");
|
||||
}
|
||||
|
||||
return table_[idx][0].type_;
|
||||
}
|
||||
|
||||
gctl::table_cell_type gctl::dsv_io::row_type(std::string name)
|
||||
{
|
||||
return row_type(name_index(name, true));
|
||||
}
|
||||
|
||||
void gctl::dsv_io::column_type(table_cell_type t, int idx)
|
||||
{
|
||||
if (idx > col_num_ || idx <= 0)
|
||||
@ -175,6 +190,21 @@ void gctl::dsv_io::column_type(table_cell_type t, std::string name)
|
||||
column_type(t, name_index(name, false));
|
||||
}
|
||||
|
||||
gctl::table_cell_type gctl::dsv_io::column_type(int idx)
|
||||
{
|
||||
if (idx > col_num_ || idx <= 0)
|
||||
{
|
||||
throw std::runtime_error("[gctl::dsv_io] Invalid column index.");
|
||||
}
|
||||
|
||||
return table_[0][idx].type_;
|
||||
}
|
||||
|
||||
gctl::table_cell_type gctl::dsv_io::column_type(std::string name)
|
||||
{
|
||||
return column_type(name_index(name, false));
|
||||
}
|
||||
|
||||
void gctl::dsv_io::load_text(std::string filename, std::string file_exten, table_headtype_e t)
|
||||
{
|
||||
std::ifstream infile;
|
||||
|
@ -164,8 +164,7 @@ namespace gctl
|
||||
dsv_io(std::string filename, std::string file_exten = ".txt", table_headtype_e t = NoHead);
|
||||
|
||||
/**
|
||||
* @brief 清理字符串向量对象
|
||||
*
|
||||
* @brief 清理(还原)表格
|
||||
*/
|
||||
void clear();
|
||||
|
||||
@ -195,7 +194,7 @@ namespace gctl
|
||||
*
|
||||
* @param num 行数
|
||||
*/
|
||||
void head_number(char num){head_num_ = num;}
|
||||
void head_number(int num){head_num_ = num;}
|
||||
|
||||
/**
|
||||
* @brief 返回头信息
|
||||
@ -328,6 +327,22 @@ namespace gctl
|
||||
*/
|
||||
void row_type(table_cell_type t, std::string name);
|
||||
|
||||
/**
|
||||
* @brief 获取行类型
|
||||
*
|
||||
* @param idx 行索引
|
||||
* @return 行类型
|
||||
*/
|
||||
table_cell_type row_type(int idx);
|
||||
|
||||
/**
|
||||
* @brief 获取行类型
|
||||
*
|
||||
* @param name 行名称
|
||||
* @return 行类型
|
||||
*/
|
||||
table_cell_type row_type(std::string name);
|
||||
|
||||
/**
|
||||
* @brief 设置列类型
|
||||
*
|
||||
@ -344,6 +359,22 @@ namespace gctl
|
||||
*/
|
||||
void column_type(table_cell_type t, std::string name);
|
||||
|
||||
/**
|
||||
* @brief 获取列类型
|
||||
*
|
||||
* @param idx 列索引
|
||||
* @return 列类型
|
||||
*/
|
||||
table_cell_type column_type(int idx);
|
||||
|
||||
/**
|
||||
* @brief 获取列类型
|
||||
*
|
||||
* @param name 列名称
|
||||
* @return 列类型
|
||||
*/
|
||||
table_cell_type column_type(std::string name);
|
||||
|
||||
/**
|
||||
* @brief 读入文本文件
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user