activemq-cpp-3.9.5
StringBuilder.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_STRINGBUILDER_H_
19 #define _DECAF_LANG_STRINGBUILDER_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>
27 
28 namespace decaf {
29 namespace lang {
30 
31  class StringBuffer;
32 
52  public Appendable {
53  public:
54 
58  StringBuilder();
59 
68  StringBuilder(int capacity);
69 
78  StringBuilder(const String& source);
79 
90  StringBuilder(const CharSequence* source);
91 
92  virtual ~StringBuilder();
93 
94  public:
95 
96  virtual int length() const;
97 
107  template<typename POINTER>
108  StringBuilder& append(const POINTER* pointer) {
109 
110  if (pointer == NULL) {
111  doAppendNull();
112  } else {
113  doAppend(pointer->toString());
114  }
115 
116  return *this;
117  }
118 
128  template<typename TYPE>
130 
131  if (pointer == NULL) {
132  doAppendNull();
133  } else {
134  doAppend(pointer->toString());
135  }
136 
137  return *this;
138  }
139 
148  StringBuilder& append(bool value);
149 
158  StringBuilder& append(char value);
159 
168  StringBuilder& append(short value);
169 
178  StringBuilder& append(int value);
179 
188  StringBuilder& append(long long value);
189 
198  StringBuilder& append(float value);
199 
208  StringBuilder& append(double value);
209 
218  StringBuilder& append(const char* value);
219 
234  StringBuilder& append(const char* value, int offset, int length);
235 
245  StringBuilder& append(const CharSequence* value);
246 
262  StringBuilder& append(const CharSequence* value, int offset, int length);
263 
272  StringBuilder& append(const String& value);
273 
282  StringBuilder& append(const StringBuffer& value);
283 
300  StringBuilder& deleteRange(int start, int end);
301 
313  StringBuilder& deleteCharAt(int index);
314 
326  template<typename POINTER>
327  StringBuilder& insert(int index, const POINTER* pointer) {
328 
329  if (pointer == NULL) {
330  doInsert(index, "null");
331  } else {
332  doInsert(index, pointer->toString());
333  }
334 
335  return *this;
336  }
337 
349  template<typename TYPE>
350  StringBuilder& insert(int index, const Pointer<TYPE> pointer) {
351 
352  if (pointer == NULL) {
353  doInsert(index, "null");
354  } else {
355  doInsert(index, pointer->toString());
356  }
357 
358  return *this;
359  }
360 
375  StringBuilder& insert(int index, char value);
376 
391  StringBuilder& insert(int index, bool value);
392 
407  StringBuilder& insert(int index, short value);
408 
423  StringBuilder& insert(int index, int value);
424 
439  StringBuilder& insert(int index, long long value);
440 
455  StringBuilder& insert(int index, float value);
456 
471  StringBuilder& insert(int index, double value);
472 
487  StringBuilder& insert(int index, const char* value);
488 
503  StringBuilder& insert(int index, const String& value);
504 
519  StringBuilder& insert(int index, const std::string& value);
520 
542  StringBuilder& insert(int index, const char* value, int offset, int length);
543 
560  StringBuilder& insert(int index, const CharSequence* value);
561 
583  StringBuilder& insert(int index, const CharSequence* value, int offset, int length);
584 
603  StringBuilder& replace(int start, int end, const String& value);
604 
610  StringBuilder& reverse();
611 
612  };
613 
614 }}
615 
616 #endif /* _DECAF_LANG_STRINGBUILDER_H_ */
A CharSequence is a readable sequence of char values.
Definition: CharSequence.h:36
#define NULL
Definition: Config.h:33
StringBuilder & insert(int index, const POINTER *pointer)
Inserts the string representation of the given object pointer.
Definition: StringBuilder.h:327
An object to which char sequences and values can be appended.
Definition: Appendable.h:42
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
StringBuilder & append(const Pointer< TYPE > pointer)
Appends the string representation of the given object pointer.
Definition: StringBuilder.h:129
StringBuilder & append(const POINTER *pointer)
Appends the string representation of the given object pointer.
Definition: StringBuilder.h:108
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
StringBuilder & insert(int index, const Pointer< TYPE > pointer)
Inserts the string representation of the given object pointer.
Definition: StringBuilder.h:350