• Main Page
  • Related Pages
  • Classes
  • Files
  • Examples
  • File List
  • File Members

tqdbusobjectpath.cpp

Go to the documentation of this file.
00001 /* qdbusobjectpath.cpp DBUS object path data type
00002  *
00003  * Copyright (C) 2007 Kevin Krammer <kevin.krammer@gmx.at>
00004  *
00005  * Licensed under the Academic Free License version 2.1
00006  *
00007  * This program is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00020  * USA.
00021  *
00022  */
00023 
00024 #include "tqdbusobjectpath.h"
00025 
00026 TQT_DBusObjectPath::TQT_DBusObjectPath() : TQCString()
00027 {
00028 }
00029 
00030 TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath& other) : TQCString(static_cast<const TQCString&>(other))
00031 {
00032 }
00033 
00034 TQT_DBusObjectPath::TQT_DBusObjectPath(const TQCString& other) : TQCString(static_cast<const TQCString&>(other))
00035 {
00036 }
00037 
00038 TQT_DBusObjectPath::TQT_DBusObjectPath(const TQT_DBusObjectPath& parentNode,
00039                                  const TQCString& nodeName)
00040     : TQCString(static_cast<const TQCString&>(parentNode))
00041 {
00042     if (parentNode.length() != 1) append("/");
00043 
00044     append(nodeName);
00045 }
00046 
00047 bool TQT_DBusObjectPath::isValid() const
00048 {
00049     return (validate(*this) == -1);
00050 }
00051 
00052 TQT_DBusObjectPath TQT_DBusObjectPath::parentNode() const
00053 {
00054     if (length() == 1) return TQT_DBusObjectPath();
00055 
00056     int index = findRev('/');
00057 
00058     if (index == -1) return TQT_DBusObjectPath();
00059 
00060     if (index == 0) return left(1);
00061 
00062     return left(index);
00063 }
00064 
00065 int TQT_DBusObjectPath::validate(const TQCString& path)
00066 {
00067     if (path.isEmpty()) return 0;
00068 
00069     if (path[0] != '/') return 0;
00070 
00071     // TODO add additional checks
00072 
00073     uint len = path.length();
00074 
00075     // only root node allowed to end in slash
00076     if (path[len - 1] == '/' && len > 1) return (len - 1);
00077 
00078     return -1;
00079 }

Generated on Fri Apr 26 2019 17:49:48 for DBus-1-TQt by  doxygen 1.7.1