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>
26#include <decaf/lang/Pointer.h>
28
29namespace decaf {
30namespace lang {
31
32 class StringBuilder;
33
58 public Appendable {
59 public:
60
65
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
284
300 StringBuffer& append(const CharSequence* value, int offset, int length);
301
310 StringBuffer& append(const String& value);
311
321
338 StringBuffer& deleteRange(int start, int end);
339
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
649
650 };
651
652}}
653
654#endif /* _DECAF_LANG_STRINGBUFFER_H_ */
void doInsert(int index, char value)
Inserts a single char value at the given index.
void doAppend(const char value)
Appends the given char to this buffer.
void doAppendNull()
Appends the string "null" to the current character buffer.
An object to which char sequences and values can be appended.
Definition Appendable.h:42
A CharSequence is a readable sequence of char values.
Definition CharSequence.h:36
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 & insert(int index, const std::string &value)
Inserts the given std::string into the character buffer at the given index.
virtual int capacity() const
Returns the current capacity.
StringBuffer(const CharSequence *source)
Constructs a string buffer initialized to the contents of the specified string.
StringBuffer & append(short value)
Appends the given short value into the internal char buffer.
StringBuffer & deleteRange(int start, int end)
Removes the characters in a substring of this buffer.
virtual String substring(int start) const
Returns a new String that contains a subset of the characters currently contained in this character b...
virtual String toString() const
Returns a String that represents the contents of this buffer.
virtual int indexOf(const String &value, int start) const
Search for the index within this string of the first occurrence of the specified substring starting a...
StringBuffer & append(float value)
Appends the given float value into the internal char buffer.
virtual void setLength(int length)
Sets the length of this character buffer.
StringBuffer & append(int value)
Appends the given int value into the internal char buffer.
StringBuffer & append(long long value)
Appends the given long long value into the internal char buffer.
StringBuffer & insert(int index, const String &value)
Inserts the given String into the character buffer at the given index.
virtual void ensureCapacity(int minCapacity)
Ensures that the capacity is at least equal to the specified min value.
StringBuffer & insert(int index, float value)
Inserts the given float into the character buffer at the given index.
StringBuffer & insert(int index, int value)
Inserts the given int into the character buffer at the given index.
virtual void setCharAt(int index, char value)
Sets the character at the specified index to the new char value given.
StringBuffer & append(const CharSequence *value)
Appends the contents of the CharSequence into this buffer, if the CharSequence pointer is NULL then t...
StringBuffer & reverse()
Reverses the order of characters in this builder.
StringBuffer & append(const char *value)
Appends the contents of the given C string into this buffer.
StringBuffer & insert(int index, const Pointer< TYPE > pointer)
Inserts the string representation of the given object pointer.
Definition StringBuffer.h:388
virtual void getChars(int start, int end, char *dst, int dstSize, int dstStart) const
Copies characters from this character buffer into the given character array.
StringBuffer & insert(int index, bool value)
Inserts the given boolean into the character buffer at the given index.
StringBuffer()
Creates an empty StringBuffer instance with a capacity of 16.
StringBuffer & append(bool value)
Appends the string representation of the given boolean value.
virtual String substring(int start, int end) const
Returns a new String that contains a subset of the characters currently contained in this character b...
StringBuffer & insert(int index, char value)
Inserts the given char into the character buffer at the given index.
StringBuffer & append(const CharSequence *value, int offset, int length)
Appends the given CharSequence to this buffer starting at the given offset and ending after the lengt...
StringBuffer & append(char value)
Appends the given char value into the internal char buffer.
virtual int lastIndexOf(const String &value) const
Search for the last index within this string where the given substring can be found.
virtual void trimToSize()
Attempts to reduce storage used for the character sequence.
StringBuffer & append(double value)
Appends the given double value into the internal char buffer.
StringBuffer & insert(int index, const POINTER *pointer)
Inserts the string representation of the given object pointer.
Definition StringBuffer.h:365
StringBuffer & insert(int index, const char *value, int offset, int length)
Inserts the given C string into the character buffer at the given index starting from the given offse...
StringBuffer & insert(int index, long long value)
Inserts the given long long into the character buffer at the given index.
virtual CharSequence * subSequence(int start, int end) const
Creates and returns a new CharSequence object that is a subset of the characters contained in this ch...
StringBuffer(int capacity)
Creates an empty StringBuffer instance with the given capacity.
StringBuffer & insert(int index, const CharSequence *value, int offset, int length)
Inserts the given CharSequence into the character buffer at the given index starting from the given o...
StringBuffer & replace(int start, int end, const String &value)
Replace some number of characters in this Buffer with the value given.
StringBuffer & append(const StringBuilder &value)
Appends the contents of the StringBuffer into this buffer.
virtual char charAt(int index) const
Returns the character at the given index.
virtual int indexOf(const String &value) const
Search for the index within this string of the first occurrence of the specified substring.
StringBuffer & deleteCharAt(int index)
Deletes the char at the specified position in this buffer, length decreases by one.
StringBuffer & insert(int index, const CharSequence *value)
Inserts the given CharSequence into the character buffer at the given index starting from the given o...
StringBuffer & append(const char *value, int offset, int length)
Appends the given subsequence of the given C string into this buffer.
StringBuffer & append(const Pointer< TYPE > pointer)
Appends the string representation of the given object pointer.
Definition StringBuffer.h:167
StringBuffer & insert(int index, short value)
Inserts the given short into the character buffer at the given index.
StringBuffer & append(const String &value)
Appends the contents of the String into this buffer.
virtual int lastIndexOf(const String &value, int start) const
Search for the last index within this string where the given substring can be found starting from the...
StringBuffer & insert(int index, const char *value)
Inserts the given C string into the character buffer at the given index.
StringBuffer(const String &source)
Constructs a string buffer initialized to the contents of the specified string.
StringBuffer & append(const POINTER *pointer)
Appends the string representation of the given object pointer.
Definition StringBuffer.h:146
virtual int length() const
Returns the current length of the String that has been built.
StringBuffer & insert(int index, double value)
Inserts the given double into the character buffer at the given index.
A modifiable sequence of characters for use in creating and modifying Strings.
Definition StringBuilder.h:52
An immutable sequence of characters.
Definition String.h:57
#define NULL
Definition Config.h:33
#define DECAF_API
Definition Config.h:29
Definition ThreadingTypes.h:31
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25