|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
Factory class for creating parser instances. More...
#include <ParserFactory.hpp>

Public Types | |
| using | CreatorFunc = std::function< std::unique_ptr< IDataParser >()> |
| Type alias for parser creator function. | |
Static Public Member Functions | |
| static util::Result< std::unique_ptr< IDataParser >, error::Error > | CreateFromFile (const std::filesystem::path &filepath) |
| Creates a parser based on file extension. | |
| static util::Result< std::unique_ptr< IDataParser >, error::Error > | Create (ParserType type) |
| Creates a parser of specific type. | |
| static std::optional< error::Error > | Register (const std::string &extension, CreatorFunc creator) |
| Registers a custom parser creator for a file extension. | |
| static bool | IsRegistered (const std::string &extension) |
| Checks if a parser is registered for an extension. | |
| static std::vector< std::string > | GetSupportedExtensions () |
| Gets all registered file extensions. | |
Static Private Member Functions | |
| static void | InitializeDefaults () |
| Initializes default parsers (XML, JSON, etc.) | |
| static void | EnsureInitialized () |
| Ensures default parsers are registered (called automatically) | |
Static Private Attributes | |
| static std::map< std::string, CreatorFunc > | s_creators |
| Map of file extensions to parser creators. | |
Factory class for creating parser instances.
Provides centralized parser creation with support for:
| using parser::ParserFactory::CreatorFunc = std::function<std::unique_ptr<IDataParser>()> |
Type alias for parser creator function.
|
static |
Creates a parser of specific type.
| type | The type of parser to create |

|
static |
Creates a parser based on file extension.
Examines the file extension and returns an appropriate parser. Falls back to XML parser if extension is not recognized.
| filepath | Path to the file to parse |


|
staticprivate |
Ensures default parsers are registered (called automatically)


|
static |
Gets all registered file extensions.

|
staticprivate |
Initializes default parsers (XML, JSON, etc.)


|
static |
Checks if a parser is registered for an extension.
| extension | File extension to check |


|
static |
Registers a custom parser creator for a file extension.
Allows runtime registration of parsers for custom file formats. The creator function will be called whenever a file with the specified extension needs parsing.
| extension | File extension (e.g., ".log", ".txt") |
| creator | Function that creates parser instances |

|
staticprivate |
Map of file extensions to parser creators.