From: Arnaud Giersch Date: Tue, 4 Jan 2011 14:49:58 +0000 (+0100) Subject: Consolidate helper functions from options.cpp in one block. X-Git-Tag: v0.1~207 X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/loba.git/commitdiff_plain/e41f399c89624041ca0cfc03c592c4f9e6902a45?ds=inline;hp=-c Consolidate helper functions from options.cpp in one block. --- e41f399c89624041ca0cfc03c592c4f9e6902a45 diff --git a/options.cpp b/options.cpp index 2cf607c..76bc997 100644 --- a/options.cpp +++ b/options.cpp @@ -78,6 +78,29 @@ namespace opt { namespace { + // some helper functions for opt::print() + + const char* on_off(bool b) + { + return b ? "on" : "off"; + } + + template + const char* val_or_string(const T& val, const char* str, const T& deflt = 0) + { + static std::string res; + if (val != deflt) { + std::ostringstream oss; + oss << val; + res = oss.str(); + } else { + res = str; + } + return res.c_str(); + } + + // helper function for opt::parse_args() + template bool nol_find_prefix(const T& nol, const char* descr, std::string& name) { @@ -198,31 +221,6 @@ bool opt::parse_args(int* argc, char* argv[]) return result; } -namespace { - - // some helper functions for opt::print() - - const char* on_off(bool b) - { - return b ? "on" : "off"; - } - - template - const char* val_or_string(const T& val, const char* str, const T& deflt = 0) - { - static std::string res; - if (val != deflt) { - std::ostringstream oss; - oss << val; - res = oss.str(); - } else { - res = str; - } - return res.c_str(); - } - -} // namespace - void opt::print() { INFO0(",----[ Simulation parameters ]");