Modified TQT_DBusObjectPath to inherit from TQString instead of

TQCString.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/18/head
Michele Calgaro 5 years ago
parent 6b319e0482
commit 00b00f9961
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -652,7 +652,7 @@ static void tqAppendToMessage(DBusMessageIter *it, const TQString &str)
static void tqAppendToMessage(DBusMessageIter *it, const TQT_DBusObjectPath &path) static void tqAppendToMessage(DBusMessageIter *it, const TQT_DBusObjectPath &path)
{ {
const char *cdata = path.data(); const char *cdata = path.ascii();
dbus_message_iter_append_basic(it, DBUS_TYPE_OBJECT_PATH, &cdata); dbus_message_iter_append_basic(it, DBUS_TYPE_OBJECT_PATH, &cdata);
} }

@ -1,4 +1,4 @@
/* qdbusobjectpath.cpp DBUS object path data type /* tqdbusobjectpath.cpp DBUS object path data type
* *
* Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at> * Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at>
* *
@ -23,24 +23,25 @@
#include "tqdbusobjectpath.h" #include "tqdbusobjectpath.h"
TQT_DBusObjectPath::TQT_DBusObjectPath() : TQCString() TQT_DBusObjectPath::TQT_DBusObjectPath() : TQString()
{ {
} }
TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath& other) : TQCString(static_cast<const TQCString&>(other)) TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath &other) : TQString(static_cast<const TQString&>(other))
{ {
} }
TQT_DBusObjectPath::TQT_DBusObjectPath(const TQCString& other) : TQCString(static_cast<const TQCString&>(other)) TQT_DBusObjectPath::TQT_DBusObjectPath(const TQString &other) : TQString(static_cast<const TQString&>(other))
{ {
} }
TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath& parentNode, TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath &parentNode, const TQString &nodeName)
const TQCString& nodeName) : TQString(static_cast<const TQString&>(parentNode))
: TQCString(static_cast<const TQCString&>(parentNode))
{ {
if (parentNode.length() != 1) append("/"); if (parentNode.length() != 1)
{
append("/");
}
append(nodeName); append(nodeName);
} }
@ -51,29 +52,37 @@ bool TQT_DBusObjectPath::isValid() const
TQT_DBusObjectPath TQT_DBusObjectPath::parentNode() const TQT_DBusObjectPath TQT_DBusObjectPath::parentNode() const
{ {
if (length() == 1) return TQT_DBusObjectPath(); if (length() == 1)
{
return TQT_DBusObjectPath();
}
int index = findRev('/'); int index = findRev('/');
if (index == -1)
if (index == -1) return TQT_DBusObjectPath(); {
return TQT_DBusObjectPath();
if (index == 0) return left(1); }
else if (index == 0)
{
return left(1);
}
return left(index); return left(index);
} }
int TQT_DBusObjectPath::validate(const TQCString& path) int TQT_DBusObjectPath::validate(const TQString &path)
{ {
if (path.isEmpty()) return 0; if (path.isEmpty() || path[0] != '/')
{
if (path[0] != '/') return 0; return 0;
}
// TODO add additional checks
uint len = path.length();
// only root node allowed to end in slash // only root node allowed to end in slash
if (path[len - 1] == '/' && len > 1) return (len - 1); uint len = path.length();
if (path[len - 1] == '/' && len > 1)
{
return (len - 1);
}
return -1; return -1;
} }

@ -1,4 +1,4 @@
/* qdbusobjectpath.h DBUS object path data type /* tqdbusobjectpath.h DBUS object path data type
* *
* Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at> * Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at>
* *
@ -18,13 +18,12 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA. * USA.
*
*/ */
#ifndef TQDBUSOBJECTPATH_H #ifndef TQDBUSOBJECTPATH_H
#define TQDBUSOBJECTPATH_H #define TQDBUSOBJECTPATH_H
#include <tqcstring.h> #include <tqstring.h>
#include "tqdbusmacros.h" #include "tqdbusmacros.h"
/** /**
@ -36,7 +35,7 @@
* *
* @see @ref dbusconventions-objectpath * @see @ref dbusconventions-objectpath
*/ */
class TQDBUS_EXPORT TQT_DBusObjectPath : public TQCString class TQDBUS_EXPORT TQT_DBusObjectPath : public TQString
{ {
public: public:
/** /**
@ -49,14 +48,14 @@ public:
* *
* @param other the object path to copy * @param other the object path to copy
*/ */
TQT_DBusObjectPath(const TQT_DBusObjectPath& other); TQT_DBusObjectPath(const TQT_DBusObjectPath &other);
/** /**
* @brief Creates copy of the given @p other object path * @brief Creates copy of the given @p other object path
* *
* @param other the object path to copy * @param other the object path to copy
*/ */
TQT_DBusObjectPath(const TQCString& other); TQT_DBusObjectPath(const TQString &other);
/** /**
* @brief Creates an object path for an object as a child of the parent node * @brief Creates an object path for an object as a child of the parent node
@ -76,7 +75,7 @@ public:
* @param parentNode the object path to create the child on * @param parentNode the object path to create the child on
* @param nodeName the name of the child node * @param nodeName the name of the child node
*/ */
TQT_DBusObjectPath(const TQT_DBusObjectPath& parentNode, const TQCString& nodeName); TQT_DBusObjectPath(const TQT_DBusObjectPath &parentNode, const TQString &nodeName);
/** /**
* @brief Returns whether the current content is considered a valid object path * @brief Returns whether the current content is considered a valid object path
@ -113,7 +112,7 @@ public:
* *
* @see isValid() * @see isValid()
*/ */
static int validate(const TQCString& path); static int validate(const TQString &path);
}; };
#endif #endif

Loading…
Cancel
Save