Samchon Framework for CPP
1.0.0
|
A string class only references characeters, reference only. More...
#include <WeakString.hpp>
Public Member Functions | |
WeakString () | |
Default Constructor does not reference any character. More... | |
WeakString (const char *data, size_t size) | |
Constructor by characters with specified size. More... | |
WeakString (const char *begin, const char *end) | |
Constructor by characters of begin and end. More... | |
WeakString (const char *data) | |
Constructor by characters. More... | |
WeakString (const char &ch) | |
Constructor by a single character. More... | |
WeakString (std::initializer_list< char > &il) | |
Constructor by a initializer list. More... | |
WeakString (const std::string &str) | |
Constructor by string. More... | |
auto | data () const -> const char * |
Get string data; referenced characeters. More... | |
auto | size () const -> size_t |
Returns size of the characters which are being referenced. More... | |
auto | empty () const -> bool |
Tests wheter string is emtpy. More... | |
auto | at (size_t index) const -> const char & |
Get character of string Returns a const reference to the character at the specified position. More... | |
auto | operator[] (size_t index) const -> const char & |
Get character of string Returns a const reference to the character at the specified position. More... | |
auto | find (const WeakString &delim, size_t startIndex=NULL) const -> size_t |
Finds first occurence in string. More... | |
auto | rfind (const WeakString &delim, size_t endIndex=SIZE_MAX) const -> size_t |
Finds last occurence in string. More... | |
auto | finds (const std::vector< std::string > &delims, size_t startIndex=0) const -> IndexPair< WeakString > |
Finds first occurence in string. More... | |
auto | rfinds (const std::vector< std::string > &delims, size_t endIndex=SIZE_MAX) const -> IndexPair< WeakString > |
Finds last occurence in string. More... | |
auto | substr (size_t startIndex, size_t size=SIZE_MAX) const -> WeakString |
Generates a substring. More... | |
auto | substring (size_t startIndex, size_t endIndex=SIZE_MAX) const -> WeakString |
Generates a substring. More... | |
auto | between (const WeakString &start={}, const WeakString &end={}) const -> WeakString |
Generates a substring. More... | |
auto | split (const WeakString &delim) const -> std::vector< WeakString > |
Generates substrings. More... | |
auto | betweens (const WeakString &start={}, const WeakString &end={}) const -> std::vector< WeakString > |
Generates substrings. More... | |
auto | trim (const std::vector< std::string > &delims) const -> WeakString |
Removes all designated characters from the beginning and end of the specified string. More... | |
auto | ltrim (const std::vector< std::string > &delims) const -> WeakString |
Removes all designated characters from the beginning of the specified string. More... | |
auto | rtrim (const std::vector< std::string > &delims) const -> WeakString |
Removes all designated characters from the end of the specified string. More... | |
auto | replace (const WeakString &before, const WeakString &after) const -> std::string |
Replace portion of string once. More... | |
auto | replaceAll (const WeakString &before, const WeakString &after) const -> std::string |
Returns a string specified word is replaced. More... | |
auto | replaceAll (const std::vector< std::pair< std::string, std::string >> &pairs) const -> std::string |
Returns a string specified words are replaced. More... | |
auto | toLowerCase () const -> std::string |
Convert uppercase letters to lowercase. More... | |
auto | yoUpperCase () const -> std::string |
Convert uppercase letters to lowercase. More... | |
auto | str () const -> std::string |
Get the string content. More... | |
Static Public Attributes | |
static const size_t | npos = -1 |
Maximum value for size_t. More... | |
Private Attributes | |
const char * | data_ |
Referenced characters's pointer of begining position. More... | |
size_t | size_ |
(Specified) size of referenced characters More... | |
Static Private Attributes | |
static const std::vector< std::string > | SPACE_ARRAY |
An array containing whitespaces. More... | |
A string class only references characeters, reference only.
WeakSring does not consider any construction, modification and destruction of characters.
Thus, you can have greater advantages than std::string on the side of performance and memory, but of course, you can't modify the characeters at all.
Definition at line 35 of file WeakString.hpp.
|
inline |
Default Constructor does not reference any character.
Constructs an empty string, with zero size
Definition at line 77 of file WeakString.hpp.
Referenced by rfinds(), substr(), and substring().
|
inline |
Constructor by characters with specified size.
Constructs by characters to be referenced with limited size.
Although the original size of data is over the specified size, you can limit referencing size of the characters
data | Target characters to be referenced by string |
size |
Specified limit-size of characters to be referenced.
If the specified size is greater than original size, it will be ignored
Definition at line 102 of file WeakString.hpp.
References data(), and size().
|
inline |
Constructor by characters of begin and end.
Constructs by characters to be referenced with its end position.
Although the original end point of data is over the specified end, you can limit end point of the characters.
begin | Target characters to be referenced by string |
end |
Specified end point of characters to be referenced.
If the specified end point is greater than original end point, it will be ignored.
Definition at line 127 of file WeakString.hpp.
|
inline |
Constructor by characters.
References the null-terminated character sequence pointed by ptr
data | Target characters to be referenced by string |
Definition at line 139 of file WeakString.hpp.
References data().
|
inline |
Constructor by a single character.
References a single character
ch | Target character to be referenced by string |
Definition at line 156 of file WeakString.hpp.
|
inline |
Constructor by a initializer list.
References initializer list of character
il | Target initializer list of characters to be referenced by string |
Definition at line 169 of file WeakString.hpp.
|
inline |
Constructor by string.
References whole chracters of the string
str | Target string to be referenced by string |
Definition at line 186 of file WeakString.hpp.
|
inline |
Get string data; referenced characeters.
Returns a pointer to an array that contains a null-terminated sequence of characters representing the current value of the string object
Definition at line 206 of file WeakString.hpp.
References data_.
Referenced by WeakString().
|
inline |
Returns size of the characters which are being referenced.
Returns the length of the string, in terms of number of referenced characters
Definition at line 217 of file WeakString.hpp.
References size_.
Referenced by between(), find(), replace(), replaceAll(), rfind(), rtrim(), split(), substr(), WeakString(), samchon::library::XML::XML(), and yoUpperCase().
|
inline |
Tests wheter string is emtpy.
Returns wheter characters' size is zero or not.
Of course, string references nothing, then returns false, too.
Definition at line 231 of file WeakString.hpp.
Referenced by between(), betweens(), samchon::library::XML::push_back(), rfind(), rtrim(), and samchon::library::StringUtil::substituteSQL().
|
inline |
Get character of string Returns a const reference to the character at the specified position.
Definition at line 242 of file WeakString.hpp.
Referenced by yoUpperCase().
|
inline |
Get character of string Returns a const reference to the character at the specified position.
Definition at line 253 of file WeakString.hpp.
|
inline |
Finds first occurence in string.
Finds the string after startIndex and returns the position of first occurence of delim.
If delim is not found, returns -1 (npos)
delim | The substring of the string which to find |
startIndex | Specified starting index of find. Default is 0 |
Definition at line 273 of file WeakString.hpp.
References npos, size(), and size_.
Referenced by between(), betweens(), finds(), samchon::library::HTTPLoader::load(), replace(), replaceAll(), rtrim(), samchon::library::Date::set(), split(), samchon::library::StringUtil::substituteSQL(), samchon::library::URLVariables::URLVariables(), samchon::protocol::WebServer::WebServer(), and samchon::library::XML::XML().
|
inline |
Finds last occurence in string.
Finds the string before endIndex and returns the position of last occurence of delim. If delim is not found, returns -1 (npos)
delim | The substring of the string which to find |
endIndex | Specified last index of find. Default is size() - 1 |
Definition at line 297 of file WeakString.hpp.
References empty(), npos, and size().
Referenced by rfinds(), rtrim(), and samchon::library::XML::XML().
|
inline |
Finds first occurence in string.
Finds first occurence position of each delim in the string after startIndex and returns the minimum position of them.
delims | The substrings of target(str) which to find |
startIndex | Specified starting index of find. Default is 0 |
Definition at line 330 of file WeakString.hpp.
References find(), samchon::IndexPair< T >::get_index(), samchon::IndexPair< T >::getValue(), and samchon::library::Math::minimum().
Referenced by samchon::library::StringUtil::finds().
|
inline |
Finds last occurence in string.
Finds last occurence position of each delim in the string before endIndex and returns the maximum position of them.
delims | The substrings of target(str) which to find |
endIndex | Specified starting index of find. Default is size() - 1 |
Definition at line 366 of file WeakString.hpp.
References samchon::IndexPair< T >::get_index(), samchon::IndexPair< T >::getValue(), samchon::library::Math::maximum(), rfind(), and WeakString().
Referenced by samchon::library::StringUtil::rfinds().
|
inline |
Generates a substring.
Extracts a substring consisting of the character specified by startIndex and all characters up to endIndex - 1.
startIndex |
Index of the first character.
If startIndex is greater than endIndex, those will be swapped.
size |
Index of the last character - 1.
If not specified, then string::size() will be used instead.
Definition at line 419 of file WeakString.hpp.
References size(), and WeakString().
Referenced by between(), samchon::library::HTTPLoader::load(), replace(), replaceAll(), samchon::library::Date::set(), samchon::library::URLVariables::URLVariables(), and samchon::library::XML::XML().
|
inline |
Generates a substring.
Extracts a substring consisting of the characters starts from startIndex and with a size specified size.
startIndex |
Index of the first character.
If startIndex is greater than endIndex, those will be swapped.
endIndex |
Number of characters to include in substring.
If the specified size is greater than last index of characeters, it will be shrinked.
Definition at line 443 of file WeakString.hpp.
References size_, and WeakString().
Referenced by between(), betweens(), replaceAll(), split(), samchon::library::StringUtil::substring(), and samchon::library::XML::XML().
|
inline |
Generates a substring.
Extracts a substring consisting of the characters from specified start to end.
It's same with substring( ? = (str.find(start) + start.size()), find(end, ?) )
start | A string for separating substring at the front |
end | A string for separating substring at the end |
Definition at line 475 of file WeakString.hpp.
References empty(), find(), size(), substr(), and substring().
Referenced by samchon::library::StringUtil::between(), samchon::protocol::WebServerConnector::connect(), samchon::library::HTTPLoader::load(), samchon::library::Date::set(), samchon::protocol::WebServer::WebServer(), and samchon::library::XML::XML().
|
inline |
Generates substrings.
Splits a string in to an array of substrings dividing by the specified delimiter
delim | The pattern which specifies where to split the string |
Definition at line 502 of file WeakString.hpp.
References find(), size(), and substring().
Referenced by betweens(), samchon::library::HTTPLoader::load(), samchon::library::Date::set(), samchon::library::StringUtil::split(), and samchon::library::URLVariables::URLVariables().
|
inline |
Generates substrings.
Splits a string into an array of substrings dividing by delimeters of start and end.
It's the array of substrings adjusted the between.
start |
A string for separating substring at the front.
If omitted, it's same with split(end) not having last item.
end |
A string for separating substring at the end.
If omitted, it's same with split(start) not having first item.
Definition at line 548 of file WeakString.hpp.
References empty(), find(), npos, split(), and substring().
Referenced by samchon::library::StringUtil::betweens().
|
inline |
Removes all designated characters from the beginning and end of the specified string.
delims | Designated character(s) |
Definition at line 634 of file WeakString.hpp.
|
inline |
Removes all designated characters from the beginning of the specified string.
delims | Designated character(s) |
Definition at line 645 of file WeakString.hpp.
|
inline |
Removes all designated characters from the end of the specified string.
delims | Designated character(s) |
Definition at line 660 of file WeakString.hpp.
References data_, empty(), find(), samchon::IndexPair< T >::get_index(), samchon::IndexPair< T >::getValue(), samchon::library::Math::maximum(), samchon::library::Math::minimum(), rfind(), size(), size_, and str().
|
inline |
Replace portion of string once.
before | A specific word you want to be replaced |
after | A specific word you want to replace |
Definition at line 740 of file WeakString.hpp.
References find(), size(), str(), and substr().
|
inline |
Returns a string specified word is replaced.
before | A specific word you want to be replaced |
after | A specific word you want to replace |
Definition at line 763 of file WeakString.hpp.
Referenced by samchon::library::XML::clearProperties(), samchon::library::StringUtil::replaceAll(), replaceAll(), and samchon::library::StringUtil::substituteSQL().
|
inline |
Returns a string specified words are replaced.
str | Target string to replace |
pairs | A specific word's pairs you want to replace and to be replaced |
Definition at line 775 of file WeakString.hpp.
References find(), replaceAll(), size(), str(), substr(), and substring().
|
inline |
Convert uppercase letters to lowercase.
Returns a string that all uppercase characters are converted to lowercase.
wstr | Target string to convert uppercase to lowercase |
Definition at line 851 of file WeakString.hpp.
References str().
Referenced by samchon::library::StringUtil::toLowerCase().
|
inline |
Convert uppercase letters to lowercase.
Returns a string all lowercase characters are converted to uppercase.
str | Target string to convert lowercase to uppercase |
Definition at line 869 of file WeakString.hpp.
References at(), data_, size(), size_, and str().
Referenced by samchon::library::StringUtil::yoUpperCase().
|
inline |
Get the string content.
Returns a string object with a copy of the current contents in the WeakString.
Definition at line 926 of file WeakString.hpp.
Referenced by samchon::protocol::WebServerConnector::connect(), samchon::protocol::InvokeParameter::InvokeParameter(), samchon::library::HTTPLoader::load(), replace(), replaceAll(), rtrim(), samchon::library::XML::setProperty(), samchon::library::XML::setValue(), samchon::library::StringUtil::substituteSQL(), toLowerCase(), and yoUpperCase().
|
staticprivate |
An array containing whitespaces.
Definition at line 41 of file WeakString.hpp.
|
static |
Maximum value for size_t.
npos is a static member constant value with the greatest possible value for an element of type size_t.
This value, when used as the value for a len (or sublen) parameter in string's member functions, means "until the end of the string". As a return value, it is usually used to indicate no matches.
This constant is defined with a value of -1, which because size_t is an unsigned integral type, it is the largest possible representable value for this type.
Definition at line 56 of file WeakString.hpp.
Referenced by betweens(), find(), and rfind().
|
private |
Referenced characters's pointer of begining position.
Definition at line 62 of file WeakString.hpp.
Referenced by data(), rtrim(), and yoUpperCase().
|
private |
(Specified) size of referenced characters
Definition at line 67 of file WeakString.hpp.
Referenced by find(), rtrim(), size(), substring(), and yoUpperCase().