Heart 1.3.842.34c2ab5
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-2024 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
12namespace QH {
13
15 reset();
16}
17
18bool 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
26 size = 0;
27 command = 0;
28 triggerHash = 0;
29 hash = 0;
30 unusedSpace1 = 0;
31 unusedSpace2 = 0;
32 unusedSpace3 = 0;
33
34}
35
36QString 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}
static unsigned int maximumSize()
maximumSize This method return maximu size of pacakge. If pacakge large the maximum size then package...
Definition package.cpp:49
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
unsigned char unusedSpace3
Definition header.h:51
bool isValid() const
isValid This method check header size and compare commands.
Definition header.cpp:18
const unsigned char headerVersion
headerVersion This is version of the header struct
Definition header.h:28
unsigned int hash
hash This is unique id of a package. id calc with CRC32 function for Qt implementation.
Definition header.h:38
unsigned int triggerHash
triggerHash This is hash of request package that package has been responded. The server should write ...
Definition header.h:44
QString toString() const
toString This method return string of header of package.
Definition header.cpp:36
unsigned int size
size This is size of package data (exclude header size).
Definition header.h:33
void reset()
reset This method reset all data and set for header invalid status.
Definition header.cpp:25
unsigned short command
command of package for more information see the AbstractData::toPackage method.
Definition header.h:23
unsigned long long unusedSpace1
unusedSpace This is unused space for changes of the header struct in the future.
Definition header.h:49
Header()
Header default constructor.
Definition header.cpp:14
unsigned long long unusedSpace2
Definition header.h:50