7 #ifndef ZEROBUF_ZEROBUF_H 8 #define ZEROBUF_ZEROBUF_H 10 #include <servus/serializable.h> 11 #include <servus/uint128_t.h> 12 #include <zerobuf/Allocator.h> 14 #include <zerobuf/json.h> 15 #include <zerobuf/types.h> 27 class Zerobuf :
public servus::Serializable
47 ZEROBUF_API
virtual void compact(
float threshold = 0.1f);
56 ZEROBUF_API Zerobuf&
operator=(Zerobuf&& rhs);
59 ZEROBUF_API
bool operator==(
const Zerobuf& rhs)
const;
62 ZEROBUF_API
bool operator!=(
const Zerobuf& rhs)
const;
65 ZEROBUF_API
void reset(AllocatorPtr allocator);
68 ZEROBUF_API
void check()
const;
71 ZEROBUF_API
explicit Zerobuf(AllocatorPtr alloc);
77 ZEROBUF_API
const Allocator& getAllocator()
const;
80 ZEROBUF_API
void _copyZerobufArray(
const void* data,
size_t size,
83 ZEROBUF_API
virtual void _parseJSON(
const Json::Value& json);
84 ZEROBUF_API
virtual void _createJSON(Json::Value& json)
const;
85 ZEROBUF_API
friend void fromJSON(
const Json::Value&, Zerobuf&);
86 ZEROBUF_API
friend void toJSON(
const Zerobuf&, Json::Value&);
88 ZEROBUF_API
bool _fromBinary(
const void* data,
const size_t size)
override;
91 AllocatorPtr _allocator;
94 Zerobuf(
const Zerobuf&
zerobuf) =
delete;
96 ZEROBUF_API Data _toBinary()
const final;
97 ZEROBUF_API
bool _fromJSON(
const std::string& json)
final;
98 ZEROBUF_API std::string _toJSON()
const final;
101 inline std::ostream& operator<<(std::ostream& os,
const Zerobuf&
zerobuf)
103 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.
bool operator==(const Zerobuf &rhs) const
virtual size_t getZerobufNumDynamics() const =0
bool operator!=(const Zerobuf &rhs) const
virtual size_t getZerobufStaticSize() const =0
Allocator base class and interface.
Base class for all Zerobuf serializable objects.
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.