|
LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
|
Parses CSV formatted log files. More...
#include <CsvParser.hpp>


Public Member Functions | |
| CsvParser () | |
| Constructs a new CSV parser with default settings. | |
| virtual | ~CsvParser () override=default |
| Virtual destructor for proper cleanup. | |
| void | ParseData (const std::filesystem::path &filepath) override |
| Parses CSV data from a file. | |
| void | ParseData (std::istream &input) override |
| Parses CSV data from an input stream. | |
| uint32_t | GetCurrentProgress () const override |
| Gets the current parsing progress. | |
| uint32_t | GetTotalProgress () const override |
| Gets the total expected progress. | |
| void | SetDelimiter (char delimiter) |
| Sets the field delimiter character. | |
| void | SetHasHeaders (bool hasHeaders) |
| Sets whether the first line contains headers. | |
| 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 Member Functions | |
| std::vector< std::string > | ParseLine (const std::string &line) |
| Parses a single CSV line into fields. | |
| db::LogEvent::EventItems | CreateEventFromFields (const std::vector< std::string > &fields, const std::vector< std::string > &headers, int eventId) |
| Creates EventItems from parsed CSV fields. | |
| util::Result< size_t, error::Error > | FindHeaderIndex (const std::vector< std::string > &headers, const std::string &name) |
| Finds the index of a header by name. | |
| std::string | Trim (std::string_view str) |
| Trims whitespace from both ends of a string. | |
Private Attributes | |
| char | m_delimiter = ',' |
| Field delimiter character. | |
| bool | m_hasHeaders = true |
| Whether first line contains headers. | |
| uint32_t | m_currentProgress = 0 |
| Current bytes processed. | |
| uint32_t | m_totalProgress = 0 |
| Total bytes to process. | |
| std::vector< IDataParserObserver * > | observers |
Parses CSV formatted log files.
This parser handles CSV (Comma-Separated Values) log files with the following format:
| parser::CsvParser::CsvParser | ( | ) |
Constructs a new CSV parser with default settings.

|
overridevirtualdefault |
Virtual destructor for proper cleanup.
|
private |
Creates EventItems from parsed CSV fields.
| fields | Vector of field values |
| headers | Vector of column headers |
| eventId | Sequential event ID |


|
private |
Finds the index of a header by name.
| headers | Vector of header names |
| name | Header name to find |


|
overridevirtual |
Gets the current parsing progress.
Implements parser::IDataParser.
|
inlinevirtualinherited |
Ordered key → value pairs read from the file header during the last ParseData() call (see db::EventsContainer::SetFileMetadata).
Reimplemented in parser::SapiLogParser.
|
overridevirtual |
Gets the total expected progress.
Implements parser::IDataParser.
|
inlineinherited |
|
inlineinherited |

|
inlineinherited |

|
overridevirtual |
Parses CSV data from a file.
| filepath | Path to the CSV file to parse |
| error::Error | if the file cannot be opened or parsed |
Implements parser::IDataParser.


|
overridevirtual |
Parses CSV data from an input stream.
| input | The input stream containing CSV data |
| error::Error | if the stream cannot be read or parsed |
Implements parser::IDataParser.

|
private |
Parses a single CSV line into fields.
| line | The CSV line to parse |


|
inlineinherited |
Registers an observer to receive parsing notifications.
| observer | Pointer to the observer object |
|
inline |
Sets the field delimiter character.
| delimiter | Character to use as field separator (default: ',') |
|
inline |
Sets whether the first line contains headers.
| hasHeaders | True if first line contains column names |
|
private |
Trims whitespace from both ends of a string.
| str | String to trim |

|
inlineinherited |
|
private |
Current bytes processed.
|
private |
Field delimiter character.
|
private |
Whether first line contains headers.
|
private |
Total bytes to process.
|
privateinherited |