3
* Copyright (C) 2006 Remko Troncon
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
#include <QStringList>
28
* \brief A class representing an entity capability specification.
29
* An entity capability is a combination of a node, a version, and a set of
34
* Default constructor.
42
* \brief Basic constructor.
43
* @param node the node
44
* @param ven the version
45
* @param ext the list of extensions (separated by spaces)
47
CapsSpec::CapsSpec(const QString& node, const QString& ver, const QString& ext) : node_(node), ver_(ver), ext_(ext)
53
* \brief Returns the node of the capabilities specification.
55
const QString& CapsSpec::node() const
62
* \brief Returns the version of the capabilities specification.
64
const QString& CapsSpec::version() const
71
* \brief Returns the extensions of the capabilities specification.
73
const QString& CapsSpec::extensions() const
80
* \brief Flattens the caps specification into the set of 'simple'
82
* A 'simple' specification is a specification with exactly one extension,
83
* or with the version number as the extension.
85
* Example: A caps specification with node=http://psi-im.org, version=0.10,
86
* and ext='achat vchat' would be expanded into the following list of specs:
87
* node=http://psi-im.org, ver=0.10, ext=0.10
88
* node=http://psi-im.org, ver=0.10, ext=achat
89
* node=http://psi-im.org, ver=0.10, ext=vchat
91
CapsSpecs CapsSpec::flatten() const
94
l.append(CapsSpec(node(),version(),version()));
95
QStringList exts(extensions().split(" ",QString::SkipEmptyParts));
96
for (QStringList::ConstIterator i = exts.begin(); i != exts.end(); ++i) {
97
l.append(CapsSpec(node(),version(),*i));
102
bool CapsSpec::operator==(const CapsSpec& s) const
104
return (node() == s.node() && version() == s.version() && extensions() == s.extensions());
107
bool CapsSpec::operator!=(const CapsSpec& s) const
109
return !((*this) == s);
112
bool CapsSpec::operator<(const CapsSpec& s) const
114
return (node() != s.node() ? node() < s.node() :
115
(version() != s.version() ? version() < s.version() :
116
extensions() < s.extensions()));