• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • dom
QualifiedName.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DOM implementation for KDE.
3  *
4  * Copyright (C) 2005, 2006 Apple Computer, Inc.
5  * Copyright (C) 2008 Vyacheslav Tokarev (tsjoker@gmail.com)
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23 
24 #include "QualifiedName.h"
25 #include "xml/dom_nodeimpl.h"
26 
27 namespace DOM {
28 
29 QualifiedName::QualifiedName(const DOMString& prefix, const DOMString& localName, const DOMString& namespaceURI)
30 {
31  m_prefix = PrefixName::fromString(prefix);
32  m_localName = LocalName::fromString(localName);
33  m_namespace = NamespaceName::fromString(namespaceURI);
34 }
35 
36 QualifiedName::QualifiedName(const QualifiedName& name)
37 {
38  m_prefix = name.prefixId();
39  m_namespace = name.namespaceNameId();
40  m_localName = name.localNameId();
41 }
42 
43 QualifiedName::QualifiedName(int prefix, int localName, int namespaceName)
44 {
45  m_prefix = PrefixName::fromId(prefix);
46  m_localName = LocalName::fromId(localName);
47  m_namespace = NamespaceName::fromId(namespaceName);
48 }
49 
50 QualifiedName::QualifiedName(quint32 id, PrefixName prefix) {
51  m_prefix = prefix;
52  m_localName = LocalName::fromId(localNamePart(id));
53  m_namespace = NamespaceName::fromId(namespacePart(id));
54 }
55 
56 const QualifiedName& QualifiedName::operator=(const QualifiedName& name)
57 {
58  m_prefix = name.prefixId();
59  m_namespace = name.namespaceNameId();
60  m_localName = name.localNameId();
61  return *this;
62 }
63 
64 bool QualifiedName::operator==(const QualifiedName& other) const
65 {
66  /*kDebug() << m_prefix.id() << other.prefixId().id() << ((m_prefix == other.prefixId())) << endl;
67  kDebug() << (m_prefix == other.prefixId()) << (m_localName == other.localNameId()) << (m_namespace == other.namespaceNameId()) << endl;*/
68  return (m_prefix == other.prefixId() && m_localName == other.localNameId() && m_namespace == other.namespaceNameId());
69 }
70 
71 bool QualifiedName::hasPrefix() const
72 {
73  return m_prefix.id() != 0/*emptyPrefix*/;
74 }
75 
76 bool QualifiedName::matches(const QualifiedName& other) const
77 {
78  //FIXME: IMPLEMENT
79  return *this == other || (m_localName == other.localNameId() && (m_prefix == other.prefixId() || m_namespace == other.namespaceNameId()));
80 }
81 
82 void QualifiedName::setPrefix(const PrefixName& prefix) {
83  m_prefix = prefix;
84 }
85 
86 void QualifiedName::setPrefix(const DOMString& prefix) {
87  m_prefix = PrefixName::fromString(prefix);
88 }
89 
90 unsigned QualifiedName::id() const
91 {
92  return (m_namespace.id() << 16) ^ (m_localName.id());
93 }
94 
95 DOMString QualifiedName::tagName() const
96 {
97  DOMString prefix = m_prefix.toString();
98  DOMString localName = m_localName.toString();
99  if (prefix.isEmpty())
100  return localName;
101  return prefix + DOMString(":") + localName;
102 }
103 
104 DOMString QualifiedName::prefix() const
105 {
106  return m_prefix.toString();
107 }
108 
109 DOMString QualifiedName::localName() const
110 {
111  return m_localName.toString();
112 }
113 
114 DOMString QualifiedName::namespaceURI() const
115 {
116  return m_namespace.toString();
117 }
118 
119 DOMString QualifiedName::toString() const
120 {
121  return prefix() + DOMString(":") + localName();
122 }
123 
124 }
125 
126 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;
DOM::QualifiedName::localNameId
LocalName localNameId() const
Definition: QualifiedName.h:59
DOM::QualifiedName::hasPrefix
bool hasPrefix() const
Definition: QualifiedName.cpp:71
DOM::QualifiedName::operator==
bool operator==(const QualifiedName &other) const
Definition: QualifiedName.cpp:64
DOM::QualifiedName
Definition: QualifiedName.h:36
DOM::QualifiedName::id
unsigned id() const
Definition: QualifiedName.cpp:90
DOM::QualifiedName::QualifiedName
QualifiedName()
Definition: QualifiedName.h:38
quint32
DOM::DOMString::isEmpty
bool isEmpty() const
Definition: dom_string.cpp:315
QualifiedName.h
DOM::QualifiedName::tagName
DOMString tagName() const
Definition: QualifiedName.cpp:95
DOM::QualifiedName::localName
DOMString localName() const
Definition: QualifiedName.cpp:109
DOM::QualifiedName::operator=
const QualifiedName & operator=(const QualifiedName &name)
Definition: QualifiedName.cpp:56
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
DOM::QualifiedName::namespaceNameId
NamespaceName namespaceNameId() const
Definition: QualifiedName.h:60
DOM::QualifiedName::prefixId
PrefixName prefixId() const
Definition: QualifiedName.h:58
DOM::QualifiedName::prefix
DOMString prefix() const
Definition: QualifiedName.cpp:104
DOM::QualifiedName::namespaceURI
DOMString namespaceURI() const
Definition: QualifiedName.cpp:114
DOM::QualifiedName::setPrefix
void setPrefix(const PrefixName &prefix)
Definition: QualifiedName.cpp:82
DOM::QualifiedName::toString
DOMString toString() const
Definition: QualifiedName.cpp:119
DOM::QualifiedName::matches
bool matches(const QualifiedName &other) const
Definition: QualifiedName.cpp:76
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal