mirror of
https://github.com/tanakh/cmdline.git
synced 2024-11-27 04:59:53 +08:00
expose default_value stringifier
Allows overriding cmdline::detail::default_value to provide own default value string such as "auto" or "none", for certain values.
This commit is contained in:
parent
4dfb5d6c94
commit
a68095a65c
@ -117,6 +117,12 @@ std::string readable_typename()
|
||||
return demangle(typeid(T).name());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string default_value(T def)
|
||||
{
|
||||
return detail::lexical_cast<std::string>(def);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline std::string readable_typename<std::string>()
|
||||
{
|
||||
@ -754,7 +760,7 @@ private:
|
||||
std::string full_description(const std::string &desc){
|
||||
return
|
||||
desc+" ("+detail::readable_typename<T>()+
|
||||
(need?"":" [="+detail::lexical_cast<std::string>(def)+"]")
|
||||
(need?"":" [="+detail::default_value<T>(def)+"]")
|
||||
+")";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user