Heart
1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Toggle main menu visibility
Loading...
Searching...
No Matches
universaldata.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2023-2025 QuasarApp.
3
* Distributed under the GPLv3 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 "
universaldata.h
"
9
10
11
namespace
QH
{
12
namespace
PKG
{
13
14
UniversalData::UniversalData
()
15
{
16
17
}
18
19
void
UniversalData::setValue
(
int
key,
const
QVariant &
value
) {
20
_data[key] =
value
;
21
}
22
23
const
QVariant &
UniversalData::value
(
int
key,
const
QVariant &defaultVal)
const
{
24
25
auto
nonConstPtr =
const_cast<
QHash<int, QVariant>*
>
(&_data);
26
if
(!nonConstPtr)
27
return
defaultVal;
28
29
if
(nonConstPtr->contains(key)) {
30
return
nonConstPtr->operator[](key);
31
}
32
33
return
defaultVal;
34
}
35
36
QVariant *
UniversalData::ref
(
int
key) {
37
38
if
(_data.contains(key)) {
39
return
&_data.operator[](key);
40
}
41
42
return
nullptr
;
43
}
44
45
QDataStream &
UniversalData::fromStream
(QDataStream &stream) {
46
47
stream >> _data;
48
49
return
stream;
50
}
51
52
QDataStream &
UniversalData::toStream
(QDataStream &stream)
const
{
53
stream << _data;
54
55
return
stream;
56
}
57
}
58
}
QH::PKG::UniversalData::setValue
void setValue(int key, const QVariant &value)
setValue This method sets new value for the filed. Works like a insert method of the QMap
Definition
universaldata.cpp:19
QH::PKG::UniversalData::UniversalData
UniversalData()
Definition
universaldata.cpp:14
QH::PKG::UniversalData::value
const QVariant & value(int key, const QVariant &defaultVal={}) const
value this method return value of the key.
Definition
universaldata.cpp:23
QH::PKG::UniversalData::toStream
QDataStream & toStream(QDataStream &stream) const override final
fromStream This method should be write all members of the current object to the stream object.
Definition
universaldata.cpp:52
QH::PKG::UniversalData::fromStream
QDataStream & fromStream(QDataStream &stream) override final
fromStream This method should be read all bytes from the stream object and full the current object.
Definition
universaldata.cpp:45
QH::PKG::UniversalData::ref
QVariant * ref(int key)
ref This method return pointer to the object If this object is not exists return nullptr
Definition
universaldata.cpp:36
QH::PKG
The PKG namesapce - this namespace contains all default packages of the Heart library....
Definition
heart.h:211
QH
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition
heart.cpp:13
universaldata.h
src
public
packages
universaldata.cpp
Generated by
1.18.0