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>
26#include <decaf/lang/Pointer.h>
27
28namespace decaf {
29namespace lang {
30
31 class StringBuffer;
32
52 public Appendable {
53 public:
54
59
69
78 StringBuilder(const String& source);
79
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
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
246
262 StringBuilder& append(const CharSequence* value, int offset, int length);
263
273
283
300 StringBuilder& deleteRange(int start, int end);
301
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
611
612 };
613
614}}
615
616#endif /* _DECAF_LANG_STRINGBUILDER_H_ */
void doInsert(int index, char value)
Inserts a single char value at the given index.
virtual int capacity() const
Returns the current capacity.
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 is a variable size contiguous indexable array of characters.
Definition StringBuffer.h:58
StringBuilder & append(const StringBuffer &value)
Appends the contents of the StringBuffer into this buffer.
StringBuilder & insert(int index, int value)
Inserts the given int into the character buffer at the given index.
StringBuilder & insert(int index, float value)
Inserts the given float into the character buffer at the given index.
StringBuilder & insert(int index, double value)
Inserts the given double into the character buffer at the given index.
StringBuilder & insert(int index, long long value)
Inserts the given long long into the character buffer at the given index.
StringBuilder & insert(int index, short value)
Inserts the given short into the character buffer at the given index.
StringBuilder & 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...
StringBuilder & append(float value)
Appends the given float value into the internal char buffer.
StringBuilder & append(int value)
Appends the given int value into the internal char buffer.
StringBuilder & deleteRange(int start, int end)
Removes the characters in a substring of this buffer.
StringBuilder & insert(int index, const Pointer< TYPE > pointer)
Inserts the string representation of the given object pointer.
Definition StringBuilder.h:350
StringBuilder & append(bool value)
Appends the string representation of the given boolean value.
StringBuilder & append(char value)
Appends the given char value into the internal char buffer.
StringBuilder & 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...
StringBuilder & insert(int index, char value)
Inserts the given char into the character buffer at the given index.
StringBuilder(const CharSequence *source)
Constructs a string builder initialized to the contents of the specified string.
StringBuilder & insert(int index, const char *value)
Inserts the given C string into the character buffer at the given index.
StringBuilder & append(const char *value, int offset, int length)
Appends the given subsequence of the given C string into this buffer.
StringBuilder(int capacity)
Creates an empty StringBuilder instance with the given capacity.
StringBuilder & append(double value)
Appends the given double value into the internal char buffer.
StringBuilder & replace(int start, int end, const String &value)
Replace some number of characters in this Buffer with the value given.
StringBuilder & insert(int index, const POINTER *pointer)
Inserts the string representation of the given object pointer.
Definition StringBuilder.h:327
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
StringBuilder(const String &source)
Constructs a string builder initialized to the contents of the specified string.
StringBuilder & reverse()
Reverses the order of characters in this builder.
StringBuilder & append(const CharSequence *value)
Appends the contents of the CharSequence into this buffer, if the CharSequence pointer is NULL then t...
StringBuilder & 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...
StringBuilder & insert(int index, const std::string &value)
Inserts the given std::string into the character buffer at the given index.
StringBuilder & insert(int index, const CharSequence *value)
Inserts the given CharSequence into the character buffer at the given index starting from the given o...
StringBuilder & append(long long value)
Appends the given long long value into the internal char buffer.
StringBuilder & append(short value)
Appends the given short value into the internal char buffer.
StringBuilder & deleteCharAt(int index)
Deletes the char at the specified position in this buffer, length decreases by one.
StringBuilder & append(const String &value)
Appends the contents of the String into this buffer.
StringBuilder()
Creates an empty StringBuilder instance with a capacity of 16.
StringBuilder & insert(int index, bool value)
Inserts the given boolean into the character buffer at the given index.
StringBuilder & append(const char *value)
Appends the contents of the given C string into this buffer.
virtual int length() const
Returns the current length of the String that has been built.
StringBuilder & insert(int index, const String &value)
Inserts the given String into the character buffer at the given index.
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