Maze Builder Docs 6.7.5
Loading...
Searching...
No Matches
mazes::string_view_utils Class Reference

String helper class. More...

#include <string_view_utils.h>

Static Public Member Functions

static void objectify (const std::unique_ptr< maze > &m, std::vector< std::tuple< int, int, int, int > > &vertices, std::vector< std::vector< std::uint32_t > > &faces, std::string_view sv=std::string_view{}) noexcept
 Compute the 3D geometries of a maze.
 
static void objectify (lab &labyrinth, std::string_view sv=std::string_view{}) noexcept
 Compute the 3D geometries of a maze.
 
static void to_pixels (const std::string &s, std::vector< std::uint8_t > &pixels, int &width, int &height, int stride=4) noexcept
 Converts a string representation of an image to a pixel array.
 
static void to_pixels_colored (const std::string &s, std::vector< std::uint8_t > &pixels, int &width, int &height, int stride=4) noexcept
 Converts a maze to a pixel representation.
 
static std::string stringify (const std::unique_ptr< maze > &m) noexcept
 Convert a maze into a string representation.
 
static std::string trim (const std::string &str) noexcept
 Trim whitespace from both ends of a string.
 
static bool contains (const std::string &str, const std::string &substr) noexcept
 Check if a string contains a substring.
 
static std::string get_file_extension (const std::string &filename) noexcept
 Extract file extension from a filename.
 
static bool ends_with (const std::string &str, const std::string &suffix) noexcept
 Check if a string ends with a specific suffix.
 
static std::string_view find_first_of (const std::string_view &s, const std::string_view &chars) noexcept
 Find the first occurrence of any character from a set in a string view.
 
static std::vector< std::string > split (const std::string &str, char delimiter) noexcept
 Split a string by delimiter.
 
static std::string_view strip (const std::string_view &s, char to_strip_from_s) noexcept
 Strip specific characters from the beginning and end of a string view.
 
static std::string_view strip_json_quotes (const std::string_view &s) noexcept
 Strip quotes from a JSON string value.
 
static std::string to_string (std::unordered_map< std::string, std::string > const &m) noexcept
 Convert a map to a formatted string with each key-value pair on a line.
 
static std::string to_string (const args &a) noexcept
 Convert an args object to a string.
 
static std::string to_string (const std::reference_wrapper< const args > &a) noexcept
 Convert a reference_wrapper of args to a string.
 

Detailed Description

String helper class.

This class provides methods to convert mazes into string representations

Member Function Documentation

◆ contains()

static bool mazes::string_view_utils::contains ( const std::string & str,
const std::string & substr )
staticnoexcept

Check if a string contains a substring.

Parameters
strThe string to search in
substrThe substring to search for
Returns
True if substr is found in str, false otherwise

◆ ends_with()

static bool mazes::string_view_utils::ends_with ( const std::string & str,
const std::string & suffix )
staticnoexcept

Check if a string ends with a specific suffix.

Parameters
strThe string to check
suffixThe suffix to check for
Returns
True if str ends with suffix, false otherwise

◆ find_first_of()

static std::string_view mazes::string_view_utils::find_first_of ( const std::string_view & s,
const std::string_view & chars )
staticnoexcept

Find the first occurrence of any character from a set in a string view.

Parameters
sThe string view to search in
charsThe set of characters to search for
Returns
A string view starting from the first occurrence of any character in chars, or the end of s if none found

◆ get_file_extension()

static std::string mazes::string_view_utils::get_file_extension ( const std::string & filename)
staticnoexcept

Extract file extension from a filename.

Parameters
filenameThe filename to process
Returns
The file extension including the dot, or empty string if no extension

◆ objectify() [1/2]

static void mazes::string_view_utils::objectify ( const std::unique_ptr< maze > & m,
std::vector< std::tuple< int, int, int, int > > & vertices,
std::vector< std::vector< std::uint32_t > > & faces,
std::string_view sv = std::string_view{} )
staticnoexcept

Compute the 3D geometries of a maze.

Parameters
mthe maze to convert
verticesthe vertices of the maze
facesthe faces of the maze
sthe string representation of the maze

◆ objectify() [2/2]

static void mazes::string_view_utils::objectify ( lab & labyrinth,
std::string_view sv = std::string_view{} )
staticnoexcept

Compute the 3D geometries of a maze.

Parameters
labyrinththe collection of mazes
sv

◆ split()

static std::vector< std::string > mazes::string_view_utils::split ( const std::string & str,
char delimiter )
staticnoexcept

Split a string by delimiter.

Parameters
strThe string to split
delimiterThe delimiter to split by
Returns
Vector of split substrings

◆ stringify()

static std::string mazes::string_view_utils::stringify ( const std::unique_ptr< maze > & m)
staticnoexcept

Convert a maze into a string representation.

Parameters
mthe maze to convert
Returns
the string representation

◆ strip()

static std::string_view mazes::string_view_utils::strip ( const std::string_view & s,
char to_strip_from_s )
staticnoexcept

Strip specific characters from the beginning and end of a string view.

Parameters
sThe string view to strip characters from
to_strip_from_sThe character to strip
Returns
A new string view with the specified characters removed from both ends

◆ strip_json_quotes()

static std::string_view mazes::string_view_utils::strip_json_quotes ( const std::string_view & s)
staticnoexcept

Strip quotes from a JSON string value.

Parameters
sThe string view potentially containing JSON quotes
Returns
A string view with JSON quotes removed from both ends

◆ to_pixels()

static void mazes::string_view_utils::to_pixels ( const std::string & s,
std::vector< std::uint8_t > & pixels,
int & width,
int & height,
int stride = 4 )
staticnoexcept

Converts a string representation of an image to a pixel array.

Parameters
s
pixelsvector to store the resulting pixel data
widthinteger reference to store the width of the image
heightinteger reference to store the height of the image

◆ to_pixels_colored()

static void mazes::string_view_utils::to_pixels_colored ( const std::string & s,
std::vector< std::uint8_t > & pixels,
int & width,
int & height,
int stride = 4 )
staticnoexcept

Converts a maze to a pixel representation.

Parameters
mA unique pointer to the maze object to be converted.
pixelsA vector to store the resulting pixel data.
widthAn integer reference to store the width of the pixel data.
heightAn integer reference to store the height of the pixel data.
strideThe number of bytes per row in the pixel data.

◆ to_string() [1/3]

static std::string mazes::string_view_utils::to_string ( const args & a)
staticnoexcept

Convert an args object to a string.

Parameters
aThe args object to convert
Returns
A formatted string representation of the args

◆ to_string() [2/3]

static std::string mazes::string_view_utils::to_string ( const std::reference_wrapper< const args > & a)
staticnoexcept

Convert a reference_wrapper of args to a string.

Parameters
aThe reference_wrapper of args to convert
Returns
A formatted string representation of the args

◆ to_string() [3/3]

static std::string mazes::string_view_utils::to_string ( std::unordered_map< std::string, std::string > const & m)
staticnoexcept

Convert a map to a formatted string with each key-value pair on a line.

Parameters
mThe map to convert
Returns
A formatted string representation of the map

◆ trim()

static std::string mazes::string_view_utils::trim ( const std::string & str)
staticnoexcept

Trim whitespace from both ends of a string.

Parameters
strThe string to trim
Returns
A trimmed copy of the string

The documentation for this class was generated from the following file: