use the True/False as is the blackbox code standard.
This commit is contained in:
parent
4abbbd9f84
commit
9d2f88e05a
2 changed files with 48 additions and 48 deletions
|
@ -33,26 +33,26 @@
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
bool Configuration::m_initialized = false;
|
bool Configuration::m_initialized = False;
|
||||||
|
|
||||||
Configuration::Configuration(const string &file) {
|
Configuration::Configuration(const string &file) {
|
||||||
setFile(file);
|
setFile(file);
|
||||||
m_modified = false;
|
m_modified = False;
|
||||||
m_database = NULL;
|
m_database = NULL;
|
||||||
m_autosave = true;
|
m_autosave = True;
|
||||||
if (! m_initialized) {
|
if (! m_initialized) {
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
m_initialized = true;
|
m_initialized = True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Configuration::Configuration() {
|
Configuration::Configuration() {
|
||||||
m_modified = false;
|
m_modified = False;
|
||||||
m_database = NULL;
|
m_database = NULL;
|
||||||
m_autosave = true;
|
m_autosave = True;
|
||||||
if (! m_initialized) {
|
if (! m_initialized) {
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
m_initialized = true;
|
m_initialized = True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,22 +72,22 @@ void Configuration::setAutoSave(bool autosave) {
|
||||||
void Configuration::save() {
|
void Configuration::save() {
|
||||||
assert(m_database != NULL);
|
assert(m_database != NULL);
|
||||||
XrmPutFileDatabase(m_database, m_file.c_str());
|
XrmPutFileDatabase(m_database, m_file.c_str());
|
||||||
m_modified = false;
|
m_modified = False;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configuration::load() {
|
bool Configuration::load() {
|
||||||
if (m_database != NULL)
|
if (m_database != NULL)
|
||||||
XrmDestroyDatabase(m_database);
|
XrmDestroyDatabase(m_database);
|
||||||
m_modified = false;
|
m_modified = False;
|
||||||
if (NULL == (m_database = XrmGetFileDatabase(m_file.c_str())))
|
if (NULL == (m_database = XrmGetFileDatabase(m_file.c_str())))
|
||||||
return false;
|
return False;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::create() {
|
void Configuration::create() {
|
||||||
if (m_database != NULL)
|
if (m_database != NULL)
|
||||||
XrmDestroyDatabase(m_database);
|
XrmDestroyDatabase(m_database);
|
||||||
m_modified = false;
|
m_modified = False;
|
||||||
assert(NULL != (m_database = XrmGetStringDatabase("")));
|
assert(NULL != (m_database = XrmGetStringDatabase("")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void Configuration::setValue(const string &rname, bool value) {
|
||||||
string rc_string = rname + ": " + val;
|
string rc_string = rname + ": " + val;
|
||||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = True;
|
||||||
if (m_autosave)
|
if (m_autosave)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ void Configuration::setValue(const string &rname, unsigned long value) {
|
||||||
string rc_string = rname + ": " + itostring(value);
|
string rc_string = rname + ": " + itostring(value);
|
||||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = True;
|
||||||
if (m_autosave)
|
if (m_autosave)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ void Configuration::setValue(const string &rname, long value) {
|
||||||
string rc_string = rname + ": " + itostring(value);
|
string rc_string = rname + ": " + itostring(value);
|
||||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = True;
|
||||||
if (m_autosave)
|
if (m_autosave)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void Configuration::setValue(const string &rname, const char *value) {
|
||||||
string rc_string = rname + ": " + value;
|
string rc_string = rname + ": " + value;
|
||||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = True;
|
||||||
if (m_autosave)
|
if (m_autosave)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ void Configuration::setValue(const string &rname, const string &value) {
|
||||||
string rc_string = rname + ": " + value;
|
string rc_string = rname + ": " + value;
|
||||||
XrmPutLineResource(&m_database, rc_string.c_str());
|
XrmPutLineResource(&m_database, rc_string.c_str());
|
||||||
|
|
||||||
m_modified = true;
|
m_modified = True;
|
||||||
if (m_autosave)
|
if (m_autosave)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
@ -157,13 +157,13 @@ bool Configuration::getValue(const string &rname, bool &value) const {
|
||||||
XrmValue retvalue;
|
XrmValue retvalue;
|
||||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||||
return false;
|
return False;
|
||||||
string val = retvalue.addr;
|
string val = retvalue.addr;
|
||||||
if (val == "true" || val == "True")
|
if (val == "True" || val == "True")
|
||||||
value = true;
|
value = True;
|
||||||
else
|
else
|
||||||
value = false;
|
value = False;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configuration::getValue(const string &rname, long &value) const {
|
bool Configuration::getValue(const string &rname, long &value) const {
|
||||||
|
@ -175,12 +175,12 @@ bool Configuration::getValue(const string &rname, long &value) const {
|
||||||
XrmValue retvalue;
|
XrmValue retvalue;
|
||||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||||
return false;
|
return False;
|
||||||
char *end;
|
char *end;
|
||||||
value = strtol(retvalue.addr, &end, 10);
|
value = strtol(retvalue.addr, &end, 10);
|
||||||
if (end == retvalue.addr)
|
if (end == retvalue.addr)
|
||||||
return false;
|
return False;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configuration::getValue(const string &rname, unsigned long &value) const {
|
bool Configuration::getValue(const string &rname, unsigned long &value) const {
|
||||||
|
@ -192,12 +192,12 @@ bool Configuration::getValue(const string &rname, unsigned long &value) const {
|
||||||
XrmValue retvalue;
|
XrmValue retvalue;
|
||||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||||
return false;
|
return False;
|
||||||
char *end;
|
char *end;
|
||||||
value = strtoul(retvalue.addr, &end, 10);
|
value = strtoul(retvalue.addr, &end, 10);
|
||||||
if (end == retvalue.addr)
|
if (end == retvalue.addr)
|
||||||
return false;
|
return False;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configuration::getValue(const string &rname,
|
bool Configuration::getValue(const string &rname,
|
||||||
|
@ -210,9 +210,9 @@ bool Configuration::getValue(const string &rname,
|
||||||
XrmValue retvalue;
|
XrmValue retvalue;
|
||||||
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
if (0 == XrmGetResource(m_database, rname.c_str(), rclass.c_str(),
|
||||||
&rettype, &retvalue) || retvalue.addr == NULL)
|
&rettype, &retvalue) || retvalue.addr == NULL)
|
||||||
return false;
|
return False;
|
||||||
value = retvalue.addr;
|
value = retvalue.addr;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ string Configuration::createClassName(const string &rname) const {
|
||||||
string rclass(rname);
|
string rclass(rname);
|
||||||
|
|
||||||
string::iterator it = rclass.begin(), end = rclass.end();
|
string::iterator it = rclass.begin(), end = rclass.end();
|
||||||
while (true) {
|
while (True) {
|
||||||
*it = toUpper(*it);
|
*it = toUpper(*it);
|
||||||
++it;
|
++it;
|
||||||
if (it == end) break;
|
if (it == end) break;
|
||||||
|
|
34
src/XAtom.cc
34
src/XAtom.cc
|
@ -276,7 +276,7 @@ void XAtom::setValue(Window win, Atoms atom, Atoms type,
|
||||||
assert(atom >= 0 && atom < NUM_ATOMS);
|
assert(atom >= 0 && atom < NUM_ATOMS);
|
||||||
assert(type >= 0 && type < NUM_ATOMS);
|
assert(type >= 0 && type < NUM_ATOMS);
|
||||||
setValue(win, _atoms[atom], _atoms[type],
|
setValue(win, _atoms[atom], _atoms[type],
|
||||||
reinterpret_cast<unsigned char*>(&value), 32, 1, false);
|
reinterpret_cast<unsigned char*>(&value), 32, 1, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ void XAtom::setValue(Window win, Atoms atom, Atoms type,
|
||||||
assert(atom >= 0 && atom < NUM_ATOMS);
|
assert(atom >= 0 && atom < NUM_ATOMS);
|
||||||
assert(type >= 0 && type < NUM_ATOMS);
|
assert(type >= 0 && type < NUM_ATOMS);
|
||||||
setValue(win, _atoms[atom], _atoms[type],
|
setValue(win, _atoms[atom], _atoms[type],
|
||||||
reinterpret_cast<unsigned char*>(value), 32, elements, false);
|
reinterpret_cast<unsigned char*>(value), 32, elements, False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,11 +304,11 @@ void XAtom::setValue(Window win, Atoms atom, StringType type,
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ansi: t = _atoms[string]; break;
|
case ansi: t = _atoms[string]; break;
|
||||||
case utf8: t = _atoms[utf8_string]; break;
|
case utf8: t = _atoms[utf8_string]; break;
|
||||||
default: assert(false); // unhandled StringType
|
default: assert(False); // unhandled StringType
|
||||||
}
|
}
|
||||||
setValue(win, _atoms[atom], t,
|
setValue(win, _atoms[atom], t,
|
||||||
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
|
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
|
||||||
8, value.size() + 1, false); // add 1 to the size to include the null
|
8, value.size() + 1, False); // add 1 to the size to include the null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void XAtom::setValue(Window win, Atoms atom, StringType type,
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ansi: t = _atoms[string]; break;
|
case ansi: t = _atoms[string]; break;
|
||||||
case utf8: t = _atoms[utf8_string]; break;
|
case utf8: t = _atoms[utf8_string]; break;
|
||||||
default: assert(false); // unhandled StringType
|
default: assert(False); // unhandled StringType
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string value;
|
std::string value;
|
||||||
|
@ -336,14 +336,14 @@ void XAtom::setValue(Window win, Atoms atom, StringType type,
|
||||||
|
|
||||||
setValue(win, _atoms[atom], t,
|
setValue(win, _atoms[atom], t,
|
||||||
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
|
reinterpret_cast<unsigned char *>(const_cast<char *>(value.c_str())),
|
||||||
8, value.size(), false);
|
8, value.size(), False);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Internal getValue function used by all of the typed getValue functions.
|
* Internal getValue function used by all of the typed getValue functions.
|
||||||
* Gets an property's value from a window.
|
* Gets an property's value from a window.
|
||||||
* Returns true if the property was successfully retrieved; false if the
|
* Returns True if the property was successfully retrieved; False if the
|
||||||
* property did not exist on the window, or has a different type/size format
|
* property did not exist on the window, or has a different type/size format
|
||||||
* than the user tried to retrieve.
|
* than the user tried to retrieve.
|
||||||
*/
|
*/
|
||||||
|
@ -368,7 +368,7 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
|
||||||
// an error occured, the property does not exist on the window, or is empty,
|
// an error occured, the property does not exist on the window, or is empty,
|
||||||
// or the wrong data is in property for the request
|
// or the wrong data is in property for the request
|
||||||
if (c_val) XFree(c_val);
|
if (c_val) XFree(c_val);
|
||||||
return false;
|
return False;
|
||||||
}
|
}
|
||||||
// the data is correct, now, is there more elements left?
|
// the data is correct, now, is there more elements left?
|
||||||
if (ret_bytes == 0 || maxread <= nelements) {
|
if (ret_bytes == 0 || maxread <= nelements) {
|
||||||
|
@ -376,7 +376,7 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
|
||||||
*value = new unsigned char[nelements * size/8 + 1];
|
*value = new unsigned char[nelements * size/8 + 1];
|
||||||
memcpy(*value, c_val, nelements * size/8 + 1);
|
memcpy(*value, c_val, nelements * size/8 + 1);
|
||||||
XFree(c_val);
|
XFree(c_val);
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
// get the entire property since it is larger than one long
|
// get the entire property since it is larger than one long
|
||||||
XFree(c_val);
|
XFree(c_val);
|
||||||
|
@ -393,7 +393,7 @@ bool XAtom::getValue(Window win, Atom atom, Atom type,
|
||||||
*value = new unsigned char[nelements * size/8 + 1];
|
*value = new unsigned char[nelements * size/8 + 1];
|
||||||
memcpy(*value, c_val, nelements * size/8 + 1);
|
memcpy(*value, c_val, nelements * size/8 + 1);
|
||||||
XFree(c_val);
|
XFree(c_val);
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -421,10 +421,10 @@ bool XAtom::getValue(Window win, Atoms atom, Atoms type,
|
||||||
unsigned long num = 1;
|
unsigned long num = 1;
|
||||||
if (! getValue(win, _atoms[atom], _atoms[type], num,
|
if (! getValue(win, _atoms[atom], _atoms[type], num,
|
||||||
reinterpret_cast<unsigned char **>(&temp), 32))
|
reinterpret_cast<unsigned char **>(&temp), 32))
|
||||||
return false;
|
return False;
|
||||||
value = temp[0];
|
value = temp[0];
|
||||||
delete [] temp;
|
delete [] temp;
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -437,9 +437,9 @@ bool XAtom::getValue(Window win, Atoms atom, StringType type,
|
||||||
StringVect s;
|
StringVect s;
|
||||||
if (getValue(win, atom, type, n, s)) {
|
if (getValue(win, atom, type, n, s)) {
|
||||||
value = s[0];
|
value = s[0];
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
return false;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -454,13 +454,13 @@ bool XAtom::getValue(Window win, Atoms atom, StringType type,
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ansi: t = _atoms[string]; break;
|
case ansi: t = _atoms[string]; break;
|
||||||
case utf8: t = _atoms[utf8_string]; break;
|
case utf8: t = _atoms[utf8_string]; break;
|
||||||
default: assert(false); // unhandled StringType
|
default: assert(False); // unhandled StringType
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *value;
|
unsigned char *value;
|
||||||
unsigned long elements = (unsigned) -1;
|
unsigned long elements = (unsigned) -1;
|
||||||
if (!getValue(win, _atoms[atom], t, elements, &value, 8) || elements < 1)
|
if (!getValue(win, _atoms[atom], t, elements, &value, 8) || elements < 1)
|
||||||
return false;
|
return False;
|
||||||
|
|
||||||
std::string s(reinterpret_cast<char *>(value), elements);
|
std::string s(reinterpret_cast<char *>(value), elements);
|
||||||
delete [] value;
|
delete [] value;
|
||||||
|
@ -479,7 +479,7 @@ bool XAtom::getValue(Window win, Atoms atom, StringType type,
|
||||||
|
|
||||||
nelements = num;
|
nelements = num;
|
||||||
|
|
||||||
return true;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue