LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
LogEvent.hpp
Go to the documentation of this file.
1
8#ifndef DB_EVENT_HPP
9#define DB_EVENT_HPP
10
11#include <string>
12#include <vector>
13#include <string_view>
14#include "Concepts.hpp"
15
20namespace db
21{
22
97{
98 public:
101 using EventItems = std::vector<std::pair<std::string, std::string>>;
102
105 std::vector<std::pair<std::string, std::string>>::iterator;
106
109 std::vector<std::pair<std::string, std::string>>::const_iterator;
110
136 template <typename... Args>
137 requires util::Constructible<EventItems, Args&&...>
138 LogEvent(int id, Args&&... args)
139 : m_id(id)
140 , m_eventItems(std::forward<Args>(args)...)
141 {
142 }
143
157 LogEvent(int id,
158 std::initializer_list<std::pair<std::string, std::string>> items)
159 : m_id(id)
160 , m_eventItems(items)
161 {
162 }
163
170 int getId() const;
171
178 const EventItems& getEventItems() const;
179
214 const std::string findByKey(std::string_view key) const;
215
216
230 const std::vector<std::string> findAllByKey(std::string_view key) const;
231
232
243 EventItemsIterator findInEvent(const std::string& search);
244
245
256 bool operator==(const LogEvent& other) const
257 {
258 return m_id == other.getId();
259 }
260
270 void SetOriginalId(int originalId);
271
281 void SetId(int newId);
282
287 const std::string& GetSource() const { return m_source; }
288
293 void SetSource(const std::string& source) { m_source = source; }
294
295 private:
296 int m_id;
298 std::string m_source;
299};
300
301} // namespace db
302
303#endif // DB_EVENT_HPP
C++20 concept definitions for LogViewer.
Represents a single, structured log event with key-value data.
Definition LogEvent.hpp:97
std::vector< std::pair< std::string, std::string > >::iterator EventItemsIterator
Iterator type for traversing event items.
Definition LogEvent.hpp:105
EventItems m_eventItems
The structured data of the event.
Definition LogEvent.hpp:297
void SetId(int newId)
Updates the event's ID (used during merge to reassign sequential IDs)
Definition LogEvent.cpp:90
EventItemsIterator findInEvent(const std::string &search)
Finds an iterator to the first item matching the search term.
Definition LogEvent.cpp:50
std::string m_source
Source identifier for multi-file merge.
Definition LogEvent.hpp:298
const EventItems & getEventItems() const
Gets a const reference to the event's data items.
Definition LogEvent.cpp:20
LogEvent(int id, Args &&... args)
Template constructor with perfect forwarding.
Definition LogEvent.hpp:138
void SetSource(const std::string &source)
Sets the source identifier for this event.
Definition LogEvent.hpp:293
int getId() const
Gets the unique ID of the event.
Definition LogEvent.cpp:15
const std::vector< std::string > findAllByKey(std::string_view key) const
Finds all values by its key in the event's items.
Definition LogEvent.cpp:38
const std::string & GetSource() const
Gets the source identifier for this event.
Definition LogEvent.hpp:287
bool operator==(const LogEvent &other) const
Equality comparison operator.
Definition LogEvent.hpp:256
int m_id
Unique event identifier.
Definition LogEvent.hpp:296
std::vector< std::pair< std::string, std::string > >::const_iterator EventItemsConstIterator
Const iterator type for traversing event items.
Definition LogEvent.hpp:109
LogEvent(int id, std::initializer_list< std::pair< std::string, std::string > > items)
Constructs a LogEvent from an initializer list.
Definition LogEvent.hpp:157
const std::string findByKey(std::string_view key) const
Finds a value by its key in the event's items.
Definition LogEvent.cpp:25
void SetOriginalId(int originalId)
Sets the original ID before merge (stores as event data)
Definition LogEvent.cpp:72
std::vector< std::pair< std::string, std::string > > EventItems
A collection of key-value pairs representing event data (eventFieldName, data).
Definition LogEvent.hpp:101
Matches types that can be constructed from the given arguments.
Definition Concepts.hpp:45
Database and data model components for the LogViewer application.
Definition EventsContainer.cpp:17