LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
parser::IDataParser Class Referenceabstract

Abstract base class for all data parsing implementations. More...

#include <IDataParser.hpp>

Inheritance diagram for parser::IDataParser:
Inheritance graph
Collaboration diagram for parser::IDataParser:
Collaboration graph

Public Member Functions

virtual ~IDataParser ()=default
 Virtual destructor for proper cleanup of derived classes.
 
virtual void ParseData (const std::filesystem::path &filepath)=0
 Parses data from a file path.
 
virtual void ParseData (std::istream &input)=0
 Parses data from an input stream.
 
virtual uint32_t GetCurrentProgress () const =0
 Gets the current parsing progress.
 
virtual uint32_t GetTotalProgress () const =0
 Gets the total expected progress value.
 
virtual std::vector< std::pair< std::string, std::string > > GetFileMetadata () const
 Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).
 
void RegisterObserver (IDataParserObserver *observer)
 Registers an observer to receive parsing notifications.
 
void UnregisterObserver (IDataParserObserver *observer)
 
void NotifyNewEvent (db::LogEvent &&event)
 
void NotifyProgressUpdated ()
 
void NotifyNewEventBatch (std::vector< std::pair< int, db::LogEvent::EventItems > > &&eventBatch)
 

Private Attributes

std::vector< IDataParserObserver * > observers
 

Detailed Description

Abstract base class for all data parsing implementations.

This class defines the common interface for parsing different log file formats. Concrete implementations handle specific formats (XML, JSON, CSV, etc.) while providing a consistent interface for client code.

Observer Pattern
The parser uses the Observer pattern to notify interested parties about parsing progress and discovered events without tight coupling.
Thread Safety
Base class is not thread-safe. Derived classes should document their thread safety guarantees.

Constructor & Destructor Documentation

◆ ~IDataParser()

virtual parser::IDataParser::~IDataParser ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ GetCurrentProgress()

virtual uint32_t parser::IDataParser::GetCurrentProgress ( ) const
pure virtual

Gets the current parsing progress.

Returns
uint32_t Current progress value (meaning depends on implementation)
Note
Progress values should be used with GetTotalProgress() for percentage calculations

Implemented in parser::AscParser, parser::CsvParser, parser::DltParser, parser::EvlogParser, parser::JsonParser, parser::SapiLogParser, and parser::XmlParser.

Here is the caller graph for this function:

◆ GetFileMetadata()

virtual std::vector< std::pair< std::string, std::string > > parser::IDataParser::GetFileMetadata ( ) const
inlinevirtual

Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).

Returns
Empty for formats without a header (the default).

Reimplemented in parser::SapiLogParser.

◆ GetTotalProgress()

virtual uint32_t parser::IDataParser::GetTotalProgress ( ) const
pure virtual

Gets the total expected progress value.

Returns
uint32_t Maximum progress value when parsing is complete
Note
Return 0 if total progress cannot be determined in advance

Implemented in parser::AscParser, parser::CsvParser, parser::DltParser, parser::EvlogParser, parser::JsonParser, parser::SapiLogParser, and parser::XmlParser.

Here is the caller graph for this function:

◆ NotifyNewEvent()

void parser::IDataParser::NotifyNewEvent ( db::LogEvent &&  event)
inline

◆ NotifyNewEventBatch()

void parser::IDataParser::NotifyNewEventBatch ( std::vector< std::pair< int, db::LogEvent::EventItems > > &&  eventBatch)
inline
Here is the caller graph for this function:

◆ NotifyProgressUpdated()

void parser::IDataParser::NotifyProgressUpdated ( )
inline
Here is the caller graph for this function:

◆ ParseData() [1/2]

virtual void parser::IDataParser::ParseData ( const std::filesystem::path &  filepath)
pure virtual

Parses data from a file path.

Parameters
filepathThe path to the file to parse
Exceptions
std::runtime_errorif the file cannot be opened or parsed
Note
This method should be implemented by derived classes for file-based parsing

Implemented in parser::AscParser, parser::CsvParser, parser::DltParser, parser::EvlogParser, parser::JsonParser, parser::SapiLogParser, and parser::XmlParser.

◆ ParseData() [2/2]

virtual void parser::IDataParser::ParseData ( std::istream &  input)
pure virtual

Parses data from an input stream.

Parameters
inputThe input stream to read data from
Exceptions
std::runtime_errorif the stream cannot be read or parsed
Note
This method enables parsing from various sources (files, network, memory)

Implemented in parser::AscParser, parser::CsvParser, parser::DltParser, parser::EvlogParser, parser::JsonParser, parser::SapiLogParser, and parser::XmlParser.

◆ RegisterObserver()

void parser::IDataParser::RegisterObserver ( IDataParserObserver *  observer)
inline

Registers an observer to receive parsing notifications.

Parameters
observerPointer to the observer object
Note
The observer must remain valid until parsing completes or it's unregistered
Duplicate observers are automatically prevented

◆ UnregisterObserver()

void parser::IDataParser::UnregisterObserver ( IDataParserObserver *  observer)
inline

Member Data Documentation

◆ observers

std::vector<IDataParserObserver*> parser::IDataParser::observers
private

The documentation for this class was generated from the following file: