Class SBCContainerString#
ClassList > SBCContainerString
This class describes a string. More...
#include <SBCContainerString.hpp>
Public Functions#
| Type | Name |
|---|---|
| SBCContainerString (std::string s) Constructs a string from a std::string s . |
|
| SBCContainerString (const char * s) Constructs a string from a char array s . |
|
| SBCContainerString (const SBCContainerString & s) Copy constructor. |
|
| SBCContainerString (SBCContainerString && s) noexcept Move constructor. |
|
| SBCContainerString & | operator= (const SBCContainerString & s) Copy assignment operator. |
| SBCContainerString & | operator= (SBCContainerString && s) noexcept Move assignment operator. |
| void | print (std::ostream & os) const Prints some debugging information. |
| void | print () const Prints some debugging information. |
| void | removeWhitespaces () Removes all whitespace characters (spaces, tabs, newlines, etc.) from the string. |
| virtual | ~SBCContainerString () Destructs the string. |
Public Static Functions#
| Type | Name |
|---|---|
| std::string | removeWhitespaces (std::string t) Removes all whitespace characters (spaces, tabs, newlines, etc.) from the input string. |
Detailed Description#
SBCContainerString is a simple class that encapsulates a std::string. Its initial purpose was to provide a simple way to remove whitespaces in a string:
// non-static version
SBString s("Hello World");
s.removeWhitespaces(); // s becomes "HelloWorld"
// static version (does not modify the input)
std::string s("Hello World");
std::string r = SBString::removeWhitespaces(s); // r is "HelloWorld"
Short name: SBString
Public Functions Documentation#
function SBCContainerString [1/4]#
Constructs a string from a std::string s .
Constructs a SBCContainerString from a std::string.
Parameters:
_sInput string used to initialize the container.
function SBCContainerString [2/4]#
Constructs a string from a char array s .
Constructs a SBCContainerString from a C-string.
Parameters:
cC-string used to initialize the container. If null, an empty string is used.
function SBCContainerString [3/4]#
Copy constructor.
Copy‑constructs a SBCContainerString from another instance.
Parameters:
_sSource SBCContainerString to copy.
function SBCContainerString [4/4]#
Move constructor.
Move‑constructs a SBCContainerString from another instance, transferring ownership.
Parameters:
_sSource SBCContainerString to move from.
function operator=#
Copy assignment operator.
Copy‑assigns the contents of another SBCContainerString to this object.
Parameters:
_sSource SBCContainerString to copy from.
Returns:
Reference to this object.
function operator=#
Move assignment operator.
Move‑assigns the contents of another SBCContainerString to this object, transferring ownership.
Parameters:
_sSource SBCContainerString to move from.
Returns:
Reference to this object.
function print [1/2]#
Prints some debugging information.
Writes the stored string to the given output stream.
Parameters:
osOutput stream to write to.
function print [2/2]#
Prints some debugging information.
Writes the stored string to the standard output (std::cout).
function removeWhitespaces [1/2]#
Removes all whitespace characters (spaces, tabs, newlines, etc.) from the string.
Removes all whitespace characters from the stored string.
function ~SBCContainerString#
Destructs the string.
Destroys the SBCContainerString and releases any allocated resources.
Public Static Functions Documentation#
function removeWhitespaces [2/2]#
Removes all whitespace characters (spaces, tabs, newlines, etc.) from the input string.
Returns a copy of the input string with all whitespace characters removed.
Parameters:
tInput string from which whitespace will be removed.
Returns:
A new string with whitespace removed.