activemq-cpp-3.9.5
StringBuffer.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_STRINGBUFFER_H_
19 #define _DECAF_LANG_STRINGBUFFER_H_
20 
21 #include <decaf/util/Config.h>
23 #include <decaf/lang/String.h>
25 #include <decaf/lang/Appendable.h>
26 #include <decaf/lang/Pointer.h>
28 
29 namespace decaf {
30 namespace lang {
31 
32  class StringBuilder;
33 
58  public Appendable {
59  public:
60 
64  StringBuffer();
65 
74  StringBuffer(int capacity);
75 
84  StringBuffer(const String& source);
85 
96  StringBuffer(const CharSequence* source);
97 
98  virtual ~StringBuffer();
99 
100  public:
101 
102  virtual int capacity() const;
103 
104  virtual char charAt(int index) const;
105 
106  virtual void ensureCapacity(int minCapacity);
107 
108  virtual void getChars(int start, int end, char* dst, int dstSize, int dstStart) const;
109 
110  virtual int indexOf(const String& value) const;
111 
112  virtual int indexOf(const String& value, int start) const;
113 
114  virtual int lastIndexOf(const String& value) const;
115 
116  virtual int lastIndexOf(const String& value, int start) const;
117 
118  virtual int length() const;
119 
120  virtual void setLength(int length);
121 
122  virtual void setCharAt(int index, char value);
123 
124  virtual String substring(int start) const;
125 
126  virtual String substring(int start, int end) const;
127 
128  virtual CharSequence* subSequence(int start, int end) const;
129 
130  virtual String toString() const;
131 
132  virtual void trimToSize();
133 
134  public:
135 
145  template<typename POINTER>
146  StringBuffer& append(const POINTER* pointer) {
147 
148  if (pointer == NULL) {
149  doAppendNull();
150  } else {
151  doAppend(pointer->toString());
152  }
153 
154  return *this;
155  }
156 
166  template<typename TYPE>
168 
169  if (pointer == NULL) {
170  doAppendNull();
171  } else {
172  doAppend(pointer->toString());
173  }
174 
175  return *this;
176  }
177 
186  StringBuffer& append(bool value);
187 
196  StringBuffer& append(char value);
197 
206  StringBuffer& append(short value);
207 
216  StringBuffer& append(int value);
217 
226  StringBuffer& append(long long value);
227 
236  StringBuffer& append(float value);
237 
246  StringBuffer& append(double value);
247 
256  StringBuffer& append(const char* value);
257 
272  StringBuffer& append(const char* value, int offset, int length);
273 
283  StringBuffer& append(const CharSequence* value);
284 
300  StringBuffer& append(const CharSequence* value, int offset, int length);
301 
310  StringBuffer& append(const String& value);
311 
320  StringBuffer& append(const StringBuilder& value);
321 
338  StringBuffer& deleteRange(int start, int end);
339 
351  StringBuffer& deleteCharAt(int index);
352 
364  template<typename POINTER>
365  StringBuffer& insert(int index, const POINTER* pointer) {
366 
367  if (pointer == NULL) {
368  doInsert(index, "null");
369  } else {
370  doInsert(index, pointer->toString());
371  }
372 
373  return *this;
374  }
375 
387  template<typename TYPE>
388  StringBuffer& insert(int index, const Pointer<TYPE> pointer) {
389 
390  if (pointer == NULL) {
391  doInsert(index, "null");
392  } else {
393  doInsert(index, pointer->toString());
394  }
395 
396  return *this;
397  }
398 
413  StringBuffer& insert(int index, char value);
414 
429  StringBuffer& insert(int index, bool value);
430 
445  StringBuffer& insert(int index, short value);
446 
461  StringBuffer& insert(int index, int value);
462 
477  StringBuffer& insert(int index, long long value);
478 
493  StringBuffer& insert(int index, float value);
494 
509  StringBuffer& insert(int index, double value);
510 
525  StringBuffer& insert(int index, const char* value);
526 
541  StringBuffer& insert(int index, const String& value);
542 
557  StringBuffer& insert(int index, const std::string& value);
558 
580  StringBuffer& insert(int index, const char* value, int offset, int length);
581 
598  StringBuffer& insert(int index, const CharSequence* value);
599 
621  StringBuffer& insert(int index, const CharSequence* value, int offset, int length);
622 
641  StringBuffer& replace(int start, int end, const String& value);
642 
648  StringBuffer& reverse();
649 
650  };
651 
652 }}
653 
654 #endif /* _DECAF_LANG_STRINGBUFFER_H_ */
A CharSequence is a readable sequence of char values.
Definition: CharSequence.h:36
#define NULL
Definition: Config.h:33
StringBuffer & insert(int index, const Pointer< TYPE > pointer)
Inserts the string representation of the given object pointer.
Definition: StringBuffer.h:388
An object to which char sequences and values can be appended.
Definition: Appendable.h:42
StringBuffer & insert(int index, const POINTER *pointer)
Inserts the string representation of the given object pointer.
Definition: StringBuffer.h:365
A modifiable sequence of characters for use in creating and modifying Strings.
Definition: AbstractStringBuilder.h:40
An immutable sequence of characters.
Definition: String.h:57
#define DECAF_API
Definition: Config.h:29
StringBuffer is a variable size contiguous indexable array of characters.
Definition: StringBuffer.h:57
A modifiable sequence of characters for use in creating and modifying Strings.
Definition: StringBuilder.h:51
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
StringBuffer & append(const POINTER *pointer)
Appends the string representation of the given object pointer.
Definition: StringBuffer.h:146
StringBuffer & append(const Pointer< TYPE > pointer)
Appends the string representation of the given object pointer.
Definition: StringBuffer.h:167