KD SOAP API Documentation: KDQName.cpp Source File

| KD SOAP API Documentation 2.2

Loading...
Searching...
No Matches
KDQName.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDE Schema Parser
3
4 SPDX-FileCopyrightText: 2005 Tobias Koenig <tokoe@kde.org>
5 based on wsdlpull parser by Vivek Krishna
6
7 SPDX-License-Identifier: MIT
8 */
9
10#include "KDQName.h"
11#include <QDebug>
12
13#include <KDSoapValue.h>
14
15KDQName::KDQName()
16{
17}
18
19 KDQName::KDQName(const QString &name)
20{
21 parse(name);
22}
23
24 KDQName::KDQName(const QString &nameSpace, const QString &localName)
25 : mNameSpace(nameSpace)
26 , mLocalName(localName)
27{
28 Q_ASSERT(!localName.contains(QLatin1Char(':')));
29}
30
31 void KDQName::operator=(const QString &name)
32{
33 parse(name);
34}
35
36 QString KDQName::localName() const
37{
38 return mLocalName;
39}
40
41 QString KDQName::prefix() const
42{
43 return mPrefix;
44}
45
46 QString KDQName::qname() const
47{
48 if (mPrefix.isEmpty())
49 return mLocalName;
50 else
51 return mPrefix + QLatin1Char(':') + mLocalName;
52}
53
54 void KDQName::setNameSpace(const QString &nameSpace)
55{
56 mNameSpace = nameSpace;
57}
58
59 QString KDQName::nameSpace() const
60{
61 return mNameSpace;
62}
63
64 bool KDQName::operator==(const KDQName &qname) const
65{
66 return (qname.nameSpace() == mNameSpace && qname.localName() == mLocalName);
67}
68
69 bool KDQName::operator!=(const KDQName &qname) const
70{
71 return !operator==(qname);
72}
73
74 bool KDQName::isEmpty() const
75{
76 return (mNameSpace.isEmpty() && mLocalName.isEmpty());
77}
78
79 KDQName KDQName::fromSoapValue(const KDSoapValue &value)
80{
81 KDQName qname;
82 qname.parse(value.value().toString());
83
84 QXmlStreamNamespaceDeclarations decls = value.environmentNamespaceDeclarations();
85 for (int i = 0; i < decls.count(); ++i) {
86 const QXmlStreamNamespaceDeclaration &decl = decls.at(i);
87 if (decl.prefix() == qname.prefix()) {
88 qname.setNameSpace(decl.namespaceUri().toString());
89 }
90 }
91
92 return qname;
93}
94
95 KDSoapValue KDQName::toSoapValue(const QString &name, const QString &typeNameSpace, const QString &typeName) const
96{
97 KDSoapValue value = KDSoapValue(name, qname(), typeNameSpace, typeName);
98 if (!mPrefix.isEmpty() && !mNameSpace.isEmpty()) {
99 QXmlStreamNamespaceDeclaration decl(mPrefix, mNameSpace);
100 value.addNamespaceDeclaration(decl);
101 }
102 return value;
103}
104
105void KDQName::parse(const QString &str)
106{
107 int pos = str.indexOf(QLatin1Char(':'));
108 if (pos != -1) {
109 mPrefix = str.left(pos);
110 mLocalName = str.mid(pos + 1);
111 } else {
112 mLocalName = str;
113 }
114 Q_ASSERT(!mLocalName.contains(QLatin1Char(':')));
115}
116
117 QDebug operator<<(QDebug dbg, const KDQName &qn)
118{
119 if (!qn.nameSpace().isEmpty())
120 dbg << "(" << qn.nameSpace() << "," << qn.localName() << ")";
121 else
122 dbg << qn.qname();
123 return dbg;
124}
operator<<
QDebug operator<<(QDebug dbg, const KDQName &qn)
Definition KDQName.cpp:117
KDQName.h
KDSoapValue.h
KDQName
Definition KDQName.h:23
KDQName::operator!=
bool operator!=(const KDQName &) const
Definition KDQName.cpp:69
KDQName::setNameSpace
void setNameSpace(const QString &nameSpace)
Definition KDQName.cpp:54
KDQName::operator==
bool operator==(const KDQName &) const
Definition KDQName.cpp:64
KDQName::toSoapValue
KDSoapValue toSoapValue(const QString &name, const QString &typeNameSpace=QString(), const QString &typeName=QString()) const
Definition KDQName.cpp:95
KDQName::fromSoapValue
static KDQName fromSoapValue(const KDSoapValue &value)
Definition KDQName.cpp:79
KDQName::localName
QString localName() const
Definition KDQName.cpp:36
KDQName::KDQName
KDQName()
Definition KDQName.cpp:15
KDQName::prefix
QString prefix() const
Definition KDQName.cpp:41
KDQName::operator=
void operator=(const QString &name)
Definition KDQName.cpp:31
KDQName::isEmpty
bool isEmpty() const
Definition KDQName.cpp:74
KDQName::qname
QString qname() const
Definition KDQName.cpp:46
KDQName::nameSpace
QString nameSpace() const
Definition KDQName.cpp:59
KDSoapValue
Definition KDSoapValue.h:60
KDSoapValue::environmentNamespaceDeclarations
QXmlStreamNamespaceDeclarations environmentNamespaceDeclarations() const
Definition KDSoapValue.cpp:144
KDSoapValue::addNamespaceDeclaration
void addNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &namespaceDeclaration)
Definition KDSoapValue.cpp:129
KDSoapValue::value
QVariant value() const
Definition KDSoapValue.cpp:104
QDebug
QLatin1Char
QString
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
QString::indexOf
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
QString::isEmpty
bool isEmpty() const const
QString::left
QString left(int n) const const
QString::mid
QString mid(int position, int n) const const
QStringRef::toString
QString toString() const const
QVariant::toString
QString toString() const const
QXmlStreamNamespaceDeclaration
QXmlStreamNamespaceDeclaration::namespaceUri
QStringRef namespaceUri() const const
QXmlStreamNamespaceDeclaration::prefix
QStringRef prefix() const const

© 2010-2024 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Sun Jan 7 2024 11:47:36 for KD SOAP API Documentation by doxygen 1.9.8