qi3pc 0.4.1
Qt based library to communicate with i3wm via its IPC API
Loading...
Searching...
No Matches
qi3pc::ParseError Struct Reference

The Err struct contains the attributes of a parsing error from i3wm when trying to run an unparsable command;. More...

#include <qi3pc.h>

Public Member Functions

QString toString () const
 Convert to a json like string.
bool operator== (const ParseError &other) const
 Memberwise comparison of this ParseError and another.

Static Public Member Functions

static std::optional< ParseErrorFromJSON (const QJsonObject &json)
 Build an optional ParseError from a QJsonObject.

Public Attributes

QString error
 Human readble error message.
QString input
 The command that failed to run.
QString errorPosition
 The position where the error was detected in the input.

Private Types

using QStringMemberPtr = QString ParseError::*
 QString member pointer of ParseError.

Static Private Attributes

static constexpr auto _MEMBERS
 Mapping of i3wm's parse error reply's attributes to members of ParseError.

Detailed Description

The Err struct contains the attributes of a parsing error from i3wm when trying to run an unparsable command;.

This is the processed reply for a qi3pc::IpcType::Command reply.

Definition at line 170 of file qi3pc.h.

Member Typedef Documentation

◆ QStringMemberPtr

using qi3pc::ParseError::QStringMemberPtr = QString ParseError::*
private

QString member pointer of ParseError.

Definition at line 219 of file qi3pc.h.

Member Function Documentation

◆ toString()

QString qi3pc::ParseError::toString ( ) const

Convert to a json like string.

Returns
QString representation of the ParseError

The resulting string is in the form "{member:'member'}{member2:'member2'}".

Note
This is NOT valid JSON. Notice the lack of commas between elements.

Definition at line 760 of file qi3pc.cpp.

References _MEMBERS.

◆ operator==()

bool qi3pc::ParseError::operator== ( const ParseError & other) const

Memberwise comparison of this ParseError and another.

Parameters
otherThe second object to compare.
Returns
whether all members are equal

Definition at line 753 of file qi3pc.cpp.

References error, errorPosition, and input.

◆ FromJSON()

qi3pc::Error qi3pc::ParseError::FromJSON ( const QJsonObject & json)
static

Build an optional ParseError from a QJsonObject.

Parameters
jsonJSON object with structure matching ParseError::_MEMBERS.
Returns
A ParseError or a nullopt.

At least "parse_error" should be in the JSON. If it's not present, a nullopt is returned. If only that key and none of the other checked ones exist, a default initialized ParseError is returned. Otherwise for each of the checked keys found, the corresponding member is initialized. Values in the JSON are expected to be of string type.

Definition at line 737 of file qi3pc.cpp.

References _MEMBERS.

Member Data Documentation

◆ error

QString qi3pc::ParseError::error

Human readble error message.

Definition at line 172 of file qi3pc.h.

◆ input

QString qi3pc::ParseError::input

The command that failed to run.

Definition at line 175 of file qi3pc.h.

◆ errorPosition

QString qi3pc::ParseError::errorPosition

The position where the error was detected in the input.

This is a string of the same length as the input. Spaces ' ' represent the parsable part of the input. Starting from where the error was detected, the rest is represented with carets '^'.

Definition at line 185 of file qi3pc.h.

◆ _MEMBERS

auto qi3pc::ParseError::_MEMBERS
inlinestaticconstexprprivate
Initial value:
= std::to_array<std::pair<const char*, QStringMemberPtr>>
({
{"error", &ParseError::error},
{"input", &ParseError::input},
{"errorposition", &ParseError::errorPosition}
})
QString errorPosition
The position where the error was detected in the input.
Definition qi3pc.h:185
QString input
The command that failed to run.
Definition qi3pc.h:175
QString error
Human readble error message.
Definition qi3pc.h:172

Mapping of i3wm's parse error reply's attributes to members of ParseError.

Definition at line 222 of file qi3pc.h.


The documentation for this struct was generated from the following files: