EventQuery Class
(LogManager::EventQuery)The EventQuery class contains the arguments for querying events from the database using LogReader. More...
Header: | #include <LogManager/EventQuery.h> |
Public Types
class | Condition |
enum | Flags { None, NewestFirst, TimeRangeBeginExclusive, TimeRangeEndExclusive, UseLogstampForTimeRange } |
enum | MatchType { Exact, Wildcard } |
Public Functions
EventQuery & | AddDataCondition(const std::string &key, std::string value, MatchType type = Exact) |
EventQuery & | AddFlag(EventQuery::Flags flag) |
EventQuery & | AddSenderCondition(std::string value, MatchType type = Exact) |
std::optional<unsigned> | GetCodeMask() const |
const std::map<std::string, std::vector<Condition> > & | GetDataConditions() const |
Flags | GetFlags() const |
std::optional<unsigned> | GetLimit() const |
std::optional<unsigned> | GetOffset() const |
const std::vector<Condition> & | GetSenderConditions() const |
std::optional<double> | GetTimeRangeBegin() const |
std::optional<double> | GetTimeRangeEnd() const |
bool | HasConditions() const |
bool | HasFlag(Flags flag) const |
EventQuery & | RemoveFlag(Flags flag) |
EventQuery & | SetCodeMask(std::optional<unsigned int> codeMask) |
EventQuery & | SetFlags(Flags flags) |
EventQuery & | SetLimit(std::optional<unsigned int> limit) |
EventQuery & | SetOffset(std::optional<unsigned int> offset) |
EventQuery & | SetTimeRangeBegin(std::optional<double> timeRangeBegin) |
EventQuery & | SetTimeRangeEnd(std::optional<double> timeRangeEnd) |
Detailed Description
The EventQuery class contains the arguments for querying events from the database using LogReader.
Usage
Create the query object and set the desired parameters. Then pass it to LogReader::ReadEvents().
Example
EventQuery query; query.SetTimeRangeBegin(1234567890) .SetTimeRangeEnd(1234567891) .SetCodeMask(0x00000001) .SetLimit(100) .SetOffset(0) .AddFlag(EventQuery::NewestFirst) .AddSenderCondition("sender", EventQuery::Wildcard) .AddDataCondition("key", "value", EventQuery::Exact); auto result = logReader->ReadEvents(query);
All arguments are optional. An empty query will return all events in the database.
See also LogReader::ReadEvents() and Event::code.
Member Type Documentation
enum EventQuery::Flags
Flags used to control the query.
Constant | Value | Description |
---|---|---|
LogManager::EventQuery::None | 0 | No flags. |
LogManager::EventQuery::NewestFirst | 1 | Return newest events first. |
LogManager::EventQuery::TimeRangeBeginExclusive | 2 | Use > instead of >= when comparing timeRangeBegin. |
LogManager::EventQuery::TimeRangeEndExclusive | 4 | Use < instead of <= when comparing timeRangeEnd. |
LogManager::EventQuery::UseLogstampForTimeRange | 8 | Use Event::logstampSec instead of timestampSec for timeRangeBegin and timeRangeEnd. |
enum EventQuery::MatchType
The type of match to use when comparing strings.
Constant | Value | Description |
---|---|---|
LogManager::EventQuery::Exact | 0 | The string must match exactly. |
LogManager::EventQuery::Wildcard | 1 | The string may contain wildcards. |
Member Function Documentation
EventQuery &EventQuery::AddDataCondition(const std::string &key, std::string value, MatchType type = Exact)
Adds a event data condition to the query.
EventQuery &EventQuery::AddFlag(EventQuery::Flags flag)
Adds the given flag to the query.
EventQuery &EventQuery::AddSenderCondition(std::string value, MatchType type = Exact)
Adds a event sender condition to the query.
std::optional<unsigned> EventQuery::GetCodeMask() const
Returns only event codes allowed by the bitmask.
const std::map<std::string, std::vector<Condition> > &EventQuery::GetDataConditions() const
Returns the list of event data conditions.
Flags EventQuery::GetFlags() const
Returns the flags set to the query.
std::optional<unsigned> EventQuery::GetLimit() const
Returns the maximum number of events the query should return. Same as SQL LIMIT.
std::optional<unsigned> EventQuery::GetOffset() const
Returns the offset of the query. Same as SQL OFFSET. Use together with limit to return data in chuncks or pages.
const std::vector<Condition> &EventQuery::GetSenderConditions() const
Returns the list of event sender conditions.
std::optional<double> EventQuery::GetTimeRangeBegin() const
Returns the lower bound of the x-axis (timestamp). When empty, query start from the beginning of the log.
std::optional<double> EventQuery::GetTimeRangeEnd() const
Returns the upper bound of the x-axis (timestamp). When empty, queries until the end of the log.
bool EventQuery::HasConditions() const
Returns if the query has any conditions set.
bool EventQuery::HasFlag(Flags flag) const
Returns if the query has the given flag set.
EventQuery &EventQuery::RemoveFlag(Flags flag)
Removes the given flag from the query.
EventQuery &EventQuery::SetCodeMask(std::optional<unsigned int> codeMask)
Sets only event codes allowed by the bitmask. Useful for example to filter out reprise events.
EventQuery &EventQuery::SetFlags(Flags flags)
Sets the flags to the query.
EventQuery &EventQuery::SetLimit(std::optional<unsigned int> limit)
Sets the maximum number of events the query should return. Same as SQL LIMIT.
EventQuery &EventQuery::SetOffset(std::optional<unsigned int> offset)
Sets the offset of the query. Same as SQL OFFSET. Use together with limit to return data in chuncks or pages.
EventQuery &EventQuery::SetTimeRangeBegin(std::optional<double> timeRangeBegin)
Sets the lower bound of the timestampSec. When empty, query start from the beginning of the log.
EventQuery &EventQuery::SetTimeRangeEnd(std::optional<double> timeRangeEnd)
Sets the upper bound of the timestampSec. When empty, queries until the end of the log.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.