The String class represents an immutable sequence of chars.
More...
#include <src/main/decaf/lang/String.h>
The String class represents an immutable sequence of chars.
- Since
- 1.0
◆ String() [1/5]
| decaf::lang::String::String |
( |
| ) |
|
Creates a new empty String object.
◆ String() [2/5]
Create a new String object that represents the given STL string.
- Parameters
-
| source | The string to copy into this new String object. |
◆ String() [3/5]
| decaf::lang::String::String |
( |
const std::string & |
source | ) |
|
Create a new String object that represents the given STL string.
- Parameters
-
| source | The string to copy into this new String object. |
◆ String() [4/5]
| decaf::lang::String::String |
( |
const char * |
array, |
|
|
int |
size |
|
) |
| |
Create a new String object that represents the given array of characters.
The method takes the size of the array as a parameter to allow for strings that are not NULL terminated, the caller can pass strlen(array) in the case where the array is properly NULL terminated.
- Parameters
-
| array | The character buffer to copy into this new String object. |
| size | The size of the string buffer given, in case the string is not NULL terminated. |
- Exceptions
-
| NullPointerException | if the character array parameter is NULL. |
| IndexOutOfBoundsException | if the size parameter is negative. |
◆ String() [5/5]
| decaf::lang::String::String |
( |
const char * |
array, |
|
|
int |
size, |
|
|
int |
offset, |
|
|
int |
length |
|
) |
| |
Create a new String object that represents the given array of characters.
The method takes the size of the array as a parameter to allow for strings that are not NULL terminated, the caller can pass strlen(array) in the case where the array is properly NULL terminated.
- Parameters
-
| array | The character buffer to copy into this new String object. |
| size | The size of the string buffer given, in case the string is not NULL terminated. |
| offset | The position to start copying from in the given buffer. |
| length | The number of bytes to copy from the given buffer starting from the offset. |
- Exceptions
-
| NullPointerException | if the character array parameter is NULL. |
| IndexOutOfBoundsException | if the size, offset or length parameter is negative or if the length to copy is greater than the span of size - offset. |
◆ ~String()
| virtual decaf::lang::String::~String |
( |
| ) |
|
|
virtual |
◆ charAt()
| virtual char decaf::lang::String::charAt |
( |
int |
index | ) |
const |
|
virtual |
Returns the Char at the specified index so long as the index is not greater than the length of the sequence.
- Parameters
-
| index | The position to return the char at. |
- Returns
- the char at the given position.
- Exceptions
-
| IndexOutOfBoundsException | if index is > than length() or negative |
Implements decaf::lang::CharSequence.
◆ isEmpty()
| bool decaf::lang::String::isEmpty |
( |
| ) |
const |
- Returns
- true if the length of this String is zero.
◆ length()
| virtual int decaf::lang::String::length |
( |
| ) |
const |
|
virtual |
◆ operator=() [1/2]
◆ operator=() [2/2]
| String& decaf::lang::String::operator= |
( |
const std::string & |
| ) |
|
◆ subSequence()
| virtual CharSequence* decaf::lang::String::subSequence |
( |
int |
start, |
|
|
int |
end |
|
) |
| const |
|
virtual |
Returns a new CharSequence that is a subsequence of this sequence.The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.
- Parameters
-
| start | The start index, inclusive. |
| end | The end index, exclusive. |
- Returns
- a new CharSequence
- Exceptions
-
| IndexOutOfBoundsException | if start or end > length() or start or end are negative. |
Implements decaf::lang::CharSequence.
◆ toString()
| virtual std::string decaf::lang::String::toString |
( |
| ) |
const |
|
virtual |
◆ valueOf() [1/7]
| static String decaf::lang::String::valueOf |
( |
bool |
value | ) |
|
|
static |
Returns a String that represents the value of the given boolean value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- "true" if the boolean is true, "false" otherwise.
◆ valueOf() [2/7]
| static String decaf::lang::String::valueOf |
( |
char |
value | ) |
|
|
static |
Returns a String that represents the value of the given char value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the single character value given.
◆ valueOf() [3/7]
| static String decaf::lang::String::valueOf |
( |
float |
value | ) |
|
|
static |
Returns a String that represents the value of the given float value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the string representation of the float value given.
◆ valueOf() [4/7]
| static String decaf::lang::String::valueOf |
( |
double |
value | ) |
|
|
static |
Returns a String that represents the value of the given double value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the string representation of the double value given.
◆ valueOf() [5/7]
| static String decaf::lang::String::valueOf |
( |
short |
value | ) |
|
|
static |
Returns a String that represents the value of the given short value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the string representation of the short value given.
◆ valueOf() [6/7]
| static String decaf::lang::String::valueOf |
( |
int |
value | ) |
|
|
static |
Returns a String that represents the value of the given integer value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the string representation of the integer value given.
◆ valueOf() [7/7]
| static String decaf::lang::String::valueOf |
( |
long long |
value | ) |
|
|
static |
Returns a String that represents the value of the given 64bit long value.
- Parameters
-
| value | The value whose string representation is to be returned. |
- Returns
- a String that contains the string representation of the 64 bit long value given.
The documentation for this class was generated from the following file: