Heart
1.3.848.aa44c26
Heart is base back end library for your c++ Qt projects.
header.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 "
header.h
"
9
#include "
package.h
"
10
#include <QString>
11
12
namespace
QH
{
13
14
Header::Header
() {
15
reset
();
16
}
17
18
bool
Header::isValid
()
const
{
19
if
(
size
>
Package::maximumSize
()) {
20
return
false
;
21
}
22
return
command
&&
hash
&&
headerVersion
== 1 &&
unusedSpace1
== 0 &&
unusedSpace2
== 0 &&
unusedSpace3
== 0;
23
}
24
25
void
Header::reset
() {
26
size
= 0;
27
command
= 0;
28
triggerHash
= 0;
29
hash
= 0;
30
unusedSpace1
= 0;
31
unusedSpace2
= 0;
32
unusedSpace3
= 0;
33
34
}
35
36
QString
Header::toString
()
const
{
37
return
QString(
"Header description: HeaderVersion - %0, Size - %1, Command - %2, hash - %3, triggerHash - %4"
).
38
arg(
headerVersion
).arg(
size
).arg(
command
).arg(QString::number(
hash
, 16), QString::number(
triggerHash
, 16));
39
}
40
}
QH::Package::maximumSize
static unsigned int maximumSize()
maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package...
Definition
package.cpp:49
header.h
QH
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition
heart.cpp:13
package.h
QH::Header::unusedSpace3
unsigned char unusedSpace3
Definition
header.h:51
QH::Header::isValid
bool isValid() const
isValid This method check header size and compare commands.
Definition
header.cpp:18
QH::Header::headerVersion
const unsigned char headerVersion
headerVersion This is version of the header struct
Definition
header.h:28
QH::Header::hash
unsigned int hash
hash This is unique id of a package. id calc with CRC32 function for Qt implementation.
Definition
header.h:38
QH::Header::triggerHash
unsigned int triggerHash
triggerHash This is hash of request package that package has been responded. The server should write ...
Definition
header.h:44
QH::Header::toString
QString toString() const
toString This method return string of header of package.
Definition
header.cpp:36
QH::Header::size
unsigned int size
size This is size of package data (exclude header size).
Definition
header.h:33
QH::Header::reset
void reset()
reset This method reset all data and set for header invalid status.
Definition
header.cpp:25
QH::Header::command
unsigned short command
command of package for more information see the AbstractData::toPackage method.
Definition
header.h:23
QH::Header::unusedSpace1
unsigned long long unusedSpace1
unusedSpace This is unused space for changes of the header struct in the future.
Definition
header.h:49
QH::Header::Header
Header()
Header default constructor.
Definition
header.cpp:14
QH::Header::unusedSpace2
unsigned long long unusedSpace2
Definition
header.h:50
src
public
header.cpp
Generated by
1.9.8