9 #include <QCryptographicHash>
10 #include "qbigint.hpp"
13 #include <QtCore/QtGlobal>
15 #if defined(WINDOWS_QBLOCK)
16 # define QBLOCK_EXPORT Q_DECL_EXPORT
18 #define QBLOCK_EXPORT Q_DECL_IMPORT
62 template<
class obj_type>
void append(
const obj_type& obj)
71 template<QCryptographicHash::Algorithm hashty>
c_array hash(
void)
const
79 template<
class obj_type>
void from_object(
const obj_type& obj)
83 obj.serialize(buffer);
94 return obj_type(buffer);
104 template<
typename max_lenght>
115 out<<static_cast<max_lenght>(obj.
size());
116 out<<static_cast<c_array>(obj);
128 auto var=
static_cast<c_array*
>(&obj);
194 for(
const auto& v:val)var.
push_back(T::from_(v));
202 return ((type_type)val.
toObject()[
"type"].toInt());
220 out<<static_cast<size_type>(ptr_vector.
size());
221 for(
const auto& v: ptr_vector)v->serialize(out);
231 for(
auto i=0;i<length_;i++)
233 ptr_vector.
push_back(obj_type::template from_<QDataStream>(in));
Byte Array that takes care of storing the objects in serialized form.
Definition: carray.hpp:28
friend QDataStream & operator>>(QDataStream &in, c_array &obj)
Read from datastream to the obj.
static c_array fromHexString(QString hash)
The data from an "0x..." hex encoded string.
friend QDataStream & operator<<(QDataStream &out, const c_array &obj)
Write to the data stream the obj data.
c_array(const QByteArray &var)
Copy constructor from ByteArray.
Definition: carray.hpp:34
void append(const obj_type &obj)
Append obj data to the end. For objects that implement QDataStream & operator <<.
Definition: carray.hpp:62
c_array hash(void) const
Get the hash of the data.
Definition: carray.hpp:71
obj_type to_object(void)
Return Object from serialized data. Objects that implement the constructor(QDataStream &in)
Definition: carray.hpp:90
void from_object(const obj_type &obj)
Append obj data. Objects that have the serialize(QDataStream) function.
Definition: carray.hpp:79
c_array(const QJsonValue &val)
Constructor from a json value hex string.
QString toHexString(void) const
The "0x..." hex encoded string of the data.
Byte Array with fixed length.
Definition: carray.hpp:106
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:112
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:123
void order_list(pvector< obj_type > &ptr_vector)
Order a Container of shared pointer to objects Normally ordered by type.
Definition: carray.hpp:241
type_type get_type(const QJsonValue &val)
Definition: carray.hpp:200
pvector< const obj_type > deserialize_list(QDataStream &in)
Definition: carray.hpp:226
pvector< const T > get_T(const QJsonArray &val)
Definition: carray.hpp:191
void serialize_list(QDataStream &out, const pvector< const obj_type > &ptr_vector)
append to the datastream the serialized form of objects in a container
Definition: carray.hpp:217
Definition: qbigint.hpp:7
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