Skip to content

Commit

Permalink
Add ini read for vector unsigned char
Browse files Browse the repository at this point in the history
  • Loading branch information
200km committed Sep 28, 2023
1 parent 9a83d2c commit 9325116
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/library/initialize/initialize_file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ IniAccess::IniAccess(const std::string file_path) : file_path_(file_path), ini_r
}
#endif

std::vector<unsigned char> IniAccess::ReadVectorUnsignedChar(const char* section_name, const char* key_name, const size_t num)
{
std::vector<unsigned char> data;
for (size_t i = 0; i < num; i++) {
std::stringstream edited_key_name;
edited_key_name << key_name << "(" << i << ")";
data.push_back((unsigned char)ReadInt(section_name, edited_key_name.str().c_str()));
}
return data;
}

double IniAccess::ReadDouble(const char* section_name, const char* key_name) {
#ifdef WIN32
std::stringstream value;
Expand Down
9 changes: 9 additions & 0 deletions src/library/initialize/initialize_file_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ class IniAccess {
IniAccess(const std::string file_path);

// Read functions
/**
* @fn ReadVectorUnsignedChar
* @brief Read a vector number as unsigned char type
* @param[in] section_name: Section name
* @param[in] key_name: Key name
* @param[in] num: Number of elements of the array
* @return Read number
*/
std::vector<unsigned char> ReadVectorUnsignedChar(const char* section_name, const char* key_name, const size_t num);
/**
* @fn ReadDouble
* @brief Read a scalar number as double type
Expand Down

0 comments on commit 9325116

Please sign in to comment.