sparrow 1.0.0
Loading...
Searching...
No Matches
sparrow::key_value_view Class Reference

Custom view for lazily extracting key-value pairs from a binary buffer. More...

#include <metadata.hpp>

Inheritance diagram for sparrow::key_value_view:
[legend]
Collaboration diagram for sparrow::key_value_view:
[legend]

Public Member Functions

SPARROW_API key_value_view (const char *ptr)
 Constructs a view over the given binary metadata buffer.
 
SPARROW_API key_value_view_iterator cbegin () const
 Gets const iterator to the beginning of the metadata pairs.
 
SPARROW_API key_value_view_iterator begin () const
 Gets iterator to the beginning of the metadata pairs.
 
SPARROW_API key_value_view_iterator cend () const
 Gets const iterator to the end of the metadata pairs.
 
SPARROW_API key_value_view_iterator end () const
 Gets iterator to the end of the metadata pairs.
 
SPARROW_API size_t size () const
 Gets the number of key-value pairs in the metadata.
 

Detailed Description

Custom view for lazily extracting key-value pairs from a binary buffer.

This class provides a range-like interface over metadata stored in binary format. It implements lazy extraction, meaning key-value pairs are only parsed when accessed through iteration. This approach is memory-efficient and allows processing of large metadata sets without upfront parsing overhead.

The binary format consists of:

  • int32_t: number of key-value pairs
  • For each pair:
    • int32_t: key length
    • char[]: key data
    • int32_t: value length
    • char[]: value data
Precondition
Input buffer must be valid and properly formatted
Buffer must remain valid for the lifetime of the view and its iterators
Postcondition
Provides range-compatible interface for metadata iteration
Supports both const and non-const iteration

Definition at line 220 of file metadata.hpp.

Constructor & Destructor Documentation

◆ key_value_view()

SPARROW_API sparrow::key_value_view::key_value_view ( const char * ptr)

Constructs a view over the given binary metadata buffer.

Parameters
ptrPointer to the start of the binary metadata buffer
Precondition
ptr must point to a valid binary metadata buffer
Buffer must contain a valid int32_t count followed by the metadata pairs
Postcondition
View is ready for iteration over the metadata pairs
size() returns the number of pairs in the buffer

Member Function Documentation

◆ begin()

SPARROW_API key_value_view_iterator sparrow::key_value_view::begin ( ) const
nodiscard

Gets iterator to the beginning of the metadata pairs.

Returns
Iterator pointing to the first key-value pair
Postcondition
Returned iterator is valid for reading metadata pairs
Iterator can be used with standard algorithms

◆ cbegin()

SPARROW_API key_value_view_iterator sparrow::key_value_view::cbegin ( ) const
nodiscard

Gets const iterator to the beginning of the metadata pairs.

Returns
Const iterator pointing to the first key-value pair
Postcondition
Returned iterator is valid for reading metadata pairs
Iterator can be used with standard algorithms

◆ cend()

SPARROW_API key_value_view_iterator sparrow::key_value_view::cend ( ) const
nodiscard

Gets const iterator to the end of the metadata pairs.

Returns
Const iterator pointing past the last key-value pair
Postcondition
Returned iterator marks the end of the range
Can be compared with begin() for range-based operations

◆ end()

SPARROW_API key_value_view_iterator sparrow::key_value_view::end ( ) const
nodiscard

Gets iterator to the end of the metadata pairs.

Returns
Iterator pointing past the last key-value pair
Postcondition
Returned iterator marks the end of the range
Can be compared with begin() for range-based operations

◆ size()

SPARROW_API size_t sparrow::key_value_view::size ( ) const
nodiscard

Gets the number of key-value pairs in the metadata.

Returns
Number of metadata pairs
Postcondition
Returns non-negative count of pairs
Value corresponds to the count stored in the buffer header

The documentation for this class was generated from the following file: