Skip to content

Commit

Permalink
[FEATURE] Allow to set extended info
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Sep 6, 2021
1 parent 57e6050 commit 641c145
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
24 changes: 17 additions & 7 deletions paramkit/include/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ namespace paramkit {
std::stringstream ss;
ss << m_info;
if (isExpanded) {
const std::string options = optionsInfo();
if (options.length()) {
ss << "\n" << options;
const std::string eInfo = extendedInfo();
if (eInfo.length()) {
ss << "\n" << eInfo;
}
}
return ss.str();
Expand Down Expand Up @@ -133,16 +133,17 @@ namespace paramkit {
return (sim_type != util::SIM_NONE) ? true : false;
}

//! Extended information about accepted values
virtual std::string optionsInfo() const
//! Extended information
virtual std::string extendedInfo() const
{
return "";
return m_extInfo;
}

std::string argStr; ///< a unique name of the parameter

std::string typeDescStr; ///< a description of the type of the parameter: what type of values are allowed
std::string m_info; ///< an information about the the parameter's purpose
std::string m_info; ///< a basic information about the the parameter's purpose
std::string m_extInfo; ///< an extended information about the the parameter's purpose

bool isRequired; ///< a flag indicating if this parameter is required
bool requiredArg; ///< a flag indicating if this parameter needs to be followed by a value
Expand Down Expand Up @@ -503,6 +504,15 @@ namespace paramkit {
int value;

protected:

std::string extendedInfo() const
{
std::stringstream stream;
stream << Param::extendedInfo();
stream << optionsInfo();
return stream.str();
}

std::string optionsInfo() const
{
std::stringstream stream;
Expand Down
8 changes: 5 additions & 3 deletions paramkit/include/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,17 @@ namespace paramkit {
//! Sets the information about the parameter, defined by its name
/**
\param paramName : a unique name of the parameter
\param info : the description of the parameter
\param basic_info : basic description of the parameter
\param extended_info : additional description of the parameter
\return true if setting the info was successful
*/
bool setInfo(const std::string& paramName, const std::string& info)
bool setInfo(const std::string& paramName, const std::string& basic_info, const std::string& extended_info = "")
{
Param *p = getParam(paramName);
if (!p) return false;

p->m_info = info;
p->m_info = basic_info;
p->m_extInfo = extended_info;
return false;
}

Expand Down

0 comments on commit 641c145

Please sign in to comment.