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

KHTML

  • khtml
  • dom
dom_string.h
Go to the documentation of this file.
1/*
2 * This file is part of the DOM implementation for KDE.
3 *
4 * Copyright 1999 Lars Knoll (knoll@kde.org)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22#ifndef _DOM_DOMString_h_
23#define _DOM_DOMString_h_
24
25#include <khtml_export.h>
26#include <kdebug.h>
27#include <QtCore/QString>
28#include <limits.h>
29
30namespace DOM {
31
32class DOMStringImpl;
33
43class KHTML_EXPORT DOMString
44{
45 friend class CharacterDataImpl;
46 friend KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
47public:
51 DOMString() : impl(0) {}
52
53 DOMString(const QChar *str, uint len);
54 DOMString(const QString &);
55 DOMString(const char *str);
59 DOMString(const char *str, uint len);
60 DOMString(DOMStringImpl *i);
61
62 virtual ~DOMString();
63
64 // assign and copy
65 DOMString(const DOMString &str);
66 DOMString &operator =(const DOMString &str);
67
71 DOMString &operator += (const DOMString &str);
75 DOMString operator + (const DOMString &str);
76
77 void insert(DOMString str, uint pos);
78
83 const QChar &operator [](unsigned int i) const;
84
85 int find(const QChar c, int start = 0) const;
86 int reverseFind(const QChar c, int start = -1) const;
87
88 DOMString substring(unsigned pos, unsigned len = UINT_MAX) const;
89
90 uint length() const;
91 void truncate( unsigned int len );
92 void remove(unsigned int pos, int len=1);
96 DOMString split(unsigned int pos);
97
101 DOMString lower() const;
105 DOMString upper() const;
106
107 QChar *unicode() const;
108 // for WebCore API compatibility
109 inline QChar *characters() const { return unicode(); }
110 QString string() const;
111
112 int toInt() const;
113 int toInt(bool* ok) const;
114 float toFloat(bool* ok = 0) const;
115 bool percentage(int &_percentage) const;
116
117 static DOMString number(float f);
118
119 DOMString copy() const;
120
121 bool isNull() const { return (impl == 0); }
122 bool isEmpty() const;
123
124 bool endsWith(const DOMString& str) const;
125 bool startsWith(const DOMString& str) const;
126
134 DOMString parsedUrl() const;
135
139#ifndef KDE_NO_DEPRECATED
140 KDE_DEPRECATED DOMString trimSpaces() const;
141#endif
142
147 DOMStringImpl *implementation() const { return impl; }
148
149 static DOMString format(const char* format, ...)
150#if defined(__GNUC__)
151 __attribute__ ((format (printf, 1, 2)))
152#endif
153 ;
154
155protected:
156 DOMStringImpl *impl;
157};
158
159inline QDebug operator<<(QDebug stream, const DOMString &string) {
160 return (stream << (string.implementation() ? string.string() : QString::fromLatin1("null")));
161}
162
163KHTML_EXPORT bool operator==( const DOMString &a, const DOMString &b );
164KHTML_EXPORT bool operator==( const DOMString &a, const QString &b );
165KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
166inline bool operator!=( const DOMString &a, const DOMString &b ) { return !(a==b); }
167inline bool operator!=( const DOMString &a, const QString &b ) { return !(a==b); }
168inline bool operator!=( const DOMString &a, const char *b ) { return !(a==b); }
169inline bool strcmp( const DOMString &a, const DOMString &b ) { return a != b; }
170
171// returns false when equal, true otherwise (ignoring case)
172KHTML_EXPORT bool strcasecmp( const DOMString &a, const DOMString &b );
173KHTML_EXPORT bool strcasecmp( const DOMString& a, const char* b );
174
175}
176#endif
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
DOM::DOMString::DOMString
DOMString()
default constructor.
Definition: dom_string.h:51
DOM::DOMString::impl
DOMStringImpl * impl
Definition: dom_string.h:156
DOM::DOMString::characters
QChar * characters() const
Definition: dom_string.h:109
DOM::DOMString::isNull
bool isNull() const
Definition: dom_string.h:121
DOM::DOMString::implementation
DOMStringImpl * implementation() const
Definition: dom_string.h:147
DOM::DOMString::operator==
friend bool operator==(const DOMString &a, const char *b)
kdebug.h
khtml_export.h
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
DOM::operator!=
bool operator!=(const DOMString &a, const DOMString &b)
Definition: dom_string.h:166
DOM::operator==
bool operator==(const DOMString &a, const DOMString &b)
Definition: dom_string.cpp:418
DOM::operator<<
QDebug operator<<(QDebug stream, const DOMString &string)
Definition: dom_string.h:159
DOM::strcasecmp
bool strcasecmp(const DOMString &a, const DOMString &b)
Definition: dom_string.cpp:348
DOM::strcmp
bool strcmp(const DOMString &a, const DOMString &b)
Definition: dom_string.h:169
number
QString number(KIO::filesize_t size)
copy
KAction * copy(const QObject *recvr, const char *slot, QObject *parent)
find
KAction * find(const QObject *recvr, const char *slot, QObject *parent)
remove
KGuiItem remove()
insert
const KShortcut & insert()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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