From e41f399c89624041ca0cfc03c592c4f9e6902a45 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 4 Jan 2011 15:49:58 +0100 Subject: [PATCH] Consolidate helper functions from options.cpp in one block. --- options.cpp | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) 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 ]"); -- 2.39.5