framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Typedefs | Enumerations | Functions
framework::protocol_buffers Namespace Reference

Protocol buffers namespace. More...

Classes

struct  protocol_buffer_implementation_wrapper
 Implementation wrapper. More...
 
struct  field_tag
 Field tag. More...
 
struct  field_base
 Common field type base. More...
 
struct  field_matcher
 Field matcher. More...
 
struct  fixed_tag
 Compile time tag definition. More...
 
struct  raw_input_frame
 Input frame wrapper. More...
 
struct  raw_output_frame
 Output frame wrapper. More...
 
class  length_delimited_input_frame
 Length delimited input frame wrapper. More...
 
class  size_frame
 Size frame. More...
 
class  max_size_frame
 Size frame. More...
 
struct  default_optional_value
 Default optional implementation. More...
 
struct  optional
 Optional value type. More...
 
class  message
 Message type. More...
 
class  group
 Group type. More...
 
struct  default_repeated_value
 Default repeated implementation. More...
 
struct  repeated
 Repeated value type. More...
 
struct  default_required_value
 Default required implementation. More...
 
struct  required
 Required field type. More...
 
struct  varint
 
struct  zig_zag
 
struct  wire_type_base
 Basic wire type definitions. More...
 
struct  wire_type_wrapper
 Wire type wrapper. More...
 
struct  length_delimited
 Length delimited type. More...
 

Typedefs

template<typename T >
using remove_reference_cv = typename std::remove_cv< typename std::remove_reference< T >::type >::type
 Remove reference/cv.
 
template<typename T >
using is_field_type = typename detail::is_field_type_impl< T >::type
 Is field type.
 
template<typename T >
using is_required = typename detail::is_required_impl< T >::type
 Is required.
 
template<typename T >
using is_optional = typename detail::is_optional_impl< T >::type
 Is optional.
 
template<typename T >
using is_repeated = typename detail::is_repeated_impl< T >::type
 Is repeated.
 
template<typename T >
using field_number = typename detail::field_number_impl< T >::type
 Field number.
 
template<typename T >
using field_type = typename detail::field_type_impl< T >::type
 Field type.
 
template<typename Lhs , typename Rhs >
using field_less_than = value_less_than< field_number< Lhs >, field_number< Rhs >>
 Field less than. More...
 
template<typename T >
using is_wire_type = typename detail::is_wire_type_impl< T >::type
 Is wire type.
 
template<typename T >
using is_integer_type = typename detail::is_integer_type_impl< T >::type
 Is integer type. More...
 
template<typename T >
using wire_type = typename detail::wire_type_impl< T >::type
 Wire type.
 
template<typename T >
using make_wire_type = typename detail::make_wire_type_impl< T >::type
 Make wire type.
 
using float_ = wire_type_wrapper< e_wire_type::fixed_32, serializable::little_endian< float >>
 float primitive.
 
using double_ = wire_type_wrapper< e_wire_type::fixed_64, serializable::little_endian< double >>
 double primitive.
 
using bool_ = wire_type_wrapper< e_wire_type::varint, varint< bool >>
 bool primitive.
 
using string_ = wire_type_wrapper< e_wire_type::length_delimited, serializable::stl_string< varint< std::size_t >>>
 string primitive.
 
using bytes = string_
 bytes primitive.
 
using int32 = wire_type_wrapper< e_wire_type::varint, varint< int32_t >>
 int32 primitive.
 
using int64 = wire_type_wrapper< e_wire_type::varint, varint< int64_t >>
 int64 primitive.
 
using uint32 = wire_type_wrapper< e_wire_type::varint, varint< uint32_t >>
 uint32 primitive.
 
using uint64 = wire_type_wrapper< e_wire_type::varint, varint< uint64_t >>
 uint64 primitive.
 
using sint32 = wire_type_wrapper< e_wire_type::varint, zig_zag< int32_t >>
 sint32 primitive.
 
using sint64 = wire_type_wrapper< e_wire_type::varint, zig_zag< int64_t >>
 sint64 primitive.
 
using fixed32 = wire_type_wrapper< e_wire_type::fixed_32, serializable::little_endian< uint32_t >>
 fixed32 primitive.
 
using fixed64 = wire_type_wrapper< e_wire_type::fixed_64, serializable::little_endian< uint64_t >>
 fixed64 primitive.
 
using sfixed32 = wire_type_wrapper< e_wire_type::fixed_32, serializable::little_endian< int32_t >>
 sfixed32 primitive.
 
using sfixed64 = wire_type_wrapper< e_wire_type::fixed_64, serializable::little_endian< int64_t >>
 sfixed64 primitive.
 

Enumerations

enum  e_constants { e_constants::fixed_varint_length = 5 }
 Common constants. More...
 
enum  e_field_type
 Field type constants.
 
enum  e_wire_type : uint8_t
 Wire type constants.
 

Functions

template<typename Tag , typename Output >
FRAMEWORK_ALWAYS_INLINE bool write_tag (Output &out)
 Write tag.
 
template<typename Tag >
FRAMEWORK_ALWAYS_INLINE bool write_tag (char *begin, char *end, char *&it)
 Write tag.
 
template<typename Tag >
FRAMEWORK_ALWAYS_INLINE bool expect_tag (char const *begin, char const *end, char const *&it)
 Expect tag.
 
template<typename Tag , typename Output >
bool write_tag (Output &out)
 Write tag.
 
template<typename SizeFrame , typename Input , typename Output >
bool write_to_string (Input &&in, Output &&out)
 Write to string. More...
 
template<typename SizeFrame , typename Input , typename Output >
bool write_to_frame (Input &&in, Output &&out)
 Write to frame. More...
 
template<typename Input , typename Output >
bool write_to_string_fast (Input &&in, Output &&out)
 Fast write to string. More...
 
template<typename Input , typename Output >
bool write_to_string_tight (Input &&in, Output &&out)
 Tight write to string. More...
 
template<typename Input , typename Output >
bool write_to_frame_fast (Input &&in, Output &&out)
 Fast write to frame. More...
 
template<typename Input , typename Output >
bool write_to_frame_tight (Input &&in, Output &&out)
 Fast write to tight. More...
 
template<typename Input >
bool write_to_array (Input &&in, char *s, std::size_t &n)
 Write to array. More...
 
template<typename Input >
bool write_to_ostream (Input &&in, std::ostream &out)
 Write to ostream. More...
 
template<typename Output >
bool read_from_array (char const *s, std::size_t n, Output &&out)
 Read from array. More...
 
template<typename Input , typename Output >
bool read_from_string (Input &&in, Output &&out)
 Read from string. More...
 
template<typename Input , typename Output >
bool read_from_frame (Input &&in, Output &&out)
 Read from frame. More...
 
template<typename Output >
bool read_from_istream (std::istream &in, Output &&out)
 Read from istream. More...
 
template<std::size_t Size, typename Output >
bool fixed_length (std::size_t value, Output &&out)
 
template<std::size_t Size>
FRAMEWORK_ALWAYS_INLINE bool fixed_length (std::size_t value, char *begin, char *end, char *&it)
 

Detailed Description

Protocol buffers namespace.

Typedef Documentation

template<typename Lhs , typename Rhs >
using framework::protocol_buffers::field_less_than = typedef value_less_than <field_number <Lhs>, field_number <Rhs>>

Field less than.

Compares the field number associated to Lhs with that of Rhs. This expression evaluates to std::true_type iff field_number <Lhs>::value < field_number <Rhs>::value - otherwise, evaluates to std::false_type.

template<typename T >
using framework::protocol_buffers::is_integer_type = typedef typename detail::is_integer_type_impl <T>::type

Is integer type.

Note
Is equivalent to std::true_type for internal integer types only (int32, int64, ...) - used to conditionally enable packed representations of repeated fields.

Enumeration Type Documentation

Common constants.

Enumerator
fixed_varint_length 

Fixed varint length.

Defines the size of the fixed-length varint used in various implementations to avoid pre-computing the size of a given field.

Note
In the worst case (a very large repeated varint field is a reasonable approximation here) computing the size of the field object may be nearly as expensive as writing the object to a byte string. Here we avoid this cost by fixing the size field to five bytes, limiting the maximum length delimited field size to 2^(5*7)-1 =~ 32 GiB.

Function Documentation

template<std::size_t Size, typename Output >
bool framework::protocol_buffers::fixed_length ( std::size_t  value,
Output &&  out 
)

Writes a fixed-length varint value to an output stream.

Parameters
valueinput value
outoutput stream
Template Parameters
Sizevarint size in bytes
Returns
true on success, false on failure
template<std::size_t Size>
FRAMEWORK_ALWAYS_INLINE bool framework::protocol_buffers::fixed_length ( std::size_t  value,
char *  begin,
char *  end,
char *&  it 
)

Writes a fixed-length varint value to a raw character buffer.

Parameters
valueinput value
beginoutput buffer begin
endoutput buffer end
itfinal output iterator position
Template Parameters
Sizevarint size in bytes
Returns
true on success, false on failure
template<typename Output >
bool framework::protocol_buffers::read_from_array ( char const *  s,
std::size_t  n,
Output &&  out 
)

Read from array.

Deserializes the object from a byte array.

Returns
true on success, false on failure
Parameters
sinput byte array
nbyte array size
outoutput object
template<typename Input , typename Output >
bool framework::protocol_buffers::read_from_frame ( Input &&  in,
Output &&  out 
)

Read from frame.

Deserializes the object from a string through a raw_input_frame. Similar performance considerations as described in write_to_frame_fast hold here.

Returns
true on success, false on failure
Parameters
ininput string
outoutput object
template<typename Output >
bool framework::protocol_buffers::read_from_istream ( std::istream &  in,
Output &&  out 
)

Read from istream.

Deserializes the object from a std::istream. This method may be preferred over a serializable::read operation to avoid instantiating multiple templates for istream types.

Returns
true on success, false on failure
Parameters
ininput istream
outoutput object
template<typename Input , typename Output >
bool framework::protocol_buffers::read_from_string ( Input &&  in,
Output &&  out 
)

Read from string.

Deserializes the object from a string.

Returns
true on success, false on failure
Parameters
ininput string
outoutput object
template<typename Input >
bool framework::protocol_buffers::write_to_array ( Input &&  in,
char *  s,
std::size_t &  n 
)

Write to array.

Serializes the object to a fixed-length byte array. The size of the serialized object is stored in n on success.

Returns
true on success, false on failure
Parameters
ininput object
soutput byte array
nbyte array size
template<typename SizeFrame , typename Input , typename Output >
bool framework::protocol_buffers::write_to_frame ( Input &&  in,
Output &&  out 
)

Write to frame.

Serializes the object to a string though a raw frame, using a SizeFrame object to asses the object's size.

Returns
true on success, false on failure
Template Parameters
SizeFrameused to assess the object's size
Parameters
ininput object
outoutput string
template<typename Input , typename Output >
bool framework::protocol_buffers::write_to_frame_fast ( Input &&  in,
Output &&  out 
)

Fast write to frame.

As write_to_string_fast but writes to the string through a raw_input_frame object. When mixing arbitrary serializable types with protocol buffer specifications the overhead associated with creating an intermediate frame object at each of these transition points was found to be substantial on the compilers benchmarked (clang++ 3.3 - 178146 / g++ 4.7.2 - 20121109). This variant uses a single global frame object for the write rather than a series of local objects - performance implications will be highly workload dependent.

Returns
true on success, false on failure
Parameters
ininput object
outoutput string
template<typename Input , typename Output >
bool framework::protocol_buffers::write_to_frame_tight ( Input &&  in,
Output &&  out 
)

Fast write to tight.

As write_to_string_tight but writes to the string through a raw_input_frame object. When mixing arbitrary serializable types with protocol buffer specifications the overhead associated with creating an intermediate frame object at each of these transition points was found to be substantial on the compilers benchmarked (clang++ 3.3 - 178146 / g++ 4.7.2 - 20121109). This variant uses a single global frame object for the write rather than a series of local objects - performance implications will be highly workload dependent.

Returns
true on success, false on failure
Parameters
ininput object
outoutput string
template<typename Input >
bool framework::protocol_buffers::write_to_ostream ( Input &&  in,
std::ostream &  out 
)

Write to ostream.

Serializes the object to a std::ostream. This method may be preferred over a serializable::write operation to avoid instantiating multiple templates for ostream types.

Returns
true on success, false on failure
Parameters
ininput object
outoutput ostream
template<typename SizeFrame , typename Input , typename Output >
bool framework::protocol_buffers::write_to_string ( Input &&  in,
Output &&  out 
)

Write to string.

Serializes the object to a string using a SizeFrame object to asses the object's size.

Returns
true on success, false on failure
Template Parameters
SizeFrameused to assess the object's size
Parameters
ininput object
outoutput string
template<typename Input , typename Output >
bool framework::protocol_buffers::write_to_string_fast ( Input &&  in,
Output &&  out 
)

Fast write to string.

Serializes the protocol buffer object to a string, using max_size_frame to asses the object's size. This method can be significantly faster than write_to_array_fast, however the amount of memory allocated to the string may be as much as an order of magnitude more than write_to_array_tight.

Returns
true on success, false on failure
Parameters
ininput object
outoutput string
template<typename Input , typename Output >
bool framework::protocol_buffers::write_to_string_tight ( Input &&  in,
Output &&  out 
)

Tight write to string.

Serializes the protocol buffer object to a string, using size_frame to assess the object's size. This method uses significantly less memory than write_to_array_fast, however the serialization time may be as much as twice that of write_to_string_fast.

Returns
true on success, false on failure
Parameters
ininput object
outoutput string