add functions

This commit is contained in:
张壹 2025-02-05 14:25:59 +08:00
parent 2215a17d5f
commit 51bca90178
2 changed files with 65 additions and 4 deletions

View File

@ -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;

View File

@ -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
*