activemq-cpp-3.9.5
String.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _DECAF_LANG_STRING_H_
19#define _DECAF_LANG_STRING_H_
20
21#include <decaf/util/Config.h>
22
26
27#include <string>
28#include <ostream>
29
30namespace decaf {
31namespace lang {
32
33 class Contents;
35
58 private:
59
60 mutable Contents* contents;
61
62 public:
63
70
82 String(const char value, int count);
83
90 String(const String& source);
91
98 String(const std::string& source);
99
110 String(const char* array);
111
126 String(const char* array, int size);
127
144 String(const char* array, int offset, int length);
145
165 String(const char* array, int size, int offset, int length);
166
167 virtual ~String();
168
169 public:
170
181 String& operator= (const String& other);
182
193 String& operator= (const std::string& other);
194
205 String& operator= (const char* other);
206
216 bool operator==(const char* other) const;
217 bool operator==(const String& other) const;
218 bool operator==(const std::string& other) const;
219
229 bool operator!=(const char* other) const;
230 bool operator!=(const String& other) const;
231 bool operator!=(const std::string& other) const;
232
242 bool operator< (const char* other) const;
243 bool operator< (const String& other) const;
244 bool operator< (const std::string& other) const;
245
255 bool operator<=(const char* other) const;
256 bool operator<=(const String& other) const;
257 bool operator<=(const std::string& other) const;
258
268 bool operator> (const char* other) const;
269 bool operator> (const String& other) const;
270 bool operator> (const std::string& other) const;
271
281 bool operator>=(const char* other) const;
282 bool operator>=(const String& other) const;
283 bool operator>=(const std::string& other) const;
284
294 String operator+ (const String& other) const;
295 String operator+ (const std::string& other) const;
296 String operator+ (const char* other) const;
297
308 const char* c_str() const;
309
310 public:
311
325
343 int compareTo(const String& string) const;
344
362 int compareTo(const std::string& string) const;
363
383 int compareTo(const char* string) const;
384
398 int compareToIgnoreCase(const String& string) const;
399
413 int compareToIgnoreCase(const std::string& string) const;
414
430 int compareToIgnoreCase(const char* string) const;
431
441 String concat(const String& string) const;
442
452 String concat(const std::string& string) const;
453
463 String concat(const char* string) const;
464
475 bool contains(const String& string) const;
476
487 bool contains(const std::string& string) const;
488
499 bool contains(const char* string) const;
500
510 bool endsWith(const String& suffix) const;
511
520 bool equals(const String& other) const;
521
530 bool equals(const std::string& other) const;
531
542 bool equals(const char* other) const;
543
553 bool equalsIgnoreCase(const String& string) const;
554
564 bool equalsIgnoreCase(const std::string& string) const;
565
575 bool equalsIgnoreCase(const char* string) const;
576
588 int findFirstOf(const String& chars) const;
589
603 int findFirstOf(const String& chars, int start) const;
604
616 int findFirstNotOf(const String& chars) const;
617
631 int findFirstNotOf(const String& chars, int start) const;
632
655 void getChars(int srcBegin, int srcEnd, char* dest, int destSize, int destBegin) const;
656
663 int hashCode() const;
664
676 int indexOf(char value) const;
677
695 int indexOf(char value, int start) const;
696
708 int indexOf(const String& string) const;
709
723 int indexOf(const String& subString, int start) const;
724
736 int indexOf(const std::string& string) const;
737
751 int indexOf(const std::string& subString, int start) const;
752
764 int indexOf(const char* string) const;
765
779 int indexOf(const char* subString, int start) const;
780
784 bool isEmpty() const;
785
797 int lastIndexOf(char value) const;
798
812 int lastIndexOf(char value, int start) const;
813
825 int lastIndexOf(const String& string) const;
826
840 int lastIndexOf(const String& subString, int start) const;
841
853 int lastIndexOf(const std::string& string) const;
854
868 int lastIndexOf(const std::string& subString, int start) const;
869
881 int lastIndexOf(const char* string) const;
882
896 int lastIndexOf(const char* subString, int start) const;
897
915 bool regionMatches(int thisStart, const String& string, int start, int length) const;
916
935 bool regionMatches(bool ignoreCase, int thisStart, const String& string, int start, int length) const;
936
948 String replace(char oldChar, char newChar) const;
949
960 bool startsWith(const String& prefix) const;
961
974 bool startsWith(const String& prefix, int start) const;
975
987 String substring(int start) const;
988
1003 String substring(int start, int end) const;
1004
1015 char* toCharArray() const;
1016
1025
1034
1040 String trim() const;
1041
1042 public:
1043
1047 virtual int length() const;
1048
1052 virtual char charAt(int index) const;
1053
1057 virtual CharSequence* subSequence(int start, int end) const;
1058
1062 virtual std::string toString() const;
1063
1064 public:
1065
1078 static String copyValueOf(const char* data);
1079
1098 static String copyValueOf(char* data, int start, int length);
1099
1106 static bool isNullOrEmpty(const char*);
1107
1116 static String valueOf(bool value);
1117
1126 static String valueOf(char value);
1127
1136 static String valueOf(float value);
1137
1146 static String valueOf(double value);
1147
1156 static String valueOf(short value);
1157
1166 static String valueOf(int value);
1167
1176 static String valueOf(long long value);
1177
1178 private:
1179
1185 void getChars(int start, int end, char* buffer, int index) const;
1186
1187 String(Contents* content);
1188 String(int offset, int length, const ArrayPointer<char> content);
1189
1191 };
1192
1193 std::ostream& operator<<(std::ostream &out, const String& target);
1194
1195 bool operator==(const std::string& left, const String& right);
1196 bool operator==(const char* left, const String& right);
1197 bool operator!=(const std::string& left, const String& right);
1198 bool operator!=(const char* left, const String& right);
1199 bool operator<=(const std::string& left, const String& right);
1200 bool operator<=(const char* left, const String& right);
1201 bool operator>=(const std::string& left, const String& right);
1202 bool operator>=(const char* left, const String& right);
1203 bool operator< (const std::string& left, const String& right);
1204 bool operator< (const char* left, const String& right);
1205 bool operator> (const std::string& left, const String& right);
1206 bool operator> (const char* left, const String& right);
1207
1208}}
1209
1210#endif /* _DECAF_LANG_STRING_H_ */
A modifiable sequence of characters for use in creating and modifying Strings.
Definition AbstractStringBuilder.h:40
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition ArrayPointer.h:51
A CharSequence is a readable sequence of char values.
Definition CharSequence.h:36
An immutable sequence of characters.
Definition String.h:57
String toUpperCase() const
Converts the characters in this string to upper case.
virtual int length() const
the length of the underlying character sequence.
int compareTo(const std::string &string) const
Compares two strings lexicographically.
bool operator!=(const String &other) const
String(const char *array, int size, int offset, int length)
Create a new String object that represents the given array of characters.
bool isEmpty() const
bool operator<=(const String &other) const
static String valueOf(bool value)
Returns a String that represents the value of the given boolean value.
String concat(const char *string) const
Concatenates this string and the specified C string.
bool equals(const String &other) const
Returns true if this String is equal to the given String instance.
String substring(int start) const
Copies a range of characters into a new string starting from the given offset and extending to the en...
bool regionMatches(int thisStart, const String &string, int start, int length) const
Compares the specified string to this string and compares the specified range of characters to determ...
char * toCharArray() const
Copies the characters in this string to a newly allocated character array.
bool contains(const String &string) const
Determines if this String contains the sequence of characters in the String passed in.
int findFirstNotOf(const String &chars, int start) const
Searches in this string for the first index of any character that is not in the specified String.
bool operator!=(const std::string &other) const
bool operator>=(const std::string &other) const
int findFirstNotOf(const String &chars) const
Searches in this string for the first index of any character that is not in the specified String.
bool regionMatches(bool ignoreCase, int thisStart, const String &string, int start, int length) const
Compares the specified string to this string and compares the specified range of characters to determ...
int indexOf(const String &subString, int start) const
Searches in this string for the index of the specified string.
static String valueOf(int value)
Returns a String that represents the value of the given integer value.
int compareTo(const char *string) const
Compares two strings lexicographically.
String replace(char oldChar, char newChar) const
Copies this string replacing occurrences of the specified character with another character.
bool startsWith(const String &prefix, int start) const
Compares the specified string to this string, starting at the specified offset, to determine if the s...
int indexOf(const char *string) const
Searches in this String for the first index of the specified C string.
String trim() const
Returns a copy of the string, with leading and trailing whitespace omitted.
int compareToIgnoreCase(const String &string) const
Compares two strings lexicographically, ignoring case differences.
void getChars(int srcBegin, int srcEnd, char *dest, int destSize, int destBegin) const
Copies characters from this String into the destination char array, starting from the given index.
String concat(const String &string) const
Concatenates this string and the specified string.
virtual char charAt(int index) const
Returns the Char at the specified index so long as the index is not greater than the length of the se...
bool equals(const char *other) const
Returns true if this String is equal to the given C string instance.
int indexOf(const std::string &subString, int start) const
Searches in this string for the index of the specified std::string.
String(const char *array)
Create a new String object that represents the given array of characters, the C string must be null t...
int compareToIgnoreCase(const std::string &string) const
Compares two strings lexicographically, ignoring case differences.
int compareToIgnoreCase(const char *string) const
Compares two strings lexicographically, ignoring case differences.
String()
Creates a new empty String object.
bool operator<=(const char *other) const
Comparison operators for the various string types that uses the compareTo method to determine if the ...
int indexOf(const std::string &string) const
Searches in this String for the first index of the specified std::string.
virtual std::string toString() const
the String representation of this CharSequence
bool operator>=(const String &other) const
int lastIndexOf(char value) const
Searches in this string for the last index of the specified character.
String substring(int start, int end) const
Copies a range of characters into a new string.
static String valueOf(char value)
Returns a String that represents the value of the given char value.
int lastIndexOf(const String &string) const
Searches in this string for the last index of the specified string.
bool equalsIgnoreCase(const String &string) const
Compares the specified string to this string ignoring the case of the characters and returns true if ...
int compareTo(const String &string) const
Compares two strings lexicographically.
bool contains(const char *string) const
Determines if this String contains the sequence of characters in the C String passed in.
int indexOf(char value) const
Searches in this string for the first index of the specified character.
static String valueOf(float value)
Returns a String that represents the value of the given float value.
bool equalsIgnoreCase(const char *string) const
Compares the specified C string to this string ignoring the case of the characters and returns true i...
int lastIndexOf(const String &subString, int start) const
Searches in this string for the index of the specified string.
bool operator==(const std::string &other) const
int indexOf(char value, int start) const
Searches in this string for the index of the specified character.
bool operator>=(const char *other) const
Comparison operators for the various string types that uses the compareTo method to determine if the ...
int findFirstOf(const String &chars, int start) const
Searches in this string for the first index of any character in the specified String.
String concat(const std::string &string) const
Concatenates this string and the specified std::string.
int lastIndexOf(char value, int start) const
Searches in this string for the index of the specified character.
virtual CharSequence * subSequence(int start, int end) const
Returns a new CharSequence that is a subsequence of this sequence.The subsequence starts with the cha...
bool operator<=(const std::string &other) const
bool operator==(const String &other) const
int indexOf(const char *subString, int start) const
Searches in this string for the index of the specified C string.
int lastIndexOf(const char *subString, int start) const
Searches in this string for the index of the specified C string.
int findFirstOf(const String &chars) const
Searches in this string for the first index of any character in the specified String.
String(const String &source)
Create a new String object that represents the given STL string.
int lastIndexOf(const std::string &string) const
Searches in this string for the last index of the specified std::string.
bool operator==(const char *other) const
Comparison operators for the various string types that uses the equals method to determine equality.
bool endsWith(const String &suffix) const
Compares the specified string to this string to determine if the specified string is a suffix.
static bool isNullOrEmpty(const char *)
Given a C String pointer return true if the value is either NULL or the string contained is empty.
bool contains(const std::string &string) const
Determines if this String contains the sequence of characters in the std::string passed in.
bool operator!=(const char *other) const
Comparison operators for the various string types that uses the equals method to determine equality.
String compact() const
If the String instance is holding a reference to a character array that is larger than the string's v...
bool equals(const std::string &other) const
Returns true if this String is equal to the given std::string instance.
String(const char value, int count)
Create a new String instance that contains N copies of the given character value.
static String copyValueOf(const char *data)
Creates a new string containing the characters in the specified character array.
String toLowerCase() const
Converts the characters in this string to lower case.
friend class AbstractStringBuilder
Definition String.h:1190
static String copyValueOf(char *data, int start, int length)
Creates a new string containing the specified characters in the character array.
static String valueOf(short value)
Returns a String that represents the value of the given short value.
int indexOf(const String &string) const
Searches in this string for the first index of the specified string.
int lastIndexOf(const char *string) const
Searches in this string for the last index of the specified C string.
bool equalsIgnoreCase(const std::string &string) const
Compares the specified std::string to this String ignoring the case of the characters and returns tru...
int hashCode() const
Returns a hash code for this String instance, the hash code for an empty String will always be zero.
const char * c_str() const
Returns a const char* value to allow easier coexistence with standard c++ string operations.
static String valueOf(long long value)
Returns a String that represents the value of the given 64bit long value.
String(const std::string &source)
Create a new String object that represents the given STL string.
int lastIndexOf(const std::string &subString, int start) const
Searches in this string for the index of the specified std::string.
bool startsWith(const String &prefix) const
Compares the specified string to this string to determine if the specified string is a prefix.
static String valueOf(double value)
Returns a String that represents the value of the given double value.
String(const char *array, int offset, int length)
Create a new String object that represents the given array of characters, the C string must be null t...
String(const char *array, int size)
Create a new String object that represents the given array of characters.
#define DECAF_API
Definition Config.h:29
Definition ThreadingTypes.h:31
std::ostream & operator<<(std::ostream &out, const Pointer< T, R > &pointer)
Definition Pointer.h:348
bool operator==(const ArrayPointer< T > &left, const U *right)
Definition ArrayPointer.h:379
bool operator>=(const std::string &left, const String &right)
bool operator<=(const std::string &left, const String &right)
bool operator<(const std::string &left, const String &right)
bool operator>(const std::string &left, const String &right)
bool operator!=(const ArrayPointer< T > &left, const U *right)
Definition ArrayPointer.h:391
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25