[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Usata-commits] Changes to usata2/src/config.cpp
From: |
David Lau |
Subject: |
[Usata-commits] Changes to usata2/src/config.cpp |
Date: |
Thu, 20 Jan 2005 15:20:31 -0500 |
Index: usata2/src/config.cpp
diff -u usata2/src/config.cpp:1.19 usata2/src/config.cpp:1.20
--- usata2/src/config.cpp:1.19 Sun Jan 2 02:48:32 2005
+++ usata2/src/config.cpp Thu Jan 20 20:20:30 2005
@@ -10,7 +10,7 @@
// included in the software distribution, or visit
// http://www.fsf.org/licenses/gpl.html.
//
-// $Id: config.cpp,v 1.19 2005/01/02 02:48:32 skunix Exp $
+// $Id: config.cpp,v 1.20 2005/01/20 20:20:30 skunix Exp $
#include <map>
#include <memory>
@@ -363,6 +363,25 @@
}
}
+
+const char * TrueBoolStrings[] = { "yes", "true","enable", 0};
+
+
+bool
+ConfigSection::get_as_bool(const std::string&key)
+{
+ std::string v = get(key);
+
+ const char ** ptr = TrueBoolStrings;
+
+ while (*ptr != 0)
+ {
+ if (v == *ptr)return true;
+ ++ptr;
+ }
+
+ return false;
+}
std::string
ConfigSection::get(const std::string&key)const
{
@@ -386,6 +405,20 @@
}
+bool
+ConfigSection::get_b(const std::string& key, bool d)
+{
+ try
+ {
+ return get_as_bool(key);
+ }
+ catch(ConfigMissingKey&x)
+ {
+ return d;
+ }
+}
+
+
void
ConfigSection::set(const std::string& key, const std::string& value)
{