Consolix
Loading...
Searching...
No Matches
Utilities

Common utility modules and helpers in Consolix. More...

Files

file  utils.hpp
 Entry point for including utility headers for Consolix.
 
file  encoding_utils.hpp
 Utilities for working with character encodings and string transformations.
 

Detailed Description

Common utility modules and helpers in Consolix.

The Utilities group includes a variety of modules that provide helper functions, type definitions, and features to simplify application development with Consolix. These utilities cover JSON manipulation, path handling, enumeration definitions, encoding transformations, and more.

Included Modules:

Example Usage:

int main() {
// Example of using ColorManipulator for styled console output
CONSOLIX_STREAM() << consolix::color(consolix::TextColor::Green) << "Hello, Consolix!" << std::endl;
// Example of working with paths
std::string exe_dir = consolix::resolve_executable_path();
CONSOLIX_STREAM() << "Executable Directory: " << exe_dir << std::endl;
// Example of stripping comments from a JSON string
std::string raw_json = R"({
"key": "value", // This is a comment
/* Another comment *&zwj;/
"key2": "value2"
})";
std::string clean_json = consolix::strip_json_comments(raw_json);
CONSOLIX_STREAM() << "Clean JSON: " << clean_json << std::endl;
// Example of encoding transformations
std::string utf8_string = "Привет, мир!";
std::string ansi_string = consolix::utf8_to_ansi(utf8_string);
CONSOLIX_STREAM() << "ANSI Encoded: " << ansi_string << std::endl;
return 0;
}
#define CONSOLIX_STREAM()
Fallback for general logging.
*The resulting JSON string may optionally retain whitespace or newlines *where the comments were removed **param json_string The JSON string to process *param with_whitespace If comments are replaced with equivalent whitespace *If comments are removed without leaving whitespace *param preserve_newlines If true and with_whitespace is newline characters *in comments are preserved all characters in the *comments are replaced with whitespace *return A JSON string with comments removed *std::string strip_json_comments(const std::string &json_string, bool with_whitespace=false, bool preserve_newlines=true)
ColorManipulator color(TextColor color)
Creates a color manipulator for use in output streams.
Entry point for including utility headers for Consolix.