Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/qtools/qgstring.h

Source at commit 1406 created 12 years 10 months ago.
By meklort, Revert drivers.c so that kexts are only loaded when OSBundleRequired is set and that value is not safe mode. Added some comments about it too.
1#ifndef QGSTRING_H
2#define QGSTRING_H
3
4#include <stdlib.h>
5#include <string.h>
6
7#if defined(_OS_SUN_) && defined(_CC_GNU_)
8#include <strings.h>
9#endif
10
11#include "qcstring.h"
12
13/*****************************************************************************
14 Fixes and workarounds for some platforms
15 *****************************************************************************/
16
17/** This is an alternative implementation of QCString.
18 */
19class QGString
20{
21 public:
22 QGString(); // make null string
23 QGString(uint size);
24 QGString( const QGString &s );
25 QGString( const char *str );
26 ~QGString() ;
27
28 bool resize( uint newlen );
29 bool enlarge( uint newlen );
30 void setLen( uint newlen );
31
32 QGString &operator=( const QGString &s );
33 QGString &operator=( const char *str );
34 QGString &operator+=( const QGString &s );
35 QGString &operator+=( const char *str );
36 QGString &operator+=( char c );
37
38 bool isNull() const { return m_data==0; }
39 boolisEmpty()const { return m_len==0; }
40 uintlength()const { return m_len; }
41 uint size() const { return m_memSize; }
42 char * data() const { return m_data; }
43 booltruncate( uint pos ) { return resize(pos+1); }
44 operator const char *() const { return (const char *)data(); }
45 char &at( uint index ) const { return m_data[index]; }
46 char &operator[]( int i ) const { return at(i); }
47
48 private:
49 char * m_data;
50 uint m_len;
51 uint m_memSize;
52};
53
54/*****************************************************************************
55 QGString non-member operators
56 *****************************************************************************/
57
58Q_EXPORT inline bool operator==( const QGString &s1, const QGString &s2 )
59{ return qstrcmp(s1.data(),s2.data()) == 0; }
60
61Q_EXPORT inline bool operator==( const QGString &s1, const char *s2 )
62{ return qstrcmp(s1.data(),s2) == 0; }
63
64Q_EXPORT inline bool operator==( const char *s1, const QGString &s2 )
65{ return qstrcmp(s1,s2.data()) == 0; }
66
67Q_EXPORT inline bool operator!=( const QGString &s1, const QGString &s2 )
68{ return qstrcmp(s1.data(),s2.data()) != 0; }
69
70Q_EXPORT inline bool operator!=( const QGString &s1, const char *s2 )
71{ return qstrcmp(s1.data(),s2) != 0; }
72
73Q_EXPORT inline bool operator!=( const char *s1, const QGString &s2 )
74{ return qstrcmp(s1,s2.data()) != 0; }
75
76Q_EXPORT inline bool operator<( const QGString &s1, const QGString& s2 )
77{ return qstrcmp(s1.data(),s2.data()) < 0; }
78
79Q_EXPORT inline bool operator<( const QGString &s1, const char *s2 )
80{ return qstrcmp(s1.data(),s2) < 0; }
81
82Q_EXPORT inline bool operator<( const char *s1, const QGString &s2 )
83{ return qstrcmp(s1,s2.data()) < 0; }
84
85Q_EXPORT inline bool operator<=( const QGString &s1, const char *s2 )
86{ return qstrcmp(s1.data(),s2) <= 0; }
87
88Q_EXPORT inline bool operator<=( const char *s1, const QGString &s2 )
89{ return qstrcmp(s1,s2.data()) <= 0; }
90
91Q_EXPORT inline bool operator>( const QGString &s1, const char *s2 )
92{ return qstrcmp(s1.data(),s2) > 0; }
93
94Q_EXPORT inline bool operator>( const char *s1, const QGString &s2 )
95{ return qstrcmp(s1,s2.data()) > 0; }
96
97Q_EXPORT inline bool operator>=( const QGString &s1, const char *s2 )
98{ return qstrcmp(s1.data(),s2) >= 0; }
99
100Q_EXPORT inline bool operator>=( const char *s1, const QGString &s2 )
101{ return qstrcmp(s1,s2.data()) >= 0; }
102
103Q_EXPORT inline QGString operator+( const QGString &s1, const QGString &s2 )
104{
105 QGString tmp( s1.data() );
106 tmp += s2;
107 return tmp;
108}
109
110Q_EXPORT inline QGString operator+( const QGString &s1, const char *s2 )
111{
112 QGString tmp( s1.data() );
113 tmp += s2;
114 return tmp;
115}
116
117Q_EXPORT inline QGString operator+( const char *s1, const QGString &s2 )
118{
119 QGString tmp( s1 );
120 tmp += s2;
121 return tmp;
122}
123
124Q_EXPORT inline QGString operator+( const QGString &s1, char c2 )
125{
126 QGString tmp( s1.data() );
127 tmp += c2;
128 return tmp;
129}
130
131Q_EXPORT inline QGString operator+( char c1, const QGString &s2 )
132{
133 QGString tmp;
134 tmp += c1;
135 tmp += s2;
136 return tmp;
137}
138
139#endif // QGSTRING_H
140

Archive Download this file

Revision: 1406