summaryrefslogtreecommitdiffstats
path: root/tdehtml/dom/dom_string.h
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:21 -0600
commitdfe289850f068f19ba4a83ab4e7e22a7e09c13c9 (patch)
treec297348a55df66c571de4525646e0b9762427353 /tdehtml/dom/dom_string.h
parentb7658a0d5eca24a9d37c6e04f88298ef02389db0 (diff)
downloadtdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.tar.gz
tdelibs-dfe289850f068f19ba4a83ab4e7e22a7e09c13c9.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdehtml/dom/dom_string.h')
-rw-r--r--tdehtml/dom/dom_string.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/tdehtml/dom/dom_string.h b/tdehtml/dom/dom_string.h
new file mode 100644
index 000000000..3d4706b5a
--- /dev/null
+++ b/tdehtml/dom/dom_string.h
@@ -0,0 +1,144 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * (C) 1999 Lars Knoll (knoll@kde.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef _DOM_DOMString_h_
+#define _DOM_DOMString_h_
+
+#include <kdebug.h>
+#include <tqstring.h>
+
+#include <tdelibs_export.h>
+
+namespace DOM {
+
+class DOMStringImpl;
+
+/**
+ * This class implements the basic string we use in the DOM. We do not use
+ * TQString for 2 reasons: Memory overhead, and the missing explicit sharing
+ * of strings we need for the DOM.
+ *
+ * All DOMStrings are explicitly shared (they behave like pointers), meaning
+ * that modifications to one instance will also modify all others. If you
+ * wish to get a DOMString that is independent, use copy().
+ */
+class KHTML_EXPORT DOMString
+{
+ friend class CharacterDataImpl;
+ friend KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
+public:
+ /**
+ * default constructor. Gives an empty DOMString
+ */
+ DOMString() : impl(0) {}
+
+ DOMString(const TQChar *str, uint len);
+ DOMString(const TQString &);
+ DOMString(const char *str);
+ DOMString(DOMStringImpl *i);
+
+ virtual ~DOMString();
+
+ // assign and copy
+ DOMString(const DOMString &str);
+ DOMString &operator =(const DOMString &str);
+
+ /**
+ * append str to this string
+ */
+ DOMString &operator += (const DOMString &str);
+ /**
+ * add two DOMString's
+ */
+ DOMString operator + (const DOMString &str);
+
+ void insert(DOMString str, uint pos);
+
+ /**
+ * The character at position i of the DOMString. If i >= length(), the
+ * character returned will be 0.
+ */
+ const TQChar &operator [](unsigned int i) const;
+
+ int find(const TQChar c, int start = 0) const;
+
+ uint length() const;
+ void truncate( unsigned int len );
+ void remove(unsigned int pos, int len=1);
+ /**
+ * Splits the string into two. The original string gets truncated to pos, and the rest is returned.
+ */
+ DOMString split(unsigned int pos);
+
+ /**
+ * Returns a lowercase version of the string
+ */
+ DOMString lower() const;
+ /**
+ * Returns an uppercase version of the string
+ */
+ DOMString upper() const;
+
+ TQChar *unicode() const;
+ TQString string() const;
+
+ int toInt() const;
+ bool percentage(int &_percentage) const;
+
+ DOMString copy() const;
+
+ bool isNull() const { return (impl == 0); }
+ bool isEmpty() const;
+
+ /**
+ * @internal get a handle to the imlementation of the DOMString
+ * Use at own risk!!!
+ */
+ DOMStringImpl *implementation() const { return impl; }
+
+protected:
+ DOMStringImpl *impl;
+};
+
+#ifndef NDEBUG
+inline kdbgstream &operator<<(kdbgstream &stream, const DOMString &string) {
+ return (stream << string.string());
+}
+#else
+inline kndbgstream &operator<<(kndbgstream &stream, const DOMString &) {
+ return stream;
+}
+#endif
+
+KHTML_EXPORT bool operator==( const DOMString &a, const DOMString &b );
+KHTML_EXPORT bool operator==( const DOMString &a, const TQString &b );
+KHTML_EXPORT bool operator==( const DOMString &a, const char *b );
+inline bool operator!=( const DOMString &a, const DOMString &b ) { return !(a==b); }
+inline bool operator!=( const DOMString &a, const TQString &b ) { return !(a==b); }
+inline bool operator!=( const DOMString &a, const char *b ) { return !(a==b); }
+inline bool strcmp( const DOMString &a, const DOMString &b ) { return a != b; }
+
+// returns false when equal, true otherwise (ignoring case)
+KHTML_EXPORT bool strcasecmp( const DOMString &a, const DOMString &b );
+KHTML_EXPORT bool strcasecmp( const DOMString& a, const char* b );
+
+}
+#endif