Patronum
Loading...
Searching...
No Matches
PFeature.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#include "PFeature.h"
9
10#include <QDataStream>
11
12namespace Patronum {
13
14Feature::Feature(const QString &cmd, const QString &arg,
15 const QString &description, const QString &example) {
16 setCmd(cmd);
17 setArg(arg);
20}
21
22QString Feature::cmd() const {
23 return _cmd;
24}
25
26void Feature::setCmd(const QString &cmd) {
27 _cmd = cmd;
28}
29
30QString Feature::arg() const {
31 return _arg;
32}
33
34void Feature::setArg(const QString &arg) {
35 _arg = arg;
36}
37
38QString Feature::description() const {
39 return _description;
40}
41
42void Feature::setDescription(const QString &description) {
43 _description = description;
44}
45
46QString Feature::example() const {
47 return _example;
48}
49
50void Feature::setExample(const QString &example) {
51 _example = example;
52}
53
54QString Feature::toString() const {
55 if (_description.size())
56 return _cmd + ": " + _description;
57
58 return _cmd;
59}
60
61QDataStream &operator<<(QDataStream &stream, const Feature &obj) {
62 stream << obj._cmd << obj._arg;
63
64 return stream;
65}
66
67QDataStream &operator>>(QDataStream &stream, Feature &obj) {
68 decltype (obj._cmd) cmd;
69 stream >> cmd >> obj._arg;
70 obj.setCmd(cmd);
71
72 return stream;
73}
74
75bool operator==(const Feature &left, const Feature &right) {
76 return left.cmd() == right.cmd();
77}
78
79uint qHash(const Feature &feature) {
80 return qHash(feature.cmd());
81}
82
83}
84
85
The Feature class it is atomic type for describe service command.
Definition PFeature.h:22
void setCmd(const QString &cmd)
setCmd This method set new value of the command.
Definition PFeature.cpp:26
QString description() const
description This method return description message of the command. This string display in a terminal ...
Definition PFeature.cpp:38
void setArg(const QString &arg)
setArg This method sets arg value for this object.
Definition PFeature.cpp:34
void setExample(const QString &example)
setExample This method sets a new example.
Definition PFeature.cpp:50
void setDescription(const QString &description)
setDescription This method sets description for command.
Definition PFeature.cpp:42
QString cmd() const
cmd This method return command of the feature.
Definition PFeature.cpp:22
QString arg() const
arg This method return argument value. The argument value has a qvariant type, so this object maybe h...
Definition PFeature.cpp:30
QString example() const
example This is exmaple of using this command.
Definition PFeature.cpp:46
QString toString() const
toString This is general method of the converting command to string.
Definition PFeature.cpp:54
The Patronum namespace - It is main name space of Patronum Library. The Patronum library support the ...
uint qHash(const Feature &feature)
Definition PFeature.cpp:79
bool operator==(const Feature &left, const Feature &right)
Definition PFeature.cpp:75
QDataStream & operator>>(QDataStream &stream, Feature &obj)
Definition PFeature.cpp:67
QDataStream & operator<<(QDataStream &stream, const Feature &obj)
Definition PFeature.cpp:61