CGPdocs

Strings and text

Convert values and types to strings (str, type_str), change the case, pad with zeros.

Compute 2

contains

2 overloads
template <typename T1, typename T2>
bool contains(std::map<T1,T2> const& m, T1 const& key)
source

Checks whether a key exists in the map.

template <typename T>
bool contains(std::map<std::string,T> const& m, char const* key)
source

Checks whether a C-string key exists in a map with string keys.

Convert 39

str

15 overloads
std::string str(float a)
source

Text representation of a float value (std::to_string).

std::string str(double a)
source

Text representation of a double value (std::to_string).

std::string str(char a)
source

One-character string made of the given char.

std::string str(short a)
source

Text representation of a short value (std::to_string).

std::string str(int a)
source

Text representation of a int value (std::to_string).

std::string str(long a)
source

Text representation of a long value (std::to_string).

std::string str(long long a)
source

Text representation of a long long value (std::to_string).

std::string str(unsigned char a)
source

Decimal representation of the unsigned char value (a number, not a character).

std::string str(unsigned short a)
source

Text representation of a unsigned short value (std::to_string).

std::string str(unsigned int a)
source

Text representation of a unsigned int value (std::to_string).

std::string str(unsigned long a)
source

Text representation of a unsigned long value (std::to_string).

std::string str(unsigned long long a)
source

Text representation of a unsigned long long value (std::to_string).

template <typename T1, typename T2>
std::string str(std::map<T1,T2> const& m)
source

Text representation of a map as "{key:value key:value }".

std::string const& str(std::string const& s)
source

Returns the string itself (identity overload so that str() works on any type).

std::string str(char const* s)
source

Converts a C-string to std::string.

std::string str_lower(std::string const& s)

Copy of the string converted to lowercase.

std::string str_upper(std::string const& s)

Copy of the string converted to uppercase.

std::string str_zero_fill(std::string const& input, size_t number_of_zero)

Left-pads the string with zeros up to the given total length (unchanged if already longer).

type_str

21 overloads
std::string type_str(float)
source

Type name as a string: "float".

std::string type_str(double)
source

Type name as a string: "double".

std::string type_str(char)
source

Type name as a string: "char".

std::string type_str(short)
source

Type name as a string: "short".

std::string type_str(int)
source

Type name as a string: "int".

std::string type_str(long)
source

Type name as a string: "long".

std::string type_str(long long)
source

Type name as a string: "long long".

std::string type_str(unsigned char)
source

Type name as a string: "unsigned char".

std::string type_str(unsigned short)
source

Type name as a string: "unsigned short".

std::string type_str(unsigned int)
source

Type name as a string: "unsigned int".

std::string type_str(unsigned long)
source

Type name as a string: "unsigned long".

std::string type_str(unsigned long long)
source

Type name as a string: "unsigned long long".

template <typename T>
std::string type_str(std::set<T> const&)
source

Type name as a string, e.g. "std::set<int>".

std::string type_str(std::string const& s)
source

Type name as a string: "string".

template <typename T>
std::string type_str(T const&)
source

Fallback for types without a dedicated type_str overload; returns a placeholder message.

std::string type_str(int2 const&)
source

Type name as a string: "int2".

std::string type_str(int3 const&)
source

Type name as a string: "int3".

std::string type_str(int4 const&)
source

Type name as a string: "int4".

std::string type_str(uint2 const&)
source

Type name as a string: "uint2".

std::string type_str(uint3 const&)
source

Type name as a string: "uint3".

std::string type_str(uint4 const&)
source

Type name as a string: "uint4".

CGP - Computer Graphics Programming.