@@ -25,7 +25,7 @@ class CaliperMetadataAccessInterface;
25
25
// / a _reference entry_ (reference into the context tree) or an
26
26
// / _immediate entry_ (explicit key:value pair). Reference entries are
27
27
// / stored as context tree node pointer, immediate entries are stored as
28
- // / (attribute, value) pair.
28
+ // / (attribute node pointer , value) pair.
29
29
30
30
class Entry
31
31
{
@@ -34,12 +34,16 @@ class Entry
34
34
35
35
public:
36
36
37
+ // / @brief Maximum size in bytes of a packed entry
37
38
constexpr static size_t MAX_PACKED_SIZE = 30 ;
38
39
40
+ // / @brief Construct an empty Entry
39
41
constexpr Entry () : m_node(nullptr ) {}
40
42
43
+ // / @brief Construct a reference entry from \a node
41
44
Entry (Node* node) : m_node(node), m_value(node->data ()) {}
42
45
46
+ // / @brief Construct an immediate entry from \a attr, \a val
43
47
Entry (const Attribute& attr, const Variant& val) : m_node(attr.node()), m_value(val) {}
44
48
45
49
// / \brief Return context tree node pointer for reference entries.
@@ -79,8 +83,16 @@ class Entry
79
83
80
84
bool is_reference () const { return !empty () && !is_immediate (); }
81
85
86
+ // / @brief Write a compact binary serialization of the entry into \a buffer
87
+ // / @param buffer The target buffer. Must have at least \ref MAX_PACKED_SIZE bytes of free space.
88
+ // / @return The actual number of bytes written into \a buffer
82
89
size_t pack (unsigned char * buffer) const ;
83
90
91
+ // / @brief Deserialize a packed entry from \a buffer
92
+ // / @param db The %Caliper metadata (context tree nodes, attributes) associated with this entry.
93
+ // / @param buffer The source buffer. Must point to a packed entry.
94
+ // / @param inc Returns the number of bytes read from the source buffer.
95
+ // / @return The deserialized entry.
84
96
static Entry unpack (const CaliperMetadataAccessInterface& db, const unsigned char * buffer, size_t * inc);
85
97
86
98
friend bool operator == (const Entry&, const Entry&);
0 commit comments