KHTML
dom_string.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _DOM_DOMString_h_
00023 #define _DOM_DOMString_h_
00024
00025 #include <khtml_export.h>
00026 #include <kdebug.h>
00027 #include <QtCore/QString>
00028 #include <limits.h>
00029
00030 namespace DOM {
00031
00032 class DOMStringImpl;
00033
00043 class KHTML_EXPORT DOMString
00044 {
00045 friend class CharacterDataImpl;
00046 friend KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
00047 public:
00051 DOMString() : impl(0) {}
00052
00053 DOMString(const QChar *str, uint len);
00054 DOMString(const QString &);
00055 DOMString(const char *str);
00059 DOMString(const char *str, uint len);
00060 DOMString(DOMStringImpl *i);
00061
00062 virtual ~DOMString();
00063
00064
00065 DOMString(const DOMString &str);
00066 DOMString &operator =(const DOMString &str);
00067
00071 DOMString &operator += (const DOMString &str);
00075 DOMString operator + (const DOMString &str);
00076
00077 void insert(DOMString str, uint pos);
00078
00083 const QChar &operator [](unsigned int i) const;
00084
00085 int find(const QChar c, int start = 0) const;
00086 int reverseFind(const QChar c, int start = -1) const;
00087
00088 DOMString substring(unsigned pos, unsigned len = UINT_MAX) const;
00089
00090 uint length() const;
00091 void truncate( unsigned int len );
00092 void remove(unsigned int pos, int len=1);
00096 DOMString split(unsigned int pos);
00097
00101 DOMString lower() const;
00105 DOMString upper() const;
00106
00107 QChar *unicode() const;
00108
00109 inline QChar *characters() const { return unicode(); }
00110 QString string() const;
00111
00112 int toInt() const;
00113 int toInt(bool* ok) const;
00114 float toFloat(bool* ok = 0) const;
00115 bool percentage(int &_percentage) const;
00116
00117 static DOMString number(float f);
00118
00119 DOMString copy() const;
00120
00121 bool isNull() const { return (impl == 0); }
00122 bool isEmpty() const;
00123
00124 bool endsWith(const DOMString& str) const;
00125 bool startsWith(const DOMString& str) const;
00126
00131 DOMStringImpl *implementation() const { return impl; }
00132
00133 static DOMString format(const char* format, ...);
00134
00135 protected:
00136 DOMStringImpl *impl;
00137 };
00138
00139 inline QDebug operator<<(QDebug stream, const DOMString &string) {
00140 return (stream << (string.implementation() ? string.string() : QString::fromLatin1("null")));
00141 }
00142
00143 KHTML_EXPORT bool operator==( const DOMString &a, const DOMString &b );
00144 KHTML_EXPORT bool operator==( const DOMString &a, const QString &b );
00145 KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
00146 inline bool operator!=( const DOMString &a, const DOMString &b ) { return !(a==b); }
00147 inline bool operator!=( const DOMString &a, const QString &b ) { return !(a==b); }
00148 inline bool operator!=( const DOMString &a, const char *b ) { return !(a==b); }
00149 inline bool strcmp( const DOMString &a, const DOMString &b ) { return a != b; }
00150
00151
00152 KHTML_EXPORT bool strcasecmp( const DOMString &a, const DOMString &b );
00153 KHTML_EXPORT bool strcasecmp( const DOMString& a, const char* b );
00154
00155 }
00156 #endif