DBus-1-TQt
1.0
tqdbusobjectpath.cpp
Go to the documentation of this file.
1
/* tqdbusobjectpath.cpp DBUS object path data type
2
*
3
* Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at>
4
*
5
* Licensed under the Academic Free License version 2.1
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
* USA.
21
*
22
*/
23
24
#include "
tqdbusobjectpath.h
"
25
26
TQT_DBusObjectPath::TQT_DBusObjectPath
() : TQString()
27
{
28
}
29
30
TQT_DBusObjectPath::TQT_DBusObjectPath
(
const
TQT_DBusObjectPath
&other) : TQString(static_cast<const TQString&>(other))
31
{
32
}
33
34
TQT_DBusObjectPath::TQT_DBusObjectPath
(
const
TQString &other) : TQString(static_cast<const TQString&>(other))
35
{
36
}
37
38
TQT_DBusObjectPath::TQT_DBusObjectPath
(
const
TQT_DBusObjectPath
&parentNode,
const
TQString &nodeName)
39
: TQString(static_cast<const TQString&>(parentNode))
40
{
41
if
(
parentNode
.length() != 1)
42
{
43
append(
"/"
);
44
}
45
append(nodeName);
46
}
47
48
bool
TQT_DBusObjectPath::isValid
()
const
49
{
50
return
(
validate
(*
this
) == -1);
51
}
52
53
TQT_DBusObjectPath
TQT_DBusObjectPath::parentNode
()
const
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
}
72
73
int
TQT_DBusObjectPath::validate
(
const
TQString &path)
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
}
TQT_DBusObjectPath::validate
static int validate(const TQString &path)
Checks the given string for validity as a D-Bus object path.
Definition:
tqdbusobjectpath.cpp:73
TQT_DBusObjectPath
Class for representing D-Bus object paths.
Definition:
tqdbusobjectpath.h:38
TQT_DBusObjectPath::isValid
bool isValid() const
Returns whether the current content is considered a valid object path.
Definition:
tqdbusobjectpath.cpp:48
TQT_DBusObjectPath::parentNode
TQT_DBusObjectPath parentNode() const
Returns the object path of this path's parent node.
Definition:
tqdbusobjectpath.cpp:53
TQT_DBusObjectPath::TQT_DBusObjectPath
TQT_DBusObjectPath()
Creates an empty and invalid object path.
Definition:
tqdbusobjectpath.cpp:26
tqdbusobjectpath.h
build
dbus-1-tqt-UDPazA
dbus-1-tqt-14.1.2
src
tqdbusobjectpath.cpp
Generated by
1.8.17