11 #ifndef SERIALIZABLE_H_ 12 #define SERIALIZABLE_H_ 32 ssize_t
print(uint8_t *to,
size_t buf_sz)
const;
35 ssize_t
print(
size_t indent, uint8_t *to,
size_t buf_sz)
const;
47 virtual ssize_t
parse(
const uint8_t *from,
size_t msg_sz) = 0;
59 virtual ssize_t
write(uint8_t *to,
size_t buf_sz)
const = 0;
61 virtual ssize_t
length()
const;
66 uint8_t getErrorCode()
const;
69 uint8_t getErrorSubCode()
const;
72 const uint8_t* getError()
const;
75 size_t getErrorLength()
const;
83 static ssize_t
_print(
size_t indent, uint8_t **to,
size_t *buf_left,
const char* format, ...);
95 virtual ssize_t
doPrint(
size_t indent, uint8_t **to,
size_t *buf_sz)
const = 0;
98 void setError(uint8_t err, uint8_t suberr,
const uint8_t *data,
size_t data_len);
112 #endif // SERIALIZABLE_H_ virtual ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const =0
Print implementation.
virtual ssize_t length() const
Get size in bytes required to serialize the object.
static ssize_t _print(size_t indent, uint8_t **to, size_t *buf_left, const char *format,...)
Print helper.
bool hasError() const
Check if error information available.
~Serializable()
Destroy the Serializable:: Serializable object.
The serializable base class.
ssize_t print(uint8_t *to, size_t buf_sz) const
Print the Serializable object as human readable string.
virtual ssize_t write(uint8_t *to, size_t buf_sz) const =0
Serialize the object and write to buffer.
void setLogger(BgpLogHandler *logger)
Replace logger for this object.
void setError(uint8_t err, uint8_t suberr, const uint8_t *data, size_t data_len)
Set the error information.
virtual ssize_t parse(const uint8_t *from, size_t msg_sz)=0
Deserialize the object from buffer.
Serializable(BgpLogHandler *logger)
Construct a new Serializable:: Serializable object.
void forwardParseError(const Serializable &other)
Forward error information from other Serializable object.