ZeroBuf  0.5.0
Zero-copy, zero-serialize, zero-hassle protocol buffers
zerobuf::Vector< T > Class Template Reference

STL-like vector abstraction for dynamic arrays in a zerobuf. More...

#include <Vector.h>

+ Collaboration diagram for zerobuf::Vector< T >:

Classes

class  Iterator
 Forward iterator for Vector< T > More...
 

Public Types

using element_type = T
 
using iterator = Iterator< Vector< T >>
 
using const_iterator = Iterator< const Vector< T >>
 

Public Member Functions

 Vector (Allocator &alloc, size_t index)
 
bool empty () const
 
uint64_t size () const
 
void clear ()
 Empty the vector. More...
 
T * data ()
 
const T * data () const
 
void resize (size_t size)
 Resize the vector to new size; keeps elements untouched. More...
 
bool operator== (const Vector &rhs) const
 
bool operator!= (const Vector &rhs) const
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 
template<class Q = T>
const std::enable_if<!std::is_base_of< Zerobuf, Q >::value, Q >::type & operator[] (const size_t index) const
 
template<class Q = T>
std::enable_if<!std::is_base_of< Zerobuf, Q >::value, Q >::type & operator[] (const size_t index)
 
template<class Q = T>
const std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type & operator[] (const size_t index) const
 
template<class Q = T>
std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type & operator[] (const size_t index)
 
template<class Q = T>
void push_back (const typename std::enable_if< !std::is_base_of< Zerobuf, Q >::value, Q >::type &)
 Insert a builtin element at the end of the vector. More...
 
template<class Q = T>
void push_back (const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type &)
 Insert a Zerobuf-derived element at the end of the vector. More...
 
void reset (Allocator &alloc)
 
void compact (float)
 Remove unused memory from vector and all members. More...
 
template<class Q = T>
void fromJSON (const Json::Value &json, const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type *=nullptr)
 Update this vector of ZeroBufs from its JSON representation. More...
 
template<class Q = T>
void fromJSON (const Json::Value &json, const typename std::enable_if< std::is_enum< Q >::value, Q >::type *=nullptr)
 Update this vector of enums from its JSON representation. More...
 
template<class Q = T>
void fromJSON (const Json::Value &json, const typename std::enable_if< std::is_arithmetic< Q >::value, Q >::type *=nullptr)
 Update this vector of arithmetics from its JSON representation. More...
 
template<class Q = T>
void fromJSON (const Json::Value &json, const typename std::enable_if< std::is_same< Q, servus::uint128_t >::value, Q >::type *=nullptr)
 Update this vector of uint128_t from its JSON representation. More...
 
template<class Q = T>
void toJSON (Json::Value &json, const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type *=nullptr) const
 
template<class Q = T>
void toJSON (Json::Value &json, const typename std::enable_if< std::is_enum< Q >::value, Q >::type *=nullptr) const
 
template<class Q = T>
void toJSON (Json::Value &json, const typename std::enable_if< std::is_arithmetic< Q >::value, Q >::type *=nullptr) const
 
template<class Q = T>
void toJSON (Json::Value &json, const typename std::enable_if< std::is_same< Q, servus::uint128_t >::value, Q >::type *=nullptr) const
 
template<class Q = T>
void fromJSONBinary (const Json::Value &json, const typename std::enable_if< std::is_pod< Q >::value, Q >::type *=nullptr)
 Update this vector from its JSON, base64-encoded representation. More...
 
template<class Q = T>
void toJSONBinary (Json::Value &json, const typename std::enable_if< std::is_pod< Q >::value, Q >::type *=nullptr) const
 
template<class Q >
void push_back (const typename std::enable_if<!std::is_base_of< Zerobuf, Q >::value, Q >::type &value)
 

Detailed Description

template<class T>
class zerobuf::Vector< T >

STL-like vector abstraction for dynamic arrays in a zerobuf.

Parameters
Telement type

Definition at line 29 of file types.h.

Member Function Documentation

template<class T >
Vector< T >::const_iterator zerobuf::Vector< T >::begin ( ) const
inline
Returns
an immutable iterator to the first element.

Definition at line 272 of file Vector.h.

Referenced by zerobuf::Vector< T >::data().

+ Here is the caller graph for this function:

template<class T >
Vector< T >::iterator zerobuf::Vector< T >::begin ( )
inline
Returns
a mutable iterator to the first element.

Definition at line 284 of file Vector.h.

template<class T >
void zerobuf::Vector< T >::clear ( )
inline

Empty the vector.

Definition at line 258 of file Vector.h.

Referenced by zerobuf::Vector< T >::size().

+ Here is the caller graph for this function:

template<class T >
void zerobuf::Vector< T >::compact ( float  )
inline

Remove unused memory from vector and all members.

Definition at line 155 of file Vector.h.

References zerobuf::Vector< T >::data(), zerobuf::Vector< T >::fromJSON(), zerobuf::Vector< T >::fromJSONBinary(), zerobuf::Vector< T >::toJSON(), and zerobuf::Vector< T >::toJSONBinary().

+ Here is the call graph for this function:

template<class T >
T* zerobuf::Vector< T >::data ( )
inline
Returns
The pointer to the current allocation of the vector

Definition at line 89 of file Vector.h.

Referenced by zerobuf::Vector< T >::compact(), zerobuf::Vector< T >::operator==(), zerobuf::Vector< T >::operator[](), and zerobuf::Vector< T >::toJSONBinary().

+ Here is the caller graph for this function:

template<class T >
const T* zerobuf::Vector< T >::data ( ) const
inline
Returns
The pointer to the current allocation of the vector

Definition at line 91 of file Vector.h.

References zerobuf::Vector< T >::begin(), zerobuf::Vector< T >::end(), zerobuf::Vector< T >::operator[](), zerobuf::Vector< T >::push_back(), zerobuf::Vector< T >::resize(), and zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
bool zerobuf::Vector< T >::empty ( ) const
inline
Returns
true if the vector contains no elements.

Definition at line 82 of file Vector.h.

template<class T >
Vector< T >::const_iterator zerobuf::Vector< T >::end ( ) const
inline
Returns
an immutable iterator to the past-the-end element.

Definition at line 278 of file Vector.h.

References zerobuf::Vector< T >::size().

Referenced by zerobuf::Vector< T >::data().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
Vector< T >::iterator zerobuf::Vector< T >::end ( )
inline
Returns
a mutable iterator to the past-the-end element.

Definition at line 290 of file Vector.h.

References zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::fromJSON ( const Json::Value &  json,
const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type *  = nullptr 
)
inline

Update this vector of ZeroBufs from its JSON representation.

Definition at line 399 of file Vector.h.

Referenced by zerobuf::Vector< T >::compact().

+ Here is the caller graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::fromJSON ( const Json::Value &  json,
const typename std::enable_if< std::is_enum< Q >::value, Q >::type *  = nullptr 
)
inline

Update this vector of enums from its JSON representation.

Definition at line 411 of file Vector.h.

template<class T >
template<class Q >
void zerobuf::Vector< T >::fromJSON ( const Json::Value &  json,
const typename std::enable_if< std::is_arithmetic< Q >::value, Q >::type *  = nullptr 
)
inline

Update this vector of arithmetics from its JSON representation.

Definition at line 426 of file Vector.h.

template<class T >
template<class Q >
void zerobuf::Vector< T >::fromJSON ( const Json::Value &  json,
const typename std::enable_if< std::is_same< Q, servus::uint128_t >::value, Q >::type *  = nullptr 
)
inline

Update this vector of uint128_t from its JSON representation.

Definition at line 440 of file Vector.h.

template<class T >
template<class Q >
void zerobuf::Vector< T >::fromJSONBinary ( const Json::Value &  json,
const typename std::enable_if< std::is_pod< Q >::value, Q >::type *  = nullptr 
)
inline

Update this vector from its JSON, base64-encoded representation.

Definition at line 510 of file Vector.h.

Referenced by zerobuf::Vector< T >::compact().

+ Here is the caller graph for this function:

template<class T >
bool zerobuf::Vector< T >::operator!= ( const Vector< T > &  rhs) const
inline
Returns
false if the two vectors are identical.

Definition at line 313 of file Vector.h.

References zerobuf::Vector< T >::operator[]().

+ Here is the call graph for this function:

template<class T >
bool zerobuf::Vector< T >::operator== ( const Vector< T > &  rhs) const
inline
Returns
true if the two vectors of builtins are identical.

Definition at line 296 of file Vector.h.

References zerobuf::Vector< T >::data().

+ Here is the call graph for this function:

template<class T >
template<class Q >
const std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type & zerobuf::Vector< T >::operator[] ( const size_t  index) const
inline
Returns
a builtin const element

Definition at line 322 of file Vector.h.

References zerobuf::Vector< T >::data(), and zerobuf::Vector< T >::size().

Referenced by zerobuf::Vector< T >::data(), zerobuf::Vector< T >::operator!=(), and zerobuf::Vector< T >::operator[]().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
template<class Q >
std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type & zerobuf::Vector< T >::operator[] ( const size_t  index)
inline
Returns
a builtin element

Definition at line 333 of file Vector.h.

References zerobuf::Vector< T >::data(), zerobuf::Vector< T >::operator[](), zerobuf::Vector< T >::push_back(), and zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
template<class Q = T>
const std::enable_if<std::is_base_of<Zerobuf, Q>::value, Q>::type& zerobuf::Vector< T >::operator[] ( const size_t  index) const
Returns
a Zerobuf-derived const element
template<class T >
template<class Q = T>
std::enable_if<std::is_base_of<Zerobuf, Q>::value, Q>::type& zerobuf::Vector< T >::operator[] ( const size_t  index)
Returns
a Zerobuf-derived element
template<class T >
template<class Q = T>
void zerobuf::Vector< T >::push_back ( const typename std::enable_if< !std::is_base_of< Zerobuf, Q >::value, Q >::type &  )

Insert a builtin element at the end of the vector.

Referenced by zerobuf::Vector< T >::data(), and zerobuf::Vector< T >::operator[]().

+ Here is the caller graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::push_back ( const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type &  value)
inline

Insert a Zerobuf-derived element at the end of the vector.

Definition at line 386 of file Vector.h.

template<class T >
void zerobuf::Vector< T >::resize ( size_t  size)
inline

Resize the vector to new size; keeps elements untouched.

Definition at line 265 of file Vector.h.

Referenced by zerobuf::Vector< T >::data().

+ Here is the caller graph for this function:

template<class T >
uint64_t zerobuf::Vector< T >::size ( ) const
inline
Returns
the number of elements in the vector.

Definition at line 84 of file Vector.h.

References zerobuf::Vector< T >::clear().

Referenced by zerobuf::Vector< T >::data(), zerobuf::Vector< T >::end(), zerobuf::Vector< T >::operator[](), and zerobuf::Vector< T >::toJSON().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::toJSON ( Json::Value &  json,
const typename std::enable_if< std::is_base_of< Zerobuf, Q >::value, Q >::type *  = nullptr 
) const
inline
Returns
the JSON representation of this vector of ZeroBufs.

Definition at line 455 of file Vector.h.

References zerobuf::Vector< T >::size().

Referenced by zerobuf::Vector< T >::compact().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::toJSON ( Json::Value &  json,
const typename std::enable_if< std::is_enum< Q >::value, Q >::type *  = nullptr 
) const
inline
Returns
the JSON representation of this vector of enums.

Definition at line 470 of file Vector.h.

References zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::toJSON ( Json::Value &  json,
const typename std::enable_if< std::is_arithmetic< Q >::value, Q >::type *  = nullptr 
) const
inline
Returns
the JSON representation of this vector of arithmetics.

Definition at line 483 of file Vector.h.

References zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::toJSON ( Json::Value &  json,
const typename std::enable_if< std::is_same< Q, servus::uint128_t >::value, Q >::type *  = nullptr 
) const
inline
Returns
the JSON representation of this vector of uint128_t.

Definition at line 496 of file Vector.h.

References zerobuf::Vector< T >::size().

+ Here is the call graph for this function:

template<class T >
template<class Q >
void zerobuf::Vector< T >::toJSONBinary ( Json::Value &  json,
const typename std::enable_if< std::is_pod< Q >::value, Q >::type *  = nullptr 
) const
inline
Returns
the JSON representation of this vector, with base64 encoding.

Definition at line 520 of file Vector.h.

References zerobuf::Vector< T >::data().

Referenced by zerobuf::Vector< T >::compact().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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