5 #include <QCryptographicHash>
13 #include <QtCore/QtGlobal>
15 #if defined(WINDOWS_QBLOCK)
16 #define QBLOCK_EXPORT Q_DECL_EXPORT
18 #define QBLOCK_EXPORT Q_DECL_IMPORT
64 template <
class obj_type>
void append(
const obj_type &obj)
73 template <QCryptographicHash::Algorithm hashty>
c_array hash(
void)
const
81 template <
class obj_type>
void from_object(
const obj_type &obj)
85 obj.serialize(buffer);
96 return obj_type(buffer);
113 out << static_cast<max_lenght>(obj.
size());
114 out << static_cast<c_array>(obj);
125 auto var =
static_cast<c_array *
>(&obj);
204 for (
const auto &v : val)
215 for (
const auto &v : val)
224 return ((type_type)val.
toObject()[
"type"].toInt());
241 out << static_cast<size_type>(ptrSet.
size());
242 for (
const auto &v : ptrSet)
253 for (
auto i = 0; i < length_; i++)
255 ptrSet.
insert(obj_type::template from_<QDataStream>(in));
265 std::sort(ptrVector.
begin(), ptrVector.
end(), [](
auto a,
auto b) { return *a < *b; });
Byte Array that takes care of storing the objects in serialized form.
Definition: carray.hpp:30
friend QDataStream & operator>>(QDataStream &in, c_array &obj)
Read from datastream to the obj.
Definition: carray.cpp:23
friend QDataStream & operator<<(QDataStream &out, const c_array &obj)
Write to the data stream the obj data.
Definition: carray.cpp:18
c_array(const QByteArray &var)
Copy constructor from ByteArray.
Definition: carray.hpp:36
void append(const obj_type &obj)
Append obj data to the end. For objects that implement QDataStream & operator <<.
Definition: carray.hpp:64
static c_array fromHexString(QString hash)
The data from an "0x..." hex encoded string.
Definition: carray.cpp:8
c_array hash(void) const
Get the hash of the data.
Definition: carray.hpp:73
obj_type to_object(void)
Return Object from serialized data. Objects that implement the constructor(QDataStream &in)
Definition: carray.hpp:92
void from_object(const obj_type &obj)
Append obj data. Objects that have the serialize(QDataStream) function.
Definition: carray.hpp:81
QString toHexString(void) const
The "0x..." hex encoded string of the data.
Definition: carray.cpp:12
Byte Array with fixed length.
Definition: carray.hpp:104
friend QDataStream & operator<<(QDataStream &out, const fl_array &obj)
Write to the data stream the obj data prepending the obj size as max_lenght type.
Definition: carray.hpp:110
friend QDataStream & operator>>(QDataStream &in, fl_array &obj)
Read from datastream to the obj. The size obj the object is read from the datastream.
Definition: carray.hpp:120
void orderList(pvector< obj_type > &ptrVector)
Order a Container of shared pointer to objects Normally ordered by type.
Definition: carray.hpp:263
pset< const obj_type > deserializeList(QDataStream &in)
Definition: carray.hpp:248
type_type get_type(const QJsonValue &val)
Definition: carray.hpp:222
void serializeList(QDataStream &out, const pset< const obj_type > &ptrSet)
append to the datastream the serialized form of objects in a container
Definition: carray.hpp:239
pset< const T > get_T(const QJsonArray &val)
Definition: carray.hpp:201
pvector< const T > get_Tvec(const QJsonArray &val)
Definition: carray.hpp:212
Definition: carray.hpp:22
const char * constData() const const
void resize(qsizetype newSize, char c)
qsizetype size() const const
QByteArray hash(QByteArrayView data, QCryptographicHash::Algorithm method)
QJsonObject toObject() const const
Container of ordered shared pointers.
Definition: carray.hpp:188
bool operator()(const std::shared_ptr< T > &a, const std::shared_ptr< T > &b) const
Definition: carray.hpp:189