From 18bdbfaad269fe7ab688194739391695b874bbd1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 24 May 2002 18:19:22 +0000 Subject: [PATCH] better string get/set --- src/XAtom.cc | 12 +++++++----- src/XAtom.h | 7 +++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/XAtom.cc b/src/XAtom.cc index 0f36ef9b..9e590126 100644 --- a/src/XAtom.cc +++ b/src/XAtom.cc @@ -182,7 +182,8 @@ void XAtom::setPixmapValue(Window win, Atom atom, Pixmap value) const { /* * Set a string property value on a window. */ -void XAtom::setStringValue(Window win, Atom atom, std::string &value) const { +void XAtom::setStringValue(Window win, Atom atom, + const std::string &value) const { setValue(win, atom, XA_STRING, const_cast (reinterpret_cast(value.c_str())), @@ -229,7 +230,8 @@ void XAtom::addPixmapValue(Window win, Atom atom, Pixmap value) const { /* * Add characters to a string property value on a window. */ -void XAtom::addStringValue(Window win, Atom atom, std::string &value) const { +void XAtom::addStringValue(Window win, Atom atom, + const std::string &value) const { setValue(win, atom, XA_STRING, const_cast (reinterpret_cast @@ -328,10 +330,10 @@ bool XAtom::getPixmapValue(Window win, Atom atom, unsigned long *nelements, /* * Gets an string property's value from a window. */ -bool XAtom::getStringValue(Window win, Atom atom, unsigned long *nelements, - std::string &value) const { +bool XAtom::getStringValue(Window win, Atom atom, std::string &value) const { unsigned char *data; - bool ret = XAtom::getValue(win, atom, XA_STRING, nelements, &data, 8); + unsigned long nelements; + bool ret = XAtom::getValue(win, atom, XA_STRING, &nelements, &data, 8); if (ret) value = reinterpret_cast(data); return ret; diff --git a/src/XAtom.h b/src/XAtom.h index 38e790de..03292b5d 100644 --- a/src/XAtom.h +++ b/src/XAtom.h @@ -122,13 +122,13 @@ public: void setAtomValue(Window win, Atom atom, Atom value) const; void setWindowValue(Window win, Atom atom, Window value) const; void setPixmapValue(Window win, Atom atom, Pixmap value) const; - void setStringValue(Window win, Atom atom, std::string &value) const; + void setStringValue(Window win, Atom atom, const std::string &value) const; void addCardValue(Window win, Atom atom, long value) const; // 32-bit CARDINAL void addAtomValue(Window win, Atom atom, Atom value) const; void addWindowValue(Window win, Atom atom, Window value) const; void addPixmapValue(Window win, Atom atom, Pixmap value) const; - void addStringValue(Window win, Atom atom, std::string &value) const; + void addStringValue(Window win, Atom atom, const std::string &value) const; // the 'value' is allocated inside the function and // delete [] value needs to be called when you are done with it. @@ -142,8 +142,7 @@ public: Window **value) const; bool getPixmapValue(Window win, Atom atom, unsigned long *nelements, Pixmap **value) const; - bool getStringValue(Window win, Atom atom, unsigned long *nelements, - std::string &value) const; + bool getStringValue(Window win, Atom atom, std::string &value) const; void eraseValue(Window win, Atom atom) const; -- 2.39.2