]> Dogcows Code - chaz/openbox/blobdiff - src/Resource.cc
made bsetroot compile with the new code for references instead of pointers
[chaz/openbox] / src / Resource.cc
index a6254bcb3ee334b9dbca2c469e7a65bbefd4175b..1f6f84380528ff2ddbb2bdc6f6b0c1f839504e17 100644 (file)
 
 #include <assert.h>
 
+bool obResource::m_initialized = false;
+
 obResource::obResource(const std::string &file) {
   setFile(file);
   m_modified = false;
   m_database = NULL;
   m_autosave = true;
+  if (!m_initialized) {
+    XrmInitialize();
+    m_initialized = true;
+  }
+}
+
+obResource::obResource() {
+  m_modified = false;
+  m_database = NULL;
+  m_autosave = true;
+  if (!m_initialized) {
+    XrmInitialize();
+    m_initialized = true;
+  }
 }
 
 obResource::~obResource() {
@@ -49,7 +65,6 @@ obResource::~obResource() {
 
 void obResource::setFile(const std::string &file) {
   m_file = file;
-  assert(m_file.c_str() != NULL);
 }
 
 void obResource::setAutoSave(bool autosave) {
@@ -83,6 +98,10 @@ void obResource::setValue(const std::string &rname, bool value) {
     save();
 }
 
+void obResource::setValue(const std::string &rname, int value) {
+  setValue(rname, (long)value);
+}
+
 void obResource::setValue(const std::string &rname, long value) {
   assert(m_database != NULL);
   
@@ -120,7 +139,6 @@ void obResource::setValue(const std::string &rname, const std::string &value) {
 
 bool obResource::getValue(const std::string &rname, const std::string &rclass,
                           bool &value) const {
-  assert(rname.c_str() != NULL);
   assert(rclass.c_str() != NULL);
   assert(m_database != NULL);
   
@@ -130,7 +148,7 @@ bool obResource::getValue(const std::string &rname, const std::string &rclass,
                           &rettype, &retvalue) || retvalue.addr == NULL)
     return false;
   std::string val = retvalue.addr;
-  if (val == "True")
+  if (0 == strncasecmp(val.c_str(), "true", val.length()))
     value = true;
   else
     value = false;
@@ -139,8 +157,6 @@ bool obResource::getValue(const std::string &rname, const std::string &rclass,
 
 bool obResource::getValue(const std::string &rname, const std::string &rclass,
                           long &value) const {
-  assert(rname.c_str() != NULL);
-  assert(rclass.c_str() != NULL);
   assert(m_database != NULL);
   
   char *rettype;
@@ -157,8 +173,6 @@ bool obResource::getValue(const std::string &rname, const std::string &rclass,
 
 bool obResource::getValue(const std::string &rname, const std::string &rclass,
                           std::string &value) const {
-  assert(rname.c_str() != NULL);
-  assert(rclass.c_str() != NULL);
   assert(m_database != NULL);
   
   char *rettype;
This page took 0.026188 seconds and 4 git commands to generate.