Consolix
Loading...
Searching...
No Matches
Components

Core components of the Consolix framework. More...

Files

file  components.hpp
 Entry point for including all Consolix components.
file  BaseLoopComponent.hpp
 Provides a base class for implementing looping application components.
file  CliComponent.hpp
 Component for handling command-line arguments using cxxopts library.
file  ConfigComponent.hpp
 Component for loading and managing configuration data from JSON files.
file  LoggerComponent.hpp
 Logger component for managing application logging with LogIt.
file  LogoComponent.hpp
 Defines a component for displaying a customizable ASCII logo.
file  LoopComponent.hpp
 Defines a component for running a customizable execution loop.
file  TitleComponent.hpp
 Component for managing console window titles in a platform-independent way.

Detailed Description

Core components of the Consolix framework.

The Components group includes modules that provide functionality such as logging, command-line argument handling, configuration management, logo rendering, and structured execution loops.

Main Components:

  • TitleComponent: Manages the console window title across platforms.
    • Supports UTF-8 titles by converting them to UTF-16 on Windows.
    • On Linux/macOS, uses ANSI escape sequences for setting the title.
  • LoggerComponent: Configures and manages logging functionality.
    • Uses MultiStream to provide consistent logging across platforms.
    • Supports UTF-8 output, with automatic conversion to CP866 on Windows for compatibility with legacy consoles.
    • Supports ANSI color codes for enhanced readability.
    • Integrates with LogIt (if enabled) for structured and multi-stream logging.
  • LogoComponent: Displays the application logo in the console.
  • CliComponent: Handles command-line arguments using the cxxopts library.
  • ConfigComponent: Loads and manages configuration from JSON files.
  • BaseLoopComponent: A base class for loop-based components.
  • LoopComponent: A component with customizable execution loops.

Key Features:

  • Easy integration of logging and logo rendering.
  • Convenient handling of command-line arguments.
  • Lightweight JSON configuration management, including support for comments.
  • Support for custom execution loops using either a base class or the LoopComponent.
  • UTF-8 support for program titles on all platforms:
    • Automatically converted to UTF-16 on Windows for proper Unicode rendering.
    • Displayed via ANSI escape sequences on Linux/macOS.
  • UTF-8 console output:
    • Uses MultiStream for consistent handling of log messages.
    • On Windows, UTF-8 is automatically converted to CP866 for legacy console compatibility.
    • Supports ANSI color sequences for improved readability.
  • Integrates with LogIt (if enabled) for structured and multi-stream logging.

Included Headers:

Example Usage:

#define CONSOLIX_USE_LOGIT 1
int main(int argc, char* argv[]) {
// Add logging functionality
// Display the application logo
// Handle command-line arguments
consolix::add<consolix::CliComponent>("MyApp", "Program description", [](auto& options) {
options.add_options()("debug", "Enable debug mode");
}, argc, argv);
// Load configuration from a JSON file
// Execute the main loop
CONSOLIX_STREAM() << "Executing main loop...";
});
}
#define CONSOLIX_STREAM()
Fallback for general logging.
Entry point for including all Consolix components.
std::shared_ptr< Component > add(Args &&... args)
Adds a new component to the application. Creates a new instance of the specified component type and a...
void run()
Runs the application. Processes all components in the application's main loop.