LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
JsonParser.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IDataParser.hpp"
4
5#include <cstdint>
6#include <filesystem>
7#include <istream>
8#include <string>
9#include <string_view>
10
11#include <nlohmann/json.hpp>
12
13namespace parser
14{
15
31class JsonParser : public IDataParser
32{
33public:
34 JsonParser() = default;
35 ~JsonParser() override = default;
36
37 void ParseData(const std::filesystem::path& filepath) override;
38 void ParseData(std::istream& input) override;
39
40 uint32_t GetCurrentProgress() const override { return m_currentProgress; }
41 uint32_t GetTotalProgress() const override { return m_totalProgress; }
42
43private:
44 void Flatten(const nlohmann::json& node,
45 const std::string& prefix,
46 db::LogEvent::EventItems& out) const;
47
48 uint32_t m_currentProgress {0};
49 uint32_t m_totalProgress {0};
50};
51
52} // namespace parser
Interface definitions for data parsing components.
std::vector< std::pair< std::string, std::string > > EventItems
A collection of key-value pairs representing event data (eventFieldName, data).
Definition LogEvent.hpp:101
Abstract base class for all data parsing implementations.
Definition IDataParser.hpp:110
Definition JsonParser.hpp:32
uint32_t m_totalProgress
Definition JsonParser.hpp:49
~JsonParser() override=default
uint32_t GetTotalProgress() const override
Gets the total expected progress value.
Definition JsonParser.hpp:41
uint32_t m_currentProgress
Definition JsonParser.hpp:48
void ParseData(const std::filesystem::path &filepath) override
Parses data from a file path.
Definition JsonParser.cpp:19
void Flatten(const nlohmann::json &node, const std::string &prefix, db::LogEvent::EventItems &out) const
Definition JsonParser.cpp:210
uint32_t GetCurrentProgress() const override
Gets the current parsing progress.
Definition JsonParser.hpp:40
JsonParser()=default
Data parsing components and interfaces.
Definition IControler.hpp:22