Standard library » Containers » Strings module

Contents

Strings describe objects that can refer to a constant contiguous sequence of char values.

Files

file bn_format.h
file bn_istring_base.h
file bn_sstream.h
file bn_string.h
file bn_string_fwd.h
file bn_string_view.h

Classes

class bn::istring_base
Base class of istring.
template<>
struct bn::hash<istring_base>
Hash support for istring_base.
class bn::ostringstream
Implements output operations on string based streams.
class bn::istring
Base class of string.
template<int MaxSize>
class bn::string
String implementation that uses a fixed size buffer.
class bn::string_view
Refers to a constant contiguous sequence of char values.
template<>
struct bn::hash<string_view>
Hash support for string_view.

Functions

template<int MaxSize, class... Args>
auto format(const string_view& format, const Args&... args) -> string<MaxSize>
Format the given arguments according to the given format string, and return the result as a string.
template<class... Args>
void format_ref(istring_base& string, const string_view& format, const Args&... args)
Format the given arguments according to the given format string, storing the result in the given string.
auto operator<<(ostringstream& stream, char character) -> ostringstream&
Appends an additional character to the given ostringstream.
auto operator<<(ostringstream& stream, const string_view& view) -> ostringstream&
Appends additional characters to the given ostringstream.
auto operator<<(ostringstream& stream, const istring_base& string) -> ostringstream&
Appends additional characters to the given ostringstream.
auto operator<<(ostringstream& stream, const char* char_array_ptr) -> ostringstream&
Appends additional characters to the given ostringstream.
template<int MaxSize>
auto operator<<(ostringstream& stream, char(&char_array)[MaxSize]) -> ostringstream&
Appends additional characters to the given ostringstream.
auto operator<<(ostringstream& stream, bool value) -> ostringstream&
Appends the character representation of the given bool value to the given ostringstream.
auto operator<<(ostringstream& stream, int value) -> ostringstream&
Appends the character representation of the given int value to the given ostringstream.
auto operator<<(ostringstream& stream, long value) -> ostringstream&
Appends the character representation of the given long value to the given ostringstream.
auto operator<<(ostringstream& stream, int64_t value) -> ostringstream&
Appends the character representation of the given int64_t value to the given ostringstream.
auto operator<<(ostringstream& stream, unsigned value) -> ostringstream&
Appends the character representation of the given unsigned value to the given ostringstream.
auto operator<<(ostringstream& stream, unsigned long value) -> ostringstream&
Appends the character representation of the given unsigned long value to the given ostringstream.
auto operator<<(ostringstream& stream, uint64_t value) -> ostringstream&
Appends the character representation of the given uint64_t value to the given ostringstream.
auto operator<<(ostringstream& stream, const void* ptr) -> ostringstream&
Appends the character representation of the given pointer to the given ostringstream.
auto operator<<(ostringstream& stream, const nullptr_t& null_ptr) -> ostringstream&
Appends the character representation of the given null pointer to the given ostringstream.
template<int Precision>
auto operator<<(ostringstream& stream, fixed_t<Precision> value) -> ostringstream&
Appends the character representation of the given fixed point value to the given ostringstream.
template<int MaxSize>
auto make_string(const char(&char_array)[MaxSize]) -> string<MaxSize - 1> constexpr
Creates a string deducing its size from the size of the argument.
template<int MaxSize, typename Type>
auto to_string(const Type& value) -> string<MaxSize>
Converts the given value to a string.

Function documentation

#include <bn_format.h>
template<int MaxSize, class... Args>
string<MaxSize> format(const string_view& format, const Args&... args)

Format the given arguments according to the given format string, and return the result as a string.

Template parameters
MaxSize Maximum number of characters that can be stored in the output string.
Args Types of the arguments to be formatted.
Parameters
format string_view representing the format string.
args Arguments to be formatted. They are used in order when processing the format string.
Returns A string holding the formatted result.

The format string consists of:

  • Ordinary characters (except { and }), which are copied unchanged to the output.
  • Escape sequences {{ and }}, which are replaced with { and } respectively in the output.
  • Replacement fields, with the following format: {}.

#include <bn_format.h>
template<class... Args>
void format_ref(istring_base& string, const string_view& format, const Args&... args)

Format the given arguments according to the given format string, storing the result in the given string.

Parameters
string The result of the formatting is stored in this string.
format string_view representing the format string.
args Arguments to be formatted. They are used in order when processing the format string.

The format string consists of:

  • Ordinary characters (except { and }), which are copied unchanged to the output.
  • Escape sequences {{ and }}, which are replaced with { and } respectively in the output.
  • Replacement fields, with the following format: {}.

ostringstream& operator<<(ostringstream& stream, char character)

Appends an additional character to the given ostringstream.

Parameters
stream ostringstream in which to append to.
character Character to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, const string_view& view)

Appends additional characters to the given ostringstream.

Parameters
stream ostringstream in which to append to.
view string_view to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, const istring_base& string)

Appends additional characters to the given ostringstream.

Parameters
stream ostringstream in which to append to.
string string to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, const char* char_array_ptr)

Appends additional characters to the given ostringstream.

Parameters
stream ostringstream in which to append to.
char_array_ptr Pointer to null-terminated characters array.
Returns Reference to the ostringstream.

template<int MaxSize>
ostringstream& operator<<(ostringstream& stream, char(&char_array)[MaxSize])

Appends additional characters to the given ostringstream.

Parameters
stream ostringstream in which to append to.
char_array Non empty const characters array.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, bool value)

Appends the character representation of the given bool value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value bool value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, int value)

Appends the character representation of the given int value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value int value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, long value)

Appends the character representation of the given long value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value long value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, int64_t value)

Appends the character representation of the given int64_t value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value int64_t value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, unsigned value)

Appends the character representation of the given unsigned value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value unsigned value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, unsigned long value)

Appends the character representation of the given unsigned long value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value unsigned long value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, uint64_t value)

Appends the character representation of the given uint64_t value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value uint64_t value to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, const void* ptr)

Appends the character representation of the given pointer to the given ostringstream.

Parameters
stream ostringstream in which to append to.
ptr pointer to append.
Returns Reference to the ostringstream.

ostringstream& operator<<(ostringstream& stream, const nullptr_t& null_ptr)

Appends the character representation of the given null pointer to the given ostringstream.

Parameters
stream ostringstream in which to append to.
null_ptr Null pointer to append.
Returns Reference to the ostringstream.

template<int Precision>
ostringstream& operator<<(ostringstream& stream, fixed_t<Precision> value)

Appends the character representation of the given fixed point value to the given ostringstream.

Parameters
stream ostringstream in which to append to.
value Fixed point value to append.
Returns Reference to the ostringstream.

#include <bn_string.h>
template<int MaxSize>
string<MaxSize - 1> make_string(const char(&char_array)[MaxSize]) constexpr

Creates a string deducing its size from the size of the argument.

Parameters
char_array Non empty const characters array.
Returns string containing the given char array.

#include <bn_string.h>
template<int MaxSize, typename Type>
string<MaxSize> to_string(const Type& value)

Converts the given value to a string.

Template parameters
MaxSize Maximum number of characters that can be stored in the output string.
Type
Parameters
value Value to print in the string.
Returns string containing the representation of the given value.