mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
Change return value of OpaqueVal::DoSerialize.
Now it returns a broker::expected<broker::data>, instead of directly returning a broker::data before. This means that broker::data does no longer have to be abused to convey error information. In a way it would be kind of neat to have more fine-granular broker error types for this use-case - at the moment everything returns broker::ec::invalid_data, which seems to be the only reasonable choice.
This commit is contained in:
parent
53cde131e9
commit
e0f10fd6d3
6 changed files with 40 additions and 36 deletions
|
@ -64,7 +64,7 @@ private:
|
|||
/** Macro to insert into an OpaqueVal-derived class's declaration. */
|
||||
#define DECLARE_OPAQUE_VALUE(T) \
|
||||
friend class OpaqueMgr::Register<T>; \
|
||||
broker::data DoSerialize() const override; \
|
||||
broker::expected<broker::data> DoSerialize() const override; \
|
||||
bool DoUnserialize(const broker::data& data) override; \
|
||||
const char* OpaqueName() const override { return #T; } \
|
||||
static OpaqueVal* OpaqueInstantiate() { return new T(); }
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
* Reinstantiates a value from its serialized Broker representation.
|
||||
*
|
||||
* @param data Broker representation as returned by *Serialize()*.
|
||||
* @return unserialized instances with referecnce count at +1
|
||||
* @return unserialized instances with reference count at +1
|
||||
*/
|
||||
static OpaqueVal* Unserialize(const broker::data& data);
|
||||
|
||||
|
@ -107,15 +107,19 @@ protected:
|
|||
OpaqueVal() { }
|
||||
|
||||
/**
|
||||
* Must be overriden to provide a serialized version of the derived
|
||||
* class' state. Returns 'broker::none()' if serialization fails, or
|
||||
* is not supported.
|
||||
* Must be overridden to provide a serialized version of the derived
|
||||
* class' state.
|
||||
*
|
||||
* @return the serialized data or an error if serialization
|
||||
* isn't supported or failed.
|
||||
*/
|
||||
virtual broker::data DoSerialize() const = 0;
|
||||
virtual broker::expected<broker::data> DoSerialize() const = 0;
|
||||
|
||||
/**
|
||||
* Must be overriden to recreate the the derived class' state from a
|
||||
* serialization. Returns true if successfull.
|
||||
* Must be overridden to recreate the the derived class' state from a
|
||||
* serialization.
|
||||
*
|
||||
* @return true if successful.
|
||||
*/
|
||||
virtual bool DoUnserialize(const broker::data& data) = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue