Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
string.h
1 /*
2  * $Id$
3  * Copyright (c) 2004-07, IRIT - UPS
4  *
5  * string module interface
6  */
7 #ifndef ELM_STRING_H
8 #define ELM_STRING_H
9 
10 #include <string.h>
11 #include <elm/string/CString.h>
12 #include <elm/string/String.h>
13 #include <elm/string/StringBuffer.h>
14 #include <elm/string/AutoString.h>
15 
16 namespace elm {
17 
18 // Back C Strings
19 inline CString CString::substring(int off) const { return CString(buf + off); };
20 inline String CString::substring(int off, int len) const { return String(buf + off, len); };
21 inline String CString::concat(const CString str) const { return String::concat(chars(), length(), str.chars(), str.length()); };
22 inline String CString::concat(const String& str) const { return String::concat(chars(), length(), str.chars(), str.length()); };
23 inline bool CString::startsWith(const char *str) const { return startsWith(CString(str)); };
24 inline bool CString::startsWith(const CString str) const { return !strncmp(buf, str.chars(), str.length()); };
25 inline bool CString::startsWith(const String& str) const { return !strncmp(buf, str.chars(), str.length()); };
26 inline bool CString::endsWith(const CString str) const
27  { int l1 = length(), l2 = str.length(); return l1 >= l2 && !memcmp(buf + l1 - l2, str.chars(), l2); };
28 inline bool CString::endsWith(const String& str) const
29  { int l1 = length(), l2 = str.length(); return l1 >= l2 && !memcmp(buf + l1 - l2, str.chars(), l2); };
30 
31 // Comparison inlines
32 inline bool operator==(const CString& s1, const CString& s2) { return s1.compare(s2) == 0; };
33 inline bool operator!=(const CString& s1, const CString& s2) { return s1.compare(s2) != 0; };
34 inline bool operator<(const CString s1, const CString s2) { return s1.compare(s2) < 0; };
35 inline bool operator<=(const CString s1, const CString s2) { return s1.compare(s2) <= 0; };
36 inline bool operator>(const CString s1, const CString s2) { return s1.compare(s2) > 0; };
37 inline bool operator>=(const CString s1, const CString s2) { return s1.compare(s2) >= 0; };
38 
39 inline bool operator==(const String& s1, const CString s2) { return s1.compare(s2) == 0; };
40 inline bool operator!=(const String& s1, const CString s2) { return s1.compare(s2) != 0; };
41 inline bool operator<(const String& s1, const CString s2) { return s1.compare(s2) < 0; };
42 inline bool operator<=(const String& s1, const CString s2) { return s1.compare(s2) <= 0; };
43 inline bool operator>(const String& s1, const CString s2) { return s1.compare(s2) > 0; };
44 inline bool operator>=(const String& s1, const CString s2) { return s1.compare(s2) >= 0; };
45 
46 inline bool operator==(const String& s1, const String& s2) { return s1.compare(s2) == 0; };
47 inline bool operator!=(const String& s1, const String& s2) { return s1.compare(s2) != 0; };
48 inline bool operator<(const String& s1, const String& s2) { return s1.compare(s2) < 0; };
49 inline bool operator<=(const String& s1, const String& s2) { return s1.compare(s2) <= 0; };
50 inline bool operator>(const String& s1, const String& s2) { return s1.compare(s2) > 0; };
51 inline bool operator>=(const String& s1, const String& s2) { return s1.compare(s2) >= 0; };
52 
53 inline bool operator==(const CString s1, const String& s2) { return s2.compare(s1) == 0; };
54 inline bool operator!=(const CString s1, const String& s2) { return s2.compare(s1) != 0; };
55 inline bool operator<(const CString s1, const String& s2) { return s2.compare(s1) >= 0; };
56 inline bool operator<=(const CString s1, const String& s2) { return s2.compare(s1) > 0; };
57 inline bool operator>(const CString s1, const String& s2) { return s2.compare(s1) <= 0; };
58 inline bool operator>=(const CString s1, const String& s2) { return s2.compare(s1) < 0; };
59 
60 inline bool operator==(const String& s1, const char *s2) { return s1.compare(CString(s2)) == 0; };
61 inline bool operator!=(const String& s1, const char *s2) { return s1.compare(CString(s2)) != 0; };
62 inline bool operator<(const String& s1, const char *s2) { return s1.compare(CString(s2)) < 0; };
63 inline bool operator<=(const String& s1, const char *s2) { return s1.compare(CString(s2)) <= 0; };
64 inline bool operator>(const String& s1, const char *s2) { return s1.compare(CString(s2)) > 0; };
65 inline bool operator>=(const String& s1, const char *s2) { return s1.compare(CString(s2)) >= 0; };
66 
67 inline bool operator==(const CString s1, const char *s2) { return s1.compare(CString(s2)) == 0; };
68 inline bool operator!=(const CString s1, const char *s2) { return s1.compare(CString(s2)) != 0; };
69 inline bool operator<(const CString s1, const char *s2) { return s1.compare(CString(s2)) < 0; };
70 inline bool operator<=(const CString s1, const char *s2) { return s1.compare(CString(s2)) <= 0; };
71 inline bool operator>(const CString s1, const char *s2) { return s1.compare(CString(s2)) > 0; };
72 inline bool operator>=(const CString s1, const char *s2) { return s1.compare(CString(s2)) >= 0; };
73 
74 inline bool operator==(const char *s1, const CString s2) { return s2.compare(CString(s1)) == 0; };
75 inline bool operator!=(const char *s1, const CString s2) { return s2.compare(CString(s1)) != 0; };
76 inline bool operator<(const char *s1, const CString s2) { return s2.compare(CString(s1)) >= 0; };
77 inline bool operator<=(const char *s1, const CString s2) { return s2.compare(CString(s1)) > 0; };
78 inline bool operator>(const char *s1, const CString s2) { return s2.compare(CString(s1)) <= 0; };
79 inline bool operator>=(const char *s1, const CString s2) { return s2.compare(CString(s1)) < 0; };
80 
81 inline bool operator==(const char *s1, const String& s2) { return s2.compare(CString(s1)) == 0; };
82 inline bool operator!=(const char *s1, const String& s2) { return s2.compare(CString(s1)) != 0; };
83 inline bool operator<(const char *s1, const String& s2) { return s2.compare(CString(s1)) >= 0; };
84 inline bool operator<=(const char *s1, const String& s2) { return s2.compare(CString(s1)) > 0; };
85 inline bool operator>(const char *s1, const String& s2) { return s2.compare(CString(s1)) <= 0; };
86 inline bool operator>=(const char *s1, const String& s2) { return s2.compare(CString(s1)) < 0; };
87 
88 
89 // Concatenation
90 inline String operator+(const CString s1, const CString s2) { return s1.concat(s2); }
91 inline String operator+(const CString s1, const char *s2) { return s1.concat(CString(s2)); };
92 inline String operator+(const CString s1, const String& s2) { return s1.concat(s2); };
93 inline String operator+(const String& s1, const CString s2) { return s1.concat(s2); };
94 inline String operator+(const String& s1, const char *s2) { return s1.concat(CString(s2)); };
95 inline String operator+(const String& s1, const String& s2) { return s1.concat(s2); };
96 inline String operator+(const char *s1, const CString s2) { return CString(s1).concat(s2); };
97 inline String operator+(const char *s1, const String& s2) { return CString(s1).concat(s2); };
98 };
99 
100 #endif // ELM_STRING_H
bool operator==(const CString &s1, const CString &s2)
Definition: string.h:32
CString substring(int pos) const
Definition: string.h:19
Definition: CString.h:17
bool operator>=(const CString s1, const CString s2)
Definition: string.h:37
int compare(const String &str) const
Definition: String.h:75
const char * buf
Definition: CString.h:19
bool operator>(const CString s1, const CString s2)
Definition: string.h:36
String concat(const CString str) const
Definition: string.h:21
const char * chars(void) const
Definition: String.h:74
bool endsWith(const CString str) const
Definition: string.h:26
bool operator!=(const CString &s1, const CString &s2)
Definition: string.h:33
bool operator<=(const CString s1, const CString s2)
Definition: string.h:35
bool operator<(const CString s1, const CString s2)
Definition: string.h:34
int length(void) const
Definition: String.h:73
Definition: String.h:31
CString(void)
Definition: CString.h:21
bool startsWith(const char *str) const
Definition: string.h:23
int length(void) const
Definition: CString.h:26
const char * chars(void) const
Definition: CString.h:27
int compare(const CString &str) const
Definition: CString.h:28
String operator+(const CString s1, const CString s2)
Definition: string.h:90