/// \brief Basic constructor. Constructs an empty string object, with the length of zero characters.
String();
/////
/// \brief Constructor with char pointer.
/// Constructor with char pointer.
/// @param prefix_cut_off says length of the prefix that is going to be omitted and
/// @param sufix_cut_off says the same about suffix.
/// Copies the null-terminated character sequence (C-string) pointed by \e c.
/// Constructs a string initialized with the 8-bit string \e c, excluding the given number of \e prefix_cut_off and \e sufix_cut_off characters.
/// @param prefix_cut_off determines the length of the prefix that is going to be omitted from the string \e c
/// @param sufix_cut_off determines the length of the sufix that is going to be omitted from the string \e c
String(constchar*c,
intprefix_cut_off=0,
intsufix_cut_off=0);
/// Returns type of string - String.
staticStringgetType();
//! Copy constructor
/////
/// \brief Copy constructor. Constructs a copy of the string \e str.
String(constString&str);
//! Convert anything to a string
/// \brief Converts anything to a string.
template<typenameT>
explicit
String(Tvalue)
@@ -58,106 +61,130 @@ class String
setString(convertToString(value).getString());
}
//! Destructor
/// \brief Destructor.
~String();
//! Return length of the string
/// Returns the number of characters in given string. Equivalent to \c getSize().
intgetLength()const;
/// Returns the number of characters in given string.
intgetSize()const;
//! Return currently allocated size
/// Returns size of allocated storage for given string.
intgetAllocatedSize()const;
//! Reserve space for given number of characters
/// Reserves space for given number of characters (\e size).
/// Requests to allocate storage for given \e size (number of characters).
voidsetSize(intsize);
//! Set string from given char pointer
/*! @param prefix_cut_off says length of the prefix that is going to be omitted and
@param sufix_cut_off says the same about sufix.
*/
/////
/// Sets string from given char pointer \e c.
/// @param prefix_cut_off determines the length of the prefix that is going to be omitted from the string \e c
/// @param sufix_cut_off determines the length of the sufix that is going to be omitted from the string \e c
voidsetString(constchar*c,
intprefix_cut_off=0,
intsufix_cut_off=0);
//! Return pointer to data
/// Returns pointer to data. It returns the content of the given string.
constchar*getString()const;
//! Return pointer to data
/// Returns pointer to data.
char*getString();
//! Operator for accesing particular chars of the string
/// \brief Operator for accesing particular chars of the string. This function overloads operator[](). It returns a reference to the character at position \e i in given string.
constchar&operator[](inti)const;
//! Operator for accesing particular chars of the string
/// \brief Operator for accesing particular chars of the string. It returns the character at the position \e i in given string as a modifiable reference.
char&operator[](inti);
/****
* Operators for C strings
*/
/////
/// \brief Operators for C strings.
/// This function overloads operator=(). It assigns \e str to this string, replacing its current contents.
String&operator=(constchar*str);
/// This function overloads operator+=(). It appends the string \e str to this string.
String&operator+=(constchar*str);
/// This function concatenates strings and returns a newly constructed string object.
Stringoperator+(constchar*str)const;
/// This function overloads operator==().
booloperator==(constchar*str)const;
/// This function overloads operator!=().
booloperator!=(constchar*str)const;
/****
* Operators for Strings
*/
/////
/// \brief Operators for Strings.
/// This function assigns \e str to this string and returns a reference to this string.
String&operator=(constString&str);
/// This function appends the string \e str onto the end of this string and returns a reference to this string.
String&operator+=(constString&str);
/// This function concatenates strings and returns a newly constructed string object.
Stringoperator+(constString&str)const;
/// This function overloads operator==(). It returns \c true if this string is equal to \e str, otherwise returns \c false.
booloperator==(constString&str)const;
/// This function overloads operator!=(). It returns \c true if this string is not equal to \e str, otherwise returns \c false.
booloperator!=(constString&str)const;
/****
* Operators for single characters
*/
/////
/// \brief Operators for single characters.
/// This function overloads operator=(). It assigns character /e str to this string.
String&operator=(charstr);
/// This function overloads operator+=(). It appends character /e str to this string.
String&operator+=(charstr);
// This function concatenates strings and returns a newly constructed string object.
Stringoperator+(charstr)const;
// This function concatenates strings and returns a newly constructed string object.
booloperator==(charstr)const;
/// This function overloads operator!=().
booloperator!=(charstr)const;
//! Cast to bool operator
/// \brief Cast to bool operator.
operatorbool()const;
//! Cast to bool with negation operator
/// \brief Cast to bool with negation operator.
booloperator!()const;
/////
/// \brief Replaces portion of string.
///It replaces section \e pattern from this string with new piece of string \e replaceWith.
///If parameter \e count is defined, the function makes replacement several times, every time when it finds the same pattern in this string.
Stringreplace(constString&pattern,
constString&replaceWith,
intcount=0)const;
/// \brief Trims/strips given string. It removes all spaces from string except for single spaces between words.
Stringstrip(charstrip=' ')const;
//! Split the string into list of strings w.r.t. given separator.
/// \brief Splits string into list of strings with respect to given \e separator.
/// It splits the string into list of substrings wherever \e separator occurs, and returs list of those strings.
/// When \e separator does not appear anywhere in the given string, this function returns a single-element list containing given sting.
/// @param separator Character, which separates substrings in given string. Empty character can not be used.