Web Analytics Made Easy - Statcounter
Skip to content

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 .

explicit SBCContainerString::SBCContainerString (
    std::string s
) 

Constructs a SBCContainerString from a std::string.

Parameters:

  • _s Input string used to initialize the container.

function SBCContainerString [2/4]#

Constructs a string from a char array s .

explicit SBCContainerString::SBCContainerString (
    const char * s
) 

Constructs a SBCContainerString from a C-string.

Parameters:

  • c C-string used to initialize the container. If null, an empty string is used.

function SBCContainerString [3/4]#

Copy constructor.

SBCContainerString::SBCContainerString (
    const SBCContainerString & s
) 

Copy‑constructs a SBCContainerString from another instance.

Parameters:


function SBCContainerString [4/4]#

Move constructor.

SBCContainerString::SBCContainerString (
    SBCContainerString && s
) noexcept

Move‑constructs a SBCContainerString from another instance, transferring ownership.

Parameters:


function operator=#

Copy assignment operator.

SBCContainerString & SBCContainerString::operator= (
    const SBCContainerString & s
) 

Copy‑assigns the contents of another SBCContainerString to this object.

Parameters:

Returns:

Reference to this object.


function operator=#

Move assignment operator.

SBCContainerString & SBCContainerString::operator= (
    SBCContainerString && s
) noexcept

Move‑assigns the contents of another SBCContainerString to this object, transferring ownership.

Parameters:

Returns:

Reference to this object.


function print [1/2]#

Prints some debugging information.

void SBCContainerString::print (
    std::ostream & os
) const

Writes the stored string to the given output stream.

Parameters:

  • os Output stream to write to.

function print [2/2]#

Prints some debugging information.

void SBCContainerString::print () const

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.

void SBCContainerString::removeWhitespaces () 

Removes all whitespace characters from the stored string.


function ~SBCContainerString#

Destructs the string.

virtual SBCContainerString::~SBCContainerString () 

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.

static std::string SBCContainerString::removeWhitespaces (
    std::string t
) 

Returns a copy of the input string with all whitespace characters removed.

Parameters:

  • t Input string from which whitespace will be removed.

Returns:

A new string with whitespace removed.