![]() |
Consolix
|
< Utility modules and helpers. More...
Namespaces | |
| namespace | compat |
Classes | |
| class | BaseLoopComponent |
| Abstract base class for application components with looping functionality. More... | |
| class | LoggerComponent |
| Fallback LoggerComponent when LogIt is disabled. More... | |
| class | MultiStream |
| A class for handling multi-target log streams. More... | |
| class | LogoComponent |
| Component responsible for displaying a customizable ASCII logo. More... | |
| class | LoopComponent |
| Component for managing a customizable execution loop. More... | |
| class | TitleComponent |
| Handles setting and retrieving the console window title. More... | |
| class | AppComponentManager |
| Manages a collection of application components with lifecycle support. More... | |
| class | ConsoleApplication |
| Singleton class to manage the lifecycle of a console application. More... | |
| class | ServiceLocator |
| A universal service locator for managing shared resources. More... | |
| class | IAppComponent |
| Interface for defining application components. More... | |
| class | IShutdownable |
| Interface for components supporting shutdown logic. More... | |
| class | ColorManipulator |
| A utility class for managing text color in streams. 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, std::size_t quote_position) |
| Checks if a character in a JSON string is escaped. | |
| std::string | strip_json_comments (const std::string &json_string, bool with_whitespace=false, bool preserve_newlines=true) |
| Removes comments from a JSON string. | |
| 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 | resolve_exec_path (const std::string &relative_path) |
| Resolves a relative path to absolute, based on executable location. | |
| 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. | |
| bool | copy_to_clipboard (const std::string &text) |
| Copies the given text to the system clipboard. | |
| std::string | get_clipboard_text () |
| Retrieves text from the system clipboard. | |
| std::string | get_os_name () |
| Gets the name of the operating system. | |
| std::uint64_t | get_system_time_ms () |
| Gets the current system time in milliseconds. | |
| int | get_cpu_count () |
| Gets the number of logical CPU cores. | |
| std::string | get_home_directory () |
| Gets the user's home directory path. | |
| std::string | get_temp_directory () |
| Gets the system temporary directory path. | |
| std::string | get_env_var (const std::string &var_name) |
| Retrieves an environment variable's value. | |
< 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. |
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. |
Definition at line 18 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. |
Definition at line 52 of file ColorManipulator.hpp.
|
inline |
Copies the given text to the system clipboard.
| text | The text to copy. |
Definition at line 27 of file system_utils.hpp.
|
inline |
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 87 of file path_utils.hpp.
|
inline |
Retrieves text from the system clipboard.
Definition at line 57 of file system_utils.hpp.
|
inline |
Gets the number of logical CPU cores.
Definition at line 103 of file system_utils.hpp.
|
inline |
Retrieves an environment variable's value.
| var_name | The name of the environment variable. |
Definition at line 147 of file system_utils.hpp.
|
inline |
Retrieves the directory of the executable file.
Definition at line 52 of file path_utils.hpp.
|
inline |
Retrieves the full path of the executable.
Definition at line 21 of file path_utils.hpp.
|
inline |
Extracts the file name from a full file path.
| file_path | The full file path as a string. |
Definition at line 59 of file path_utils.hpp.
|
inline |
Gets the user's home directory path.
Definition at line 117 of file system_utils.hpp.
|
inline |
Gets the name of the operating system.
Definition at line 81 of file system_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 |
Gets the current system time in milliseconds.
Definition at line 95 of file system_utils.hpp.
|
inline |
Gets the system temporary directory path.
Definition at line 131 of file system_utils.hpp.
|
inline |
Checks if a resource is registered globally.
| T | The type of the resource. |
Definition at line 59 of file service_utils.hpp.
|
inline |
Initializes the application. This function prepares the application and service locator for use.
Definition at line 28 of file application_utils.hpp.
|
inline |
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 74 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 |
Resolves a relative path to absolute, based on executable location.
| relative_path | Relative path from executable directory. |
Definition at line 66 of file path_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.
|
inline |
Removes comments from a JSON string.
| json_string | The JSON string to process. |
| with_whitespace | If true, comments are replaced with equivalent whitespace. |
| preserve_newlines | If true and with_whitespace is enabled, newline characters are preserved. |
Definition at line 38 of file json_utils.hpp.