7 #ifndef ZEROBUF_ZEROBUF_H
8 #define ZEROBUF_ZEROBUF_H
11 #include <zerobuf/Allocator.h>
12 #include <zerobuf/types.h>
13 #include <zerobuf/json.h>
14 #include <servus/serializable.h>
15 #include <servus/uint128_t.h>
28 class Zerobuf :
public servus::Serializable
48 ZEROBUF_API
virtual void compact(
float threshold = 0.1f );
57 ZEROBUF_API Zerobuf&
operator = ( Zerobuf&& rhs );
60 ZEROBUF_API
bool operator == (
const Zerobuf& rhs )
const;
63 ZEROBUF_API
bool operator != (
const Zerobuf& rhs )
const;
66 ZEROBUF_API
void reset( AllocatorPtr allocator );
69 ZEROBUF_API
void check()
const;
72 ZEROBUF_API
explicit Zerobuf( AllocatorPtr alloc );
78 ZEROBUF_API
const Allocator& getAllocator()
const;
81 ZEROBUF_API
void _copyZerobufArray(
const void* data,
size_t size,
84 ZEROBUF_API
virtual void _parseJSON(
const Json::Value& json );
85 ZEROBUF_API
virtual void _createJSON( Json::Value& json )
const;
86 ZEROBUF_API
friend void fromJSON(
const Json::Value&,Zerobuf& );
87 ZEROBUF_API
friend void toJSON(
const Zerobuf&, Json::Value& );
89 ZEROBUF_API
bool _fromBinary(
const void* data,
const size_t size )
override;
92 AllocatorPtr _allocator;
95 Zerobuf(
const Zerobuf&
zerobuf ) =
delete;
97 ZEROBUF_API Data _toBinary() const final;
98 ZEROBUF_API
bool _fromJSON( const
std::
string& json ) final;
99 ZEROBUF_API
std::
string _toJSON() const final;
102 inline
std::ostream& operator << (
std::ostream& os, const Zerobuf&
zerobuf )
104 return os <<
"\"" << zerobuf.getTypeName() <<
"\" : " << zerobuf.toJSON();
Defines export visibility macros for library ZeroBuf.
Zerobuf & operator=(const Zerobuf &rhs)
Assignment operator.
Zero-copy, zero-serialize, zero-hassle protocol buffers.
virtual size_t getZerobufStaticSize() const =0
bool operator==(const Zerobuf &rhs) const
bool operator!=(const Zerobuf &rhs) const
Allocator base class and interface.
Base class for all Zerobuf serializable objects.
virtual size_t getZerobufNumDynamics() const =0
virtual void notifyChanged()
Called if any data in this object has changed.
virtual void compact(float threshold=0.1f)
Remove unused holes from the zerobuf.