summaryrefslogtreecommitdiffstats
path: root/qtools/qgstring.h
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2006-09-10 20:49:41 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2006-09-10 20:49:41 (GMT)
commitb1dbef9886c3bf49050a5f49b9ae9d12021e4b50 (patch)
treefe67587a09765b41e54254d65f53b6c9352816e9 /qtools/qgstring.h
parent7b814d4aaf6321e05503a392c163537fd618066c (diff)
downloadDoxygen-b1dbef9886c3bf49050a5f49b9ae9d12021e4b50.zip
Doxygen-b1dbef9886c3bf49050a5f49b9ae9d12021e4b50.tar.gz
Doxygen-b1dbef9886c3bf49050a5f49b9ae9d12021e4b50.tar.bz2
Release-1.4.7-20060910
Diffstat (limited to 'qtools/qgstring.h')
-rw-r--r--qtools/qgstring.h137
1 files changed, 137 insertions, 0 deletions
diff --git a/qtools/qgstring.h b/qtools/qgstring.h
new file mode 100644
index 0000000..d3b997f
--- /dev/null
+++ b/qtools/qgstring.h
@@ -0,0 +1,137 @@
+#ifndef QGSTRING_H
+#define QGSTRING_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#if defined(_OS_SUN_) && defined(_CC_GNU_)
+#include <strings.h>
+#endif
+
+#include "qcstring.h"
+
+/*****************************************************************************
+ Fixes and workarounds for some platforms
+ *****************************************************************************/
+
+/** This is an alternative implementation of QCString.
+ */
+class QGString
+{
+ public:
+ QGString(); // make null string
+ QGString(uint size);
+ QGString( const QGString &s );
+ QGString( const char *str );
+ ~QGString() ;
+
+ bool resize( uint newlen );
+
+ QGString &operator=( const QGString &s );
+ QGString &operator=( const char *str );
+ QGString &operator+=( const QGString &s );
+ QGString &operator+=( const char *str );
+ QGString &operator+=( char c );
+
+ bool isNull() const { return m_data==0; }
+ bool isEmpty() const { return m_len==0; }
+ uint length() const { return m_len; }
+ uint size() const { return m_memSize; }
+ char * data() const { return m_data; }
+ bool truncate( uint pos ) { return resize(pos+1); }
+ operator const char *() const { return (const char *)data(); }
+ char &at( uint index ) const { return m_data[index]; }
+ char &operator[]( int i ) const { return at(i); }
+
+ private:
+ char * m_data;
+ uint m_len;
+ uint m_memSize;
+};
+
+/*****************************************************************************
+ QGString non-member operators
+ *****************************************************************************/
+
+Q_EXPORT inline bool operator==( const QGString &s1, const QGString &s2 )
+{ return qstrcmp(s1.data(),s2.data()) == 0; }
+
+Q_EXPORT inline bool operator==( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) == 0; }
+
+Q_EXPORT inline bool operator==( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) == 0; }
+
+Q_EXPORT inline bool operator!=( const QGString &s1, const QGString &s2 )
+{ return qstrcmp(s1.data(),s2.data()) != 0; }
+
+Q_EXPORT inline bool operator!=( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) != 0; }
+
+Q_EXPORT inline bool operator!=( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) != 0; }
+
+Q_EXPORT inline bool operator<( const QGString &s1, const QGString& s2 )
+{ return qstrcmp(s1.data(),s2.data()) < 0; }
+
+Q_EXPORT inline bool operator<( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) < 0; }
+
+Q_EXPORT inline bool operator<( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) < 0; }
+
+Q_EXPORT inline bool operator<=( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) <= 0; }
+
+Q_EXPORT inline bool operator<=( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) <= 0; }
+
+Q_EXPORT inline bool operator>( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) > 0; }
+
+Q_EXPORT inline bool operator>( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) > 0; }
+
+Q_EXPORT inline bool operator>=( const QGString &s1, const char *s2 )
+{ return qstrcmp(s1.data(),s2) >= 0; }
+
+Q_EXPORT inline bool operator>=( const char *s1, const QGString &s2 )
+{ return qstrcmp(s1,s2.data()) >= 0; }
+
+Q_EXPORT inline QGString operator+( const QGString &s1, const QGString &s2 )
+{
+ QGString tmp( s1.data() );
+ tmp += s2;
+ return tmp;
+}
+
+Q_EXPORT inline QGString operator+( const QGString &s1, const char *s2 )
+{
+ QGString tmp( s1.data() );
+ tmp += s2;
+ return tmp;
+}
+
+Q_EXPORT inline QGString operator+( const char *s1, const QGString &s2 )
+{
+ QGString tmp( s1 );
+ tmp += s2;
+ return tmp;
+}
+
+Q_EXPORT inline QGString operator+( const QGString &s1, char c2 )
+{
+ QGString tmp( s1.data() );
+ tmp += c2;
+ return tmp;
+}
+
+Q_EXPORT inline QGString operator+( char c1, const QGString &s2 )
+{
+ QGString tmp;
+ tmp += c1;
+ tmp += s2;
+ return tmp;
+}
+
+#endif // QGSTRING_H