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 _id = qHash(_cmd);
29}
30
31QString Feature::arg() const {
32 return _arg;
33}
34
35void Feature::setArg(const QString &arg) {
36 _arg = arg;
37}
38
39QString Feature::description() const {
40 return _description;
41}
42
43void Feature::setDescription(const QString &description) {
44 _description = description;
45}
46
47QString Feature::example() const {
48 return _example;
49}
50
51void Feature::setExample(const QString &example) {
52 _example = example;
53}
54
55QString Feature::toString() const {
56 if (_description.size())
57 return _cmd + ": " + _description;
58
59 return _cmd;
60}
61
62unsigned int Feature::id() const {
63 return _id;
64}
65
66QDataStream &operator<<(QDataStream &stream, const Feature &obj) {
67 stream << obj._cmd << obj._arg;
68
69 return stream;
70}
71
72QDataStream &operator>>(QDataStream &stream, Feature &obj) {
73 decltype (obj._cmd) cmd;
74 stream >> cmd >> obj._arg;
75 obj.setCmd(cmd);
76
77 return stream;
78}
79
80bool operator==(const Feature &left, const Feature &right) {
81 return left.id() == right.id();
82}
83
84
85uint qHash(const Feature &feature) {
86 return feature.id();
87}
88
89}
90
91
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:39
void setArg(const QString &arg)
Definition PFeature.cpp:35
void setExample(const QString &example)
setExample This method sets a new example.
Definition PFeature.cpp:51
unsigned int id() const
id This method retun id of the feature. The id is qHash from command string.
Definition PFeature.cpp:62
void setDescription(const QString &description)
setDescription This method sets description for command.
Definition PFeature.cpp:43
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:31
QString example() const
example This is exmaple of using this command.
Definition PFeature.cpp:47
QString toString() const
toString This is general method of the converting command to string.
Definition PFeature.cpp:55
The Patronum namespace - It is main name space of Patronum Library. The Patronum library support the ...
uint qHash(const Feature &feature)
Definition PFeature.cpp:85
bool operator==(const Feature &left, const Feature &right)
Definition PFeature.cpp:80
QDataStream & operator>>(QDataStream &stream, Feature &obj)
Definition PFeature.cpp:72
QDataStream & operator<<(QDataStream &stream, const Feature &obj)
Definition PFeature.cpp:66