![]() |
Consolix
|
< Utility modules and helpers. More...
Classes | |
class | AppComponentManager |
Manages a collection of application components with lifecycle support. More... | |
class | BaseLoopComponent |
Abstract base class for application components with looping functionality. More... | |
class | ColorManipulator |
A utility class for managing text color in streams. More... | |
class | ConsoleApplication |
Singleton class to manage the lifecycle of a console application. More... | |
class | IAppComponent |
Interface for defining application components. More... | |
class | IShutdownable |
Interface for components supporting shutdown logic. More... | |
class | LoggerComponent |
Fallback LoggerComponent when LogIt is disabled. More... | |
class | LogoComponent |
Component responsible for displaying a customizable ASCII logo. More... | |
class | LoopComponent |
Component for managing a customizable execution loop. More... | |
class | MultiStream |
A class for handling multi-target log streams. More... | |
class | ServiceLocator |
A universal service locator for managing shared resources. More... | |
class | TitleComponent |
Handles setting and retrieving the console window title. More... | |
Enumerations | |
enum class | TextColor { Black , DarkRed , DarkGreen , DarkYellow , DarkBlue , DarkMagenta , DarkCyan , LightGray , DarkGray , Red , Green , Yellow , Blue , Magenta , Cyan , White } |
Represents text colors for console output. More... | |
Functions | |
void | init () |
Initializes the application. This function prepares the application and service locator for use. | |
template<typename InitAction> | |
void | init (InitAction init_action) |
Initializes the application with a custom action. This function prepares the application and service locator, and executes a custom action during initialization. | |
template<typename Component, typename... Args> | |
std::shared_ptr< Component > | add (Args &&... args) |
Adds a new component to the application. Creates a new instance of the specified component type and adds it to the application. | |
void | add (std::shared_ptr< IAppComponent > component) |
Adds an existing component to the application. Registers a pre-existing component with the application. | |
void | run () |
Runs the application. Processes all components in the application's main loop. | |
template<typename IterationAction> | |
void | run (IterationAction iteration_action) |
Runs the application with a custom loop action. | |
void | stop () |
Stops the application. Stops the application's main loop and begins the shutdown process. | |
template<typename T> | |
void | register_service (std::function< std::shared_ptr< T >()> creator) |
Registers a resource or service globally. Registers a resource or service with the ServiceLocator using the provided creator function. | |
template<typename T> | |
void | register_service () |
Registers a resource with default construction globally. Registers a resource or service using default construction. | |
template<typename T> | |
T & | get_service () |
Retrieves a resource globally. Retrieves a reference to a globally registered resource from the ServiceLocator . | |
template<typename T> | |
bool | has_service () |
Checks if a resource is registered globally. | |
void | clear_all () |
Clears all registered resources globally. Clears all resources and services registered in the ServiceLocator | |
ColorManipulator | color (TextColor color) |
Creates a color manipulator for use in output streams. | |
std::ostream & | operator<< (std::ostream &os, const ColorManipulator &manip) |
Overloads the stream operator to apply text color. | |
const char * | to_c_str (const TextColor &color) |
Converts a TextColor to an ANSI escape code string. | |
bool | check_escaped (const std::string &json_string, size_t quote_position) |
Checks if a character in a JSON string is escaped. | |
*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) |
std::string | get_exec_path () |
Retrieves the full path of the executable. | |
std::string | get_exec_dir () |
Retrieves the directory of the executable file. | |
std::string | get_file_name (const std::string &file_path) |
Extracts the file name from a full file path. | |
std::string | make_relative (const std::string &file_path, const std::string &base_path) |
Computes the relative path from base_path to file_path. | |
void | create_directories (const std::string &path) |
Creates directories recursively for the given path. | |
Variables | |
*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 | true |
Removes comments from a JSON string. | |
*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 | false |
*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 | enabled |
*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 | Otherwise |
< Utility modules and helpers.
< Global configuration macros for Consolix. < Core functionalities of Consolix. < Aggregated components of Consolix.
Main namespace for the Consolix framework.
The consolix
namespace contains all classes, functions, and utilities provided by the Consolix framework. It is the primary namespace used for building structured and flexible console applications.
|
strong |
Represents text colors for console output.
The enumeration defines a set of standard text colors compatible with both ANSI escape codes (Linux/macOS) and Windows API (Windows).
Enumerator | |
---|---|
Black | |
DarkRed | |
DarkGreen | |
DarkYellow | |
DarkBlue | |
DarkMagenta | |
DarkCyan | |
LightGray | |
DarkGray | |
Red | |
Green | |
Yellow | |
Blue | |
Magenta | |
Cyan | |
White |
|
inline |
Adds a new component to the application. Creates a new instance of the specified component type and adds it to the application.
Component | The type of the component to add. |
Args | The types of the arguments to pass to the component's constructor. |
args | Arguments to construct the component. |
std::shared_ptr
to the added component. Definition at line 50 of file application_utils.hpp.
|
inline |
Adds an existing component to the application. Registers a pre-existing component with the application.
component | A std::shared_ptr to the component to add. |
Definition at line 57 of file application_utils.hpp.
|
inline |
Checks if a character in a JSON string is escaped.
json_string | The JSON string. |
quote_position | The position of the character to check. |
true
if the character is escaped, false
otherwise. Definition at line 17 of file json_utils.hpp.
|
inline |
Clears all registered resources globally. Clears all resources and services registered in the ServiceLocator
Definition at line 65 of file service_utils.hpp.
|
inline |
Creates a color manipulator for use in output streams.
color | The desired text color. |
ColorManipulator
object for stream manipulation. Definition at line 52 of file ColorManipulator.hpp.
void consolix::create_directories | ( | const std::string & | path | ) |
Creates directories recursively for the given path.
path | The directory path to create. |
std::runtime_error | if the directories cannot be created. |
Definition at line 185 of file path_utils.hpp.
std::string consolix::get_exec_dir | ( | ) |
Retrieves the directory of the executable file.
Definition at line 56 of file path_utils.hpp.
std::string consolix::get_exec_path | ( | ) |
Retrieves the full path of the executable.
Definition at line 17 of file path_utils.hpp.
std::string consolix::get_file_name | ( | const std::string & | file_path | ) |
Extracts the file name from a full file path.
file_path | The full file path as a string. |
Definition at line 147 of file path_utils.hpp.
|
inline |
Retrieves a resource globally. Retrieves a reference to a globally registered resource from the ServiceLocator
.
T | The type of the resource. |
Definition at line 51 of file service_utils.hpp.
|
inline |
Checks if a resource is registered globally.
T | The type of the resource. |
true
if the resource is registered, false
otherwise. Definition at line 59 of file service_utils.hpp.
void consolix::init | ( | ) |
Initializes the application. This function prepares the application and service locator for use.
Definition at line 28 of file application_utils.hpp.
void consolix::init | ( | InitAction | init_action | ) |
Initializes the application with a custom action. This function prepares the application and service locator, and executes a custom action during initialization.
InitAction | A callable type for the custom initialization action. |
init_action | The action to execute during initialization. |
Definition at line 38 of file application_utils.hpp.
|
inline |
Computes the relative path from base_path to file_path.
file_path | The target file path. |
base_path | The base path from which to compute the relative path. |
Definition at line 156 of file path_utils.hpp.
|
inline |
Overloads the stream operator to apply text color.
os | The output stream. |
manip | The ColorManipulator controlling the text color. |
Definition at line 60 of file ColorManipulator.hpp.
|
inline |
Registers a resource with default construction globally. Registers a resource or service using default construction.
T | The type of the resource. |
Definition at line 42 of file service_utils.hpp.
|
inline |
Registers a resource or service globally. Registers a resource or service with the ServiceLocator
using the provided creator function.
T | The type of the resource. |
creator | A function to create the resource (optional). |
Definition at line 34 of file service_utils.hpp.
|
inline |
Runs the application. Processes all components in the application's main loop.
Definition at line 63 of file application_utils.hpp.
|
inline |
Runs the application with a custom loop action.
Executes a custom action during each iteration of the application's main loop.
IterationAction | A callable type for the custom loop action. |
iteration_action | The action to execute in the main loop. |
Definition at line 73 of file application_utils.hpp.
|
inline |
Stops the application. Stops the application's main loop and begins the shutdown process.
Definition at line 79 of file application_utils.hpp.
*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 consolix::strip_json_comments | ( | const std::string & | json_string, |
bool | with_whitespace = false, | ||
bool | preserve_newlines = true ) |
Definition at line 39 of file json_utils.hpp.
|
inline |
* 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 consolix::enabled |
Definition at line 35 of file json_utils.hpp.
* 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 consolix::false |
Definition at line 34 of file json_utils.hpp.
* 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 consolix::Otherwise |
Definition at line 36 of file json_utils.hpp.
* 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 consolix::true |
Removes comments from a JSON string.
This function processes a JSON string and removes comments, including single-line comments (e.g., //
or #
) and multi-line comments (e.g., `/* ...
Definition at line 33 of file json_utils.hpp.