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

KHTML

QualifiedName.cpp

Go to the documentation of this file.
00001 /*
00002  * This file is part of the DOM implementation for KDE.
00003  *
00004  * Copyright (C) 2005, 2006 Apple Computer, Inc.
00005  * Copyright (C) 2008 Vyacheslav Tokarev (tsjoker@gmail.com)
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library 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 GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIB.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USA.
00021  *
00022  */
00023 
00024 #include "QualifiedName.h"
00025 #include "xml/dom_nodeimpl.h"
00026 
00027 namespace DOM {
00028 
00029 QualifiedName::QualifiedName(const DOMString& prefix, const DOMString& localName, const DOMString& namespaceURI)
00030 {
00031     m_prefix = PrefixName::fromString(prefix);
00032     m_localName = LocalName::fromString(localName);
00033     m_namespace = NamespaceName::fromString(namespaceURI);
00034 }
00035 
00036 QualifiedName::QualifiedName(const QualifiedName& name)
00037 {
00038     m_prefix = name.prefixId();
00039     m_namespace = name.namespaceNameId();
00040     m_localName = name.localNameId();
00041 }
00042 
00043 QualifiedName::QualifiedName(int prefix, int localName, int namespaceName)
00044 {
00045     m_prefix = PrefixName::fromId(prefix);
00046     m_localName = LocalName::fromId(localName);
00047     m_namespace = NamespaceName::fromId(namespaceName);
00048 }
00049 
00050 QualifiedName::QualifiedName(quint32 id, PrefixName prefix) {
00051     m_prefix = prefix;
00052     m_localName = LocalName::fromId(localNamePart(id));
00053     m_namespace = NamespaceName::fromId(namespacePart(id));
00054 }
00055 
00056 const QualifiedName& QualifiedName::operator=(const QualifiedName& name)
00057 {
00058     m_prefix = name.prefixId();
00059     m_namespace = name.namespaceNameId();
00060     m_localName = name.localNameId();
00061     return *this;
00062 }
00063 
00064 bool QualifiedName::operator==(const QualifiedName& other) const
00065 {
00066     /*kDebug() << m_prefix.id() << other.prefixId().id() << ((m_prefix == other.prefixId())) << endl;
00067     kDebug() << (m_prefix == other.prefixId()) << (m_localName == other.localNameId()) << (m_namespace == other.namespaceNameId()) << endl;*/
00068     return (m_prefix == other.prefixId() && m_localName == other.localNameId() && m_namespace == other.namespaceNameId());
00069 }
00070 
00071 bool QualifiedName::hasPrefix() const
00072 {
00073     return m_prefix.id() != 0/*emptyPrefix*/; 
00074 }
00075 
00076 bool QualifiedName::matches(const QualifiedName& other) const
00077 {
00078     //FIXME: IMPLEMENT
00079     return *this == other || (m_localName == other.localNameId() && (m_prefix == other.prefixId() || m_namespace == other.namespaceNameId()));
00080 }
00081 
00082 void QualifiedName::setPrefix(const PrefixName& prefix) {
00083     m_prefix = prefix;
00084 }
00085 
00086 void QualifiedName::setPrefix(const DOMString& prefix) {
00087     m_prefix = PrefixName::fromString(prefix);
00088 }
00089 
00090 unsigned QualifiedName::id() const
00091 {
00092     return (m_namespace.id() << 16) ^ (m_localName.id());
00093 }
00094 
00095 DOMString QualifiedName::tagName() const
00096 {
00097     DOMString prefix = m_prefix.toString();
00098     DOMString localName = m_localName.toString();
00099     if (prefix.isEmpty())
00100         return localName;
00101     return prefix + ":" + localName;
00102 }
00103 
00104 DOMString QualifiedName::prefix() const
00105 {
00106     return m_prefix.toString();
00107 }
00108 
00109 DOMString QualifiedName::localName() const
00110 {
00111     return m_localName.toString();
00112 }
00113 
00114 DOMString QualifiedName::namespaceURI() const
00115 {
00116     return m_namespace.toString();
00117 }
00118 
00119 DOMString QualifiedName::toString() const
00120 {
00121     return prefix() + ":" + localName();
00122 }
00123 
00124 }
00125 
00126 // kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;

KHTML

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal