Branch: master

00b00f99 2019-05-20 14:22:18 Michele Calgaro
Modified TQT_DBusObjectPath to inherit from TQString instead of
TQCString.

Signed-off-by: Michele Calgaro <michele.calgaro@...>
M src/tqdbusmarshall.cpp
M src/tqdbusobjectpath.cpp
M src/tqdbusobjectpath.h

src/tqdbusmarshall.cpp

diff --git a/src/tqdbusmarshall.cpp b/src/tqdbusmarshall.cpp
index 7f0781f..f0cc9c0 100644
--- a/src/tqdbusmarshall.cpp
+++ b/src/tqdbusmarshall.cpp
@@ -652,7 +652,7 @@
 
 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);
 }
 

src/tqdbusobjectpath.cpp

diff --git a/src/tqdbusobjectpath.cpp b/src/tqdbusobjectpath.cpp
index 0f42860..bdd9634 100644
--- a/src/tqdbusobjectpath.cpp
+++ b/src/tqdbusobjectpath.cpp
@@ -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@...>
  *
@@ -23,24 +23,25 @@
 
 #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,
-                                 const TQCString& nodeName)
-    : TQCString(static_cast<const TQCString&>(parentNode))
+TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath &parentNode, const TQString &nodeName)
+    : TQString(static_cast<const TQString&>(parentNode))
 {
-    if (parentNode.length() != 1) append("/");
-
+    if (parentNode.length() != 1)
+    {
+      append("/");
+    }
     append(nodeName);
 }
 
@@ -51,29 +52,37 @@
 
 TQT_DBusObjectPath TQT_DBusObjectPath::parentNode() const
 {
-    if (length() == 1) return TQT_DBusObjectPath();
+    if (length() == 1)
+    {
+      return TQT_DBusObjectPath();
+    }
 
     int index = findRev('/');
-
-    if (index == -1) return TQT_DBusObjectPath();
-
-    if (index == 0) return left(1);
+    if (index == -1)
+    {
+      return TQT_DBusObjectPath();
+    }
+    else if (index == 0)
+    {
+      return left(1);
+    }
 
     return left(index);
 }
 
-int TQT_DBusObjectPath::validate(const TQCString& path)
+int TQT_DBusObjectPath::validate(const TQString &path)
 {
-    if (path.isEmpty()) return 0;
-
-    if (path[0] != '/') return 0;
-
-    // TODO add additional checks
-
-    uint len = path.length();
+    if (path.isEmpty() || path[0] != '/')
+    {
+      return 0;
+    }
 
     // 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;
 }

src/tqdbusobjectpath.h

diff --git a/src/tqdbusobjectpath.h b/src/tqdbusobjectpath.h
index 7a166c6..3d184d3 100644
--- a/src/tqdbusobjectpath.h
+++ b/src/tqdbusobjectpath.h
@@ -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@...>
  *
@@ -18,13 +18,12 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  * USA.
- *
  */
 
 #ifndef TQDBUSOBJECTPATH_H
 #define TQDBUSOBJECTPATH_H
 
-#include <tqcstring.h>
+#include <tqstring.h>
 #include "tqdbusmacros.h"
 
 /**
@@ -36,7 +35,7 @@
  *
  * @see @ref dbusconventions-objectpath
  */
-class TQDBUS_EXPORT TQT_DBusObjectPath : public TQCString
+class TQDBUS_EXPORT TQT_DBusObjectPath : public TQString
 {
 public:
     /**
@@ -49,14 +48,14 @@
      *
      * @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
      *
      * @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
@@ -76,7 +75,7 @@
      * @param parentNode the object path to create the child on
      * @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
@@ -113,7 +112,7 @@
      *
      * @see isValid()
      */
-    static int validate(const TQCString& path);
+    static int validate(const TQString &path);
 };
 
 #endif