Metall  v0.28
A persistent memory allocator for data-centric analytics
metall::json::key_value_pair< char_type, char_traits, Alloc > Class Template Reference

A class for holding a pair of JSON string (as its key) and JSON value (as its value). More...

#include </home/runner/work/metall/metall/include/metall/json/key_value_pair.hpp>

Public Types

using char_type = _char_type
 
using char_traits = _char_traits
 
using allocator_type = Alloc
 
using key_type = std::basic_string_view< char_type, char_traits >
 
using value_type = metall::json::value< allocator_type >
 
using size_type = std::size_t
 

Public Member Functions

 key_value_pair (key_type key, const value_type &value, const allocator_type &alloc=allocator_type())
 Constructor. More...
 
 key_value_pair (key_type key, value_type &&value, const allocator_type &alloc=allocator_type())
 Constructor. More...
 
 key_value_pair (const key_value_pair &other)
 Copy constructor. More...
 
 key_value_pair (const key_value_pair &other, const allocator_type &alloc)
 Allocator-extended copy constructor. More...
 
 key_value_pair (key_value_pair &&other) noexcept
 Move constructor. More...
 
 key_value_pair (key_value_pair &&other, const allocator_type &alloc) noexcept
 Allocator-extended move constructor. More...
 
key_value_pairoperator= (const key_value_pair &other)
 Copy assignment operator. More...
 
key_value_pairoperator= (key_value_pair &&other) noexcept
 Move assignment operator. More...
 
void swap (key_value_pair &other) noexcept
 Swap contents. More...
 
 ~key_value_pair () noexcept
 Destructor. More...
 
const key_type key () const noexcept
 Returns the stored key. More...
 
const char_typekey_c_str () const noexcept
 Returns the stored key as const char*. More...
 
value_typevalue () noexcept
 References the stored JSON value. More...
 
const value_typevalue () const noexcept
 References the stored JSON value. More...
 
allocator_type get_allocator () const noexcept
 Return an allocator object. More...
 

Friends

bool operator== (const key_value_pair &lhs, const key_value_pair &rhs) noexcept
 Return true if two key-value pairs are equal. More...
 
bool operator!= (const key_value_pair &lhs, const key_value_pair &rhs) noexcept
 Return true if two key-value pairs are not equal. More...
 

Detailed Description

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
class metall::json::key_value_pair< char_type, char_traits, Alloc >

A class for holding a pair of JSON string (as its key) and JSON value (as its value).

Template Parameters
char_typeA char type to store.
char_traitsA chart traits.
_allocator_typeAn allocator type.

Member Typedef Documentation

◆ char_type

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::char_type = _char_type

◆ char_traits

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::char_traits = _char_traits

◆ allocator_type

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::allocator_type = Alloc

◆ key_type

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::key_type = std::basic_string_view<char_type, char_traits>

◆ value_type

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::value_type = metall::json::value<allocator_type>

◆ size_type

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
using metall::json::key_value_pair< char_type, char_traits, Alloc >::size_type = std::size_t

Constructor & Destructor Documentation

◆ key_value_pair() [1/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( key_type  key,
const value_type value,
const allocator_type alloc = allocator_type() 
)
inline

Constructor.

Parameters
keyA key string.
valueA JSON value to hold.
allocAn allocator object to allocate the key and the contents of the JSON value.

◆ key_value_pair() [2/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( key_type  key,
value_type &&  value,
const allocator_type alloc = allocator_type() 
)
inline

Constructor.

Parameters
keyA key string.
valueA JSON value to hold.
allocAn allocator object to allocate the key and the contents of the JSON value.

◆ key_value_pair() [3/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( const key_value_pair< char_type, char_traits, Alloc > &  other)
inline

Copy constructor.

◆ key_value_pair() [4/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( const key_value_pair< char_type, char_traits, Alloc > &  other,
const allocator_type alloc 
)
inline

Allocator-extended copy constructor.

◆ key_value_pair() [5/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( key_value_pair< char_type, char_traits, Alloc > &&  other)
inlinenoexcept

Move constructor.

◆ key_value_pair() [6/6]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::key_value_pair ( key_value_pair< char_type, char_traits, Alloc > &&  other,
const allocator_type alloc 
)
inlinenoexcept

Allocator-extended move constructor.

◆ ~key_value_pair()

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
metall::json::key_value_pair< char_type, char_traits, Alloc >::~key_value_pair ( )
inlinenoexcept

Destructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
key_value_pair& metall::json::key_value_pair< char_type, char_traits, Alloc >::operator= ( const key_value_pair< char_type, char_traits, Alloc > &  other)
inline

Copy assignment operator.

◆ operator=() [2/2]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
key_value_pair& metall::json::key_value_pair< char_type, char_traits, Alloc >::operator= ( key_value_pair< char_type, char_traits, Alloc > &&  other)
inlinenoexcept

Move assignment operator.

◆ swap()

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
void metall::json::key_value_pair< char_type, char_traits, Alloc >::swap ( key_value_pair< char_type, char_traits, Alloc > &  other)
inlinenoexcept

Swap contents.

◆ key()

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
const key_type metall::json::key_value_pair< char_type, char_traits, Alloc >::key ( ) const
inlinenoexcept

Returns the stored key.

Returns
Returns the stored key.

◆ key_c_str()

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
const char_type* metall::json::key_value_pair< char_type, char_traits, Alloc >::key_c_str ( ) const
inlinenoexcept

Returns the stored key as const char*.

Returns
Returns the stored key as const char*.

◆ value() [1/2]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
value_type& metall::json::key_value_pair< char_type, char_traits, Alloc >::value ( )
inlinenoexcept

References the stored JSON value.

Returns
Returns a reference to the stored JSON value.

◆ value() [2/2]

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
const value_type& metall::json::key_value_pair< char_type, char_traits, Alloc >::value ( ) const
inlinenoexcept

References the stored JSON value.

Returns
Returns a reference to the stored JSON value.

◆ get_allocator()

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
allocator_type metall::json::key_value_pair< char_type, char_traits, Alloc >::get_allocator ( ) const
inlinenoexcept

Return an allocator object.

Friends And Related Function Documentation

◆ operator==

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
bool operator== ( const key_value_pair< char_type, char_traits, Alloc > &  lhs,
const key_value_pair< char_type, char_traits, Alloc > &  rhs 
)
friend

Return true if two key-value pairs are equal.

Parameters
lhsA key-value pair to compare.
rhsA key-value pair to compare.
Returns
True if two key-value pairs are equal. Otherwise, false.

◆ operator!=

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
bool operator!= ( const key_value_pair< char_type, char_traits, Alloc > &  lhs,
const key_value_pair< char_type, char_traits, Alloc > &  rhs 
)
friend

Return true if two key-value pairs are not equal.

Parameters
lhsA key-value pair to compare.
rhsA key-value pair to compare.
Returns
True if two key-value pairs are not equal. Otherwise, false.

Member Data Documentation

◆ m_short_key

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
char_type metall::json::key_value_pair< char_type, char_traits, Alloc >::m_short_key[k_short_key_max_length+1]

◆ m_short_key_buf

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
uint64_t metall::json::key_value_pair< char_type, char_traits, Alloc >::m_short_key_buf

◆ m_long_key

template<typename char_type = char, typename char_traits = std::char_traits<char_type>, typename Alloc = std::allocator<char_type>>
char_pointer metall::json::key_value_pair< char_type, char_traits, Alloc >::m_long_key {nullptr}

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