DBus-1-TQt 1.0
TQT_DBusObjectPath Class Reference

#include <tqdbusobjectpath.h>

+ Inheritance diagram for TQT_DBusObjectPath:
+ Collaboration diagram for TQT_DBusObjectPath:

Public Member Functions

 TQT_DBusObjectPath ()
 
 TQT_DBusObjectPath (const TQT_DBusObjectPath &other)
 
 TQT_DBusObjectPath (const TQString &other)
 
 TQT_DBusObjectPath (const TQT_DBusObjectPath &parentNode, const TQString &nodeName)
 
bool isValid () const
 
TQT_DBusObjectPath parentNode () const
 

Static Public Member Functions

static int validate (const TQString &path)
 

Detailed Description

Class for representing D-Bus object paths.

This data type is necessary to correctly represent object paths in the context of D-Bus messages, since normal strings have a different D-Bus signature than object paths.

See also
Object paths

Definition at line 38 of file tqdbusobjectpath.h.

Constructor & Destructor Documentation

◆ TQT_DBusObjectPath() [1/4]

TQT_DBusObjectPath::TQT_DBusObjectPath ( )

Creates an empty and invalid object path.

Definition at line 26 of file tqdbusobjectpath.cpp.

26 : TQString()
27{
28}
+ Here is the caller graph for this function:

◆ TQT_DBusObjectPath() [2/4]

TQT_DBusObjectPath::TQT_DBusObjectPath ( const TQT_DBusObjectPath other)

Creates copy of the given other object path.

Parameters
otherthe object path to copy

Definition at line 30 of file tqdbusobjectpath.cpp.

30 : TQString(static_cast<const TQString&>(other))
31{
32}

◆ TQT_DBusObjectPath() [3/4]

TQT_DBusObjectPath::TQT_DBusObjectPath ( const TQString &  other)

Creates copy of the given other object path.

Parameters
otherthe object path to copy

Definition at line 34 of file tqdbusobjectpath.cpp.

34 : TQString(static_cast<const TQString&>(other))
35{
36}

◆ TQT_DBusObjectPath() [4/4]

TQT_DBusObjectPath::TQT_DBusObjectPath ( const TQT_DBusObjectPath parentNode,
const TQString &  nodeName 
)

Creates an object path for an object as a child of the parent node.

This is basically like specifying a directory and a file name to create the file's full path.

Example:

TQT_DBusObjectPath rootNode("/"); // => "/"
TQT_DBusObjectPath childNod(rootNode, "child"); // => "/child"
TQT_DBusObjectPath grandChildNode(childNode, "grandchild"); // => "/child/grandchild"
Class for representing D-Bus object paths.
Parameters
parentNodethe object path to create the child on
nodeNamethe name of the child node

Definition at line 38 of file tqdbusobjectpath.cpp.

39 : TQString(static_cast<const TQString&>(parentNode))
40{
41 if (parentNode.length() != 1)
42 {
43 append("/");
44 }
45 append(nodeName);
46}
TQT_DBusObjectPath parentNode() const
Returns the object path of this path's parent node.

References parentNode().

+ Here is the call graph for this function:

Member Function Documentation

◆ isValid()

bool TQT_DBusObjectPath::isValid ( ) const

Returns whether the current content is considered a valid object path.

Note
Calls validate() to perform a check on the current content
Returns
true if the object's content describe a valid object path, otherwise false
See also
Object paths

Definition at line 48 of file tqdbusobjectpath.cpp.

49{
50 return (validate(*this) == -1);
51}
static int validate(const TQString &path)
Checks the given string for validity as a D-Bus object path.

References validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parentNode()

TQT_DBusObjectPath TQT_DBusObjectPath::parentNode ( ) const

Returns the object path of this path's parent node.

This is basically like getting the directory of an file path

Returns
the parent node's object path or an empty and invalid object if this is already the root node

Definition at line 53 of file tqdbusobjectpath.cpp.

54{
55 if (length() == 1)
56 {
57 return TQT_DBusObjectPath();
58 }
59
60 int index = findRev('/');
61 if (index == -1)
62 {
63 return TQT_DBusObjectPath();
64 }
65 else if (index == 0)
66 {
67 return left(1);
68 }
69
70 return left(index);
71}
TQT_DBusObjectPath()
Creates an empty and invalid object path.

References TQT_DBusObjectPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validate()

int TQT_DBusObjectPath::validate ( const TQString &  path)
static

Checks the given string for validity as a D-Bus object path.

See section Object paths for information on object path formatting.

Parameters
paththe string to check
Returns
-1 if the object path is valid, otherwise the index of the first violating character
See also
isValid()

Definition at line 73 of file tqdbusobjectpath.cpp.

74{
75 if (path.isEmpty() || path[0] != '/')
76 {
77 return 0;
78 }
79
80 // only root node allowed to end in slash
81 uint len = path.length();
82 if (path[len - 1] == '/' && len > 1)
83 {
84 return (len - 1);
85 }
86
87 return -1;
88}
+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: