Skip to content

Commit

Permalink
core: fix docs and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrielcarvfer committed Oct 26, 2022
1 parent 1237315 commit 870b7fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
23 changes: 17 additions & 6 deletions src/core/examples/command-line-example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ SetCbArg(std::string val)

} // unnamed namespace

/**
* Print a row containing the name, the default
* and the final values of an argument.
*
* \param [in] label The argument label.
* \param [in] defaultValue The default value of the argument.
* \param [in] finalValue The final value of the argument.
*
*/
#define DefaultFinal(label, defaultValue, finalValue) \
std::left << std::setw(20) << label + std::string(":") << std::setw(20) << defaultValue \
<< finalValue << "\n"

int
main(int argc, char* argv[])
{
Expand Down Expand Up @@ -123,12 +136,10 @@ main(int argc, char* argv[])
std::cout << "Argument Initial Value Final Value\n"
<< std::left << std::boolalpha;

#define DefaultFinal(label, default, final) \
std::left << std::setw(20) << label + std::string(":") << std::setw(20) << default << final \
<< "\n"

std::cout << DefaultFinal("intArg", intDef, intArg)
<< DefaultFinal("boolArg", std::boolalpha << boolDef, std::boolalpha << boolArg)
std::cout << DefaultFinal("intArg", intDef, intArg) //
<< DefaultFinal("boolArg",
(boolDef ? "true" : "false"),
(boolArg ? "true" : "false")) //
<< DefaultFinal("strArg", "\"" + strDef + "\"", "\"" + strArg + "\"");

// Look up new default value for attribute
Expand Down
2 changes: 1 addition & 1 deletion src/core/model/command-line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ CommandLine::PrintDoxygenUsage() const
}

auto listOptions = [&os](const std::string& head, const Items& items, std::string pre) {
os << "\n<dl>\n<h3>" << head << "</h3>\n";
os << "\n<h3>" << head << "</h3>\n<dl>\n";
for (const auto& i : items)
{
os << " <dt>" << pre << i->m_name << " </dt>\n"
Expand Down
8 changes: 6 additions & 2 deletions src/core/model/command-line.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class CommandLine
/**
* The argument value.
* \internal This has to be \c mutable because the Parse()
* function is \const in the base class Item.
* function is \c const in the base class Item.
*/
mutable std::string m_value;
}; // class StringItem
Expand Down Expand Up @@ -550,13 +550,17 @@ class CommandLine

/**
* Strip leading `--` or `-` from options.
*
* \param [in] param Option name to search
* \returns \c false if none found, indicating this is a non-option.
*/
HasOptionName GetOptionName(const std::string& param) const;
/**
* Handle hard-coded options.
*
* \note: if any hard-coded options are found this function exits.
*
* \param [in] args Vector of hard-coded options to handle.
*/
void HandleHardOptions(const std::vector<std::string>& args) const;

Expand Down Expand Up @@ -714,7 +718,7 @@ bool UserItemParse<uint8_t>(const std::string& value, uint8_t& dest);
* \brief Helper to specialize CommandLine::UserItem::GetDefault() on types
* needing special handling.
*
* \param [in] default The default value from the UserItem.
* \param [in] defaultValue The default value from the UserItem.
* \return The string representation of value.
* @{
*/
Expand Down

0 comments on commit 870b7fb

Please sign in to comment.