Maze Builder Docs 6.7.5
Loading...
Searching...
No Matches
string_view_utils.h
Go to the documentation of this file.
1#ifndef STRINGZ_H
2#define STRINGZ_H
3
4#include <cstdint>
5#include <memory>
6#include <string_view>
7#include <string>
8#include <tuple>
9#include <unordered_map>
10#include <vector>
11#include <sstream>
12
13namespace mazes {
14
15class args;
16class maze;
17class lab;
18
20
25public:
26
32 static void objectify(const std::unique_ptr<maze>& m,
33 std::vector<std::tuple<int, int, int, int>>& vertices,
34 std::vector<std::vector<std::uint32_t>>& faces,
35 std::string_view sv = std::string_view{}) noexcept;
36
40 static void objectify(lab& labyrinth,
41 std::string_view sv = std::string_view{}) noexcept;
42
48 static void to_pixels(const std::string& s, std::vector<std::uint8_t>& pixels, int& width, int& height,
49 int stride = 4) noexcept;
50
57 static void to_pixels_colored(const std::string& s, std::vector<std::uint8_t>& pixels, int& width, int& height, int stride = 4) noexcept;
58
62 static std::string stringify(const std::unique_ptr<maze>& m) noexcept;
63
67 static std::string trim(const std::string& str) noexcept;
68
73 static bool contains(const std::string& str, const std::string& substr) noexcept;
74
78 static std::string get_file_extension(const std::string& filename) noexcept;
79
84 static bool ends_with(const std::string& str, const std::string& suffix) noexcept;
85
90 static std::string_view find_first_of(const std::string_view& s, const std::string_view& chars) noexcept;
91
96 static std::vector<std::string> split(const std::string& str, char delimiter) noexcept;
97
102 static std::string_view strip(const std::string_view& s, char to_strip_from_s) noexcept;
103
107 static std::string_view strip_json_quotes(const std::string_view& s) noexcept;
108
109
113 static std::string to_string(std::unordered_map<std::string, std::string> const& m) noexcept;
114
115 // Add these prototypes before the template method
119 static std::string to_string(const args& a) noexcept;
120
124 static std::string to_string(const std::reference_wrapper<const args>& a) noexcept;
125
126}; // class
127} // namespace
128
129#endif // STRINGZ_H
Command-line argument handler with JSON support.
Definition args.h:17
Holds mazes and provides search functions.
Definition lab.h:24
Definition pixels.h:8
String helper class.
Definition string_view_utils.h:24
static std::string_view strip_json_quotes(const std::string_view &s) noexcept
Strip quotes from a JSON string value.
static std::string trim(const std::string &str) noexcept
Trim whitespace from both ends of a string.
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 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_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 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::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 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 bool contains(const std::string &str, const std::string &substr) noexcept
Check if a string contains a substring.
static void objectify(lab &labyrinth, std::string_view sv=std::string_view{}) noexcept
Compute the 3D geometries of a maze.
static std::vector< std::string > split(const std::string &str, char delimiter) noexcept
Split a string by delimiter.
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.
Definition stringify.h:8
Namespace for the maze builder.
Definition algo_interface.h:9