Date: Wednesday, March 22, 2006 @ 18:26:06
  Author: marc
    Path: /cvsroot/carob/carob/include

Modified: Common.hpp (1.39 -> 1.40)

Implemented { "DEBUG" | "FATAL" | ... } string to enum LogLevel converter


------------+
 Common.hpp |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+)


Index: carob/include/Common.hpp
diff -u carob/include/Common.hpp:1.39 carob/include/Common.hpp:1.40
--- carob/include/Common.hpp:1.39       Wed Mar 22 15:04:51 2006
+++ carob/include/Common.hpp    Wed Mar 22 18:26:06 2006
@@ -54,6 +54,30 @@
   LOG_LEVEL_OFF
 };
 
+class StringLogLevel : public std::string
+{
+public:
+  // we have nothing more than the derived std::string
+  StringLogLevel(const char * s)
+    : std::string(s)
+  { } ;
+
+  // converter from std::string to the enum
+  operator LogLevel() const
+    throw (std::string) // error message
+  {
+    if (0 == compare("DEBUG")) return LOG_LEVEL_DEBUG;
+    if (0 == compare("INFO")) return LOG_LEVEL_INFO;
+    if (0 == compare("WARN")) return LOG_LEVEL_WARN;
+    if (0 == compare("ERROR")) return LOG_LEVEL_ERROR;
+    if (0 == compare("FATAL")) return LOG_LEVEL_FATAL;
+    if (0 == compare("OFF")) return LOG_LEVEL_OFF;
+
+    throw (*this + " is an unknown LogLevel");
+  }
+};
+
+
 // Line separator (EOL)
 //TODO: get this at runtime => ???
 const wchar_t LINE_SEPARATOR[] = 
@@ -164,3 +188,13 @@
 
 } //namespace CarobNS
 #endif //_COMMON_H_
+
+
+/*
+ * Local Variables:
+ * c-file-style: "bsd"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * End:
+ */
+

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to