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 
24 #include <decaf/lang/Comparable.h>
26 
27 #include <string>
28 #include <ostream>
29 
30 namespace decaf {
31 namespace lang {
32 
33  class Contents;
34  class AbstractStringBuilder;
35 
57  class DECAF_API String: public CharSequence {
58  private:
59 
60  mutable Contents* contents;
61 
62  public:
63 
69  String();
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 
324  String compact() const;
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 
1024  String toLowerCase() const;
1025 
1033  String toUpperCase() const;
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 CharSequence is a readable sequence of char values.
Definition: CharSequence.h:36
bool operator>(const std::string &left, const String &right)
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
An immutable sequence of characters.
Definition: String.h:57
#define DECAF_API
Definition: Config.h:29
bool operator<=(const std::string &left, const String &right)
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:391
bool operator>=(const std::string &left, const String &right)
bool operator==(const ArrayPointer< T > &left, const U *right)
Definition: ArrayPointer.h:379
bool operator<(const std::string &left, const String &right)