Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Typedefs | Functions | Variables
Hg Namespace Reference

The MIT License(MIT)

More...

Classes

struct  And
 Takes the logical and of the two input types. The types passed in must have a static boolean value named "value". More...
 
struct  array_trait
 A sequence type that has a fixed size. More...
 
struct  at
 Returns the value of the item at the specified index. More...
 
struct  at< MT, 0 >
 Specialization that handles an MT sequence. More...
 
struct  at< MT, IdxT >
 Specialization that handles an MT sequence. More...
 
struct  at< SeqT, 0 >
 Terminating case that returns the value at the specified index.. More...
 
struct  back< MT >
 Specialization for an MT TypeList. More...
 
struct  back< TypeList< TMP_ARRAY_32(T)> >
 This allows the last type of the list to be returned. More...
 
class  basic_msg
 An object that defines and manages access to a formatted message buffer. More...
 
struct  BitField
 Represents a single entry for a bit field type definition. More...
 
struct  BitFieldArray
 Represents a set of fields that provide homogeneous bit-field access to each of the data values. More...
 
struct  BitFieldVector
 Represents a set of fields that provide homogeneous bit-field access to each of the data values. More...
 
struct  container_trait
 A container_trait describes any type that is not a fundamental type or bitfield. These types facilitate more complex data structures. More...
 
struct  ContainerSize
 Calculates the static size of the container passed in. This value is equivalent to the offset of the "end" item in the container. More...
 
struct  contains
 Searches the integer_sequence and indicates of the specified value is found. More...
 
class  Datum
 A type-wrapper that provides transparent access to a range of memory in a message buffer as if it were the specified type itself. More...
 
struct  dynamic_fields
 Extracts index values of the vector types in a message. More...
 
struct  dynamic_size_trait
 Indicates the field or message has a dynamic size determined at run-time. More...
 
struct  empty_type
 Compares types against the MT type. More...
 
struct  EndianType
 Policy class used to perform byte-order operations. More...
 
struct  EndianType< T, false >
 Policy class used to perform byte-order operations. More...
 
struct  find
 Searches the integer_sequence for a value and returns the position. If the value is not found, Hg::npos is returned. More...
 
struct  find< MT, ValueT >
 Searches the integer_sequence for a value and returns the position. If the value is not found, Hg::npos is returned. More...
 
struct  front< MT >
 Specialization for an MT Type Container. More...
 
struct  front< TypeList< TMP_ARRAY_32(T)> >
 This allows the first type of the list to be returned. More...
 
struct  fundamental_trait
 fundamental_trait identifies fundamental integral types. More...
 
struct  GetTail
 Returns the Tail of an Integral Sequence. This is similar to PopFront, however, as soon as a 0 is encountered, MT will be returned, rather than the remainder of the list. More...
 
struct  GetTail< MT >
 Specialization of GetTail for the MT node type. More...
 
struct  has_dynamic
 Template to determine if a container has any dynamically sized entry types. More...
 
struct  HostByteOrderT
 Byte-order management policy for network data transfers. More...
 
struct  instance_of
 This construct provides mechanism to declare and initialize compile-time global constants. More...
 
struct  integer_sequence
 A parameterized type that is a sequence of integer values. More...
 
struct  is_opaque
 Detect a sequence type that uses an unsigned char (byte_t). More...
 
struct  is_opaque< std::array< byte_t, N > >
 Detect a std::array opaque type. N is the number of entries. More...
 
struct  is_opaque< std::vector< byte_t, A > >
 Detect a std::vector opaque type. A is the allocator. More...
 
struct  is_std_array
 Detect a std::array type. This is the default false case. More...
 
struct  is_std_array< std::array< T, N > >
 Detect a std::array type. This version identifies the std::array. More...
 
struct  is_std_vector
 Detect a std::vector type. This is the default false case. More...
 
struct  is_std_vector< std::vector< T, A > >
 Detect a std::vector type. This version identifies the std::vector. T is the type the vector contains, A is the allocator. More...
 
struct  IsTailEmpty
 Compares the tail-type of the sequence and indicates if the type is empty. More...
 
struct  IsTailEmpty< MT >
 Specialization for an MT type sequence.. More...
 
struct  length
 Count the number of elements in the specified type container. More...
 
struct  make_Hg_type_list
 Creates a type list suitable for processing within Hg messages. More...
 
class  Message
 An object that defines and manages access to a formatted message buffer. More...
 
struct  message_size_trait
 Indicates the type size the specified message is, static or dynamic. More...
 
struct  msg_size
 Reports the number of bytes this message object occupies. This instance of size calculates the size for dynamically sized messages. More...
 
struct  msg_size< T, false >
 Specialization returns the size of a fixed size message. More...
 
class  msg_view
 The MsgView object to manage structured access over an opaque buffer. More...
 
class  msg_view_const_iterator
 Iterator for nonmutable msg_view. More...
 
class  msg_view_iterator
 Iterator for a mutable msg_view. More...
 
class  MsgBuffer
 MsgBuffer Template Definition. This abstracts the behavior of the buffer with respect to the Byte-Order of the message. More...
 
class  MsgBuffer< BufferedStaticStoragePolicy >
 (Static) MsgBuffer Template Definition. This class is a specialization of the template MsgBuffer, and uses a static_storage_policy. More...
 
struct  MT
 A type to represent an MT type for defining type lists and type arrays. More...
 
struct  nested_trait
 A nested type indicates that the data that is contained within, possibly requires an internal inspection to facilitate correct behavior. More...
 
struct  NetByteOrderT
 Byte-order management policy for network data transfers. More...
 
struct  Not
 Takes the logical not of the type. The type passed in must have a static boolean value named "value". More...
 
struct  OffsetOf
 Calculate the pointer offset in bytes for the specified type. More...
 
struct  OffsetOf< 0, ContainerT >
 The item at index 0 will always have an offset of 0. More...
 
struct  one_or_zero
 Casts a static const boolean to an int of one or a zero. More...
 
struct  one_or_zero< false >
 Specialization for the false condition of the bool selector. More...
 
struct  opaque_array_trait
 Indicates the format of the array data is undefined, opaque. More...
 
struct  opaque_trait
 Indicates the fields format is undefined and will be determined by context. More...
 
struct  opaque_value
 Detect if the current value type is opaque. More...
 
struct  opaque_vector_trait
 Indicates the format of the vector data is undefined, opaque. More...
 
struct  Or
 Takes the logical or of the input types. The types passed in must have a static boolean value named "value". More...
 
struct  packed_trait
 packed_trait identifies fundamental integral types, that automatically perform bit-shift and mask operations to simulate bit-fields. More...
 
struct  pop_front< TypeList< TPop, TMP_ARRAY_31(T)> >
 This allows the first type of the list to be removed, and the remainder of the list will become the type typedef. More...
 
struct  pop_front< TypeNode< T1, T2 > >
 Specialization for a TypeNode. More...
 
struct  push_back< TypeList< TMP_ARRAY_32(T)>, T >
 This allows the a new type to be pushed at the back of the list. The new list will become the typedef of the pushed type and the existing type list. More...
 
struct  push_front< MT, T >
 Specialization for an MT TypeList: results with type T and empty. More...
 
struct  push_front< TypeList< TMP_ARRAY_32(T)>, T >
 This allows the a new type to be pushed at the front of the list. The new list will become the typedef of the pushed type and the existing type list. More...
 
struct  push_front< TypeNode< T1, T2 >, T >
 Specialization for a TypeNode: TypeList. More...
 
struct  reverse
 Reverses the order the values in an integral_sequence. More...
 
struct  reverse_nodes
 Reverses the order the nodes in an integral_node list. More...
 
struct  reverse_nodes< ToT, MT >
 A terminating case for reversal of an integral_node list. More...
 
struct  sequence_trait
 Sequence types are a class of types that contain more than one element of the same type in series. More...
 
struct  SizeAt
 Calculate the size in bytes for the specified type. More...
 
struct  SizeOf
 Template to determine the size of a type or type container. More...
 
struct  static_size_trait
 Indicates the field or message has a fixed static size at compile-time. More...
 
struct  StaticStoragePolicy
 Storage Policy implementation for fixed-size memory buffers. More...
 
struct  StoragePolicy
 Storage Policy implementation for contiguous memory buffers. More...
 
struct  TailValue
 Safely extracts the last value in an integral sequence. More...
 
struct  TailValue< MT >
 Specialization to TailValue for the MT type node. More...
 
struct  type_check
 Static Assertion Base Template to verify type constraints for an object. More...
 
struct  TypeAt
 Return the type at the specified array index. More...
 
struct  TypeList
 A template-type list that is composed from a collection of types. More...
 
struct  TypeNode
 A fundamental type used for template meta-programming type containers. More...
 
struct  TypeNode< H, MT >
 A terminator for TypeNode chains. More...
 
struct  value_if
 This construct provides the compile-time equivalent of the ternary operator ?: for value selection. More...
 
struct  value_if< false, T, trueValue, falseValue >
 Specialization for the false condition of the value selector. More...
 
struct  vector_trait
 A sequence type that represents a dynamically sized field. More...
 
struct  yes_t
 Affirmative Type for use in SFINAE selection templates. More...
 

Typedefs

typedef unsigned char byte_t
 A short alias for the 'unsigned char'.
 
typedef MT empty
 An alias that may be more readable.
 
typedef char no_t
 Negative Type for use in SFINAE selection templates.
 

Functions

template<typename T >
size_t dynamic_size_of (const T &msg)
 Query for the amount of dynamic memory required by a specified Hg::basic_msg. More...
 
template<typename MsgT , typename StorageT >
size_t dynamic_size_of (const basic_msg< MsgT, StorageT > &msg)
 Reports the total size of the dynamic buffers required for this message.
 
template<typename T >
EndianSwap (T input)
 A generic implementation that performs no action. More...
 
template<>
uint16_t EndianSwap (uint16_t input)
 Endian Swap (Specialization, uint16_t) More...
 
template<>
int16_t EndianSwap (int16_t input)
 Endian Swap (Specialization, int16_t) More...
 
template<>
uint32_t EndianSwap (uint32_t input)
 Endian Swap (Specialization, uint32_t) More...
 
template<>
int32_t EndianSwap (int32_t input)
 Endian Swap (Specialization, int32_t) More...
 
template<>
uint64_t EndianSwap (uint64_t input)
 Endian Swap (Specialization, uint64_t) More...
 
template<>
int64_t EndianSwap (int64_t input)
 Endian Swap (Specialization, int64_t) More...
 
template<size_t BeginIndex, size_t EndIndex, typename ContainerT , typename Function >
Function & ForEachType (Function &fn)
 Meta-template implementation of for_each. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const T &msg)
 Writes the values of a message into an ostream object. More...
 
template<typename T >
std::istream & operator>> (std::istream &is, T &msg)
 Reads the values of a message from an istream object. More...
 
template<typename MsgT , typename BufferT , typename SizeTraitT >
size_t pack_message (MsgT &msg_values, BufferT &buffer, size_t offset)
 Writes the values of a variable-sized message into a packed memory buffer. A separate instance exists to eliminate dynamic size tests from messages that are completely fixed in size. More...
 
template<typename MsgT , typename BufferT , typename SizeTraitT >
BufferT & pack_message (MsgT &msg_values, size_t size, BufferT &buffer)
 Writes the values of a message into a packed memory buffer. More...
 
template<typename MsgT , typename BufferT , typename SizeTraitT >
bool pack_message (MsgT &msg_values, BufferT &fixed_buffer)
 Writes the values of a message into a packed memory buffer. More...
 
template<typename T >
T::base_type::big_t to_big_endian (T &from)
 Parameterized function to convert a Hg::Message to bit endian byte-order. More...
 
template<typename T >
T::base_type::host_t to_host (T &from)
 Parameterized function to convert a Hg::Message to host byte-order. More...
 
template<typename T >
T::base_type::little_t to_little_endian (T &from)
 Parameterized function to convert a Hg::Message to little endian byte-order. More...
 
template<typename T >
T::base_type::net_t to_network (T &from)
 Parameterized function to convert a Hg::Message to network byte-order. More...
 
template<typename MsgT , typename BufferT , typename SizeTraitT >
MsgT & unpack_message (MsgT &msg_values, const BufferT &buffer)
 Reads the values of a message structure from a packed memory buffer. More...
 
template<typename MsgT , typename BufferT , typename SizeTraitT >
size_t unpack_message (MsgT &msg_values, const BufferT &buffer, size_t offset)
 Reads the values of a message structure from a packed memory buffer. More...
 

Variables

const Endianess k_endianess = Endianess(ALCHEMY_ENDIANESS)
 < Constant indicates machine endianess.
 

Detailed Description

The MIT License(MIT)

Function Documentation

template<typename T >
size_t Hg::dynamic_size_of ( const T &  msg)

Query for the amount of dynamic memory required by a specified Hg::basic_msg.

T [typename] The Hg::basic_msg format definition of the message to be converted.

Parameters
msgThe message object to be queried.
Returns
The number of bytes required to populate the dynamically sized fields from the message is returned. 0 is returned when there is no dynamic data.

Definition at line 28 of file message_dynamic.h.

template<typename T >
T Hg::EndianSwap ( input)

A generic implementation that performs no action.

No change is required the for generic case of EndianSwap. Specialized definitions of this function will perform endian swap operations.

Parameters
inputInput value to perform endian-swap operation.
Returns
Simply return the input value.

Definition at line 79 of file byte_order.h.

template<>
uint16_t Hg::EndianSwap ( uint16_t  input)
inline

Endian Swap (Specialization, uint16_t)

Swaps the current byte order between endian formats for a 16-bit value.

Definition at line 91 of file byte_order.h.

template<>
int16_t Hg::EndianSwap ( int16_t  input)
inline

Endian Swap (Specialization, int16_t)

Swaps the current byte order between endian formats for a 16-bit value.

Definition at line 104 of file byte_order.h.

template<>
uint32_t Hg::EndianSwap ( uint32_t  input)
inline

Endian Swap (Specialization, uint32_t)

Swaps the current byte order between endian formats for a 32-bit value.

Definition at line 118 of file byte_order.h.

template<>
int32_t Hg::EndianSwap ( int32_t  input)
inline

Endian Swap (Specialization, int32_t)

Swaps the current byte order between endian formats for a 32-bit value.

Definition at line 133 of file byte_order.h.

template<>
uint64_t Hg::EndianSwap ( uint64_t  input)
inline

Endian Swap (Specialization, uint64_t)

Swaps the current byte order between endian formats for a 64-bit value.

Definition at line 147 of file byte_order.h.

template<>
int64_t Hg::EndianSwap ( int64_t  input)
inline

Endian Swap (Specialization, int64_t)

Swaps the current byte order between endian formats for a 64-bit value.

Definition at line 166 of file byte_order.h.

template<size_t BeginIndex, size_t EndIndex, typename ContainerT , typename Function >
Function& Hg::ForEachType ( Function &  fn)

Meta-template implementation of for_each.

Meta-template to perform a user specified action on every element in the specified type ContainerT. This is the compile-time equivalent of the std::for_each function.

Template Parameters
BeginIndex[size_t] The starting index for processing the type container. This value must be less than EndIndex otherwise a compiler error will be generated.
EndIndex[size_t]The last index to be processed in the type container.
ContainerT[typename] A type container to process. Each type entry within the specified range will be processed. A compiler error will be generated if this parameter is not a Type Container.
Function[typename] The user specified functor to use on each type.
Parameters
fnA functor that will be called for each type entry in the container passed to the forEach function.

Since this function works on a template type, the functor must support a parameterized functor that accepts one type.

Returns
The input functor is returned to capture any changed state.

Definition at line 151 of file meta_foreach.h.

template<typename T >
std::ostream& Hg::operator<< ( std::ostream &  os,
const T &  msg 
)

Writes the values of a message into an ostream object.

Parameters
osThe output stream that will accept the serialized form of the message.
msgThe message to be serialized.
Returns
A reference to os will be returned to allow these calls to be chained.

Definition at line 115 of file pack_message.h.

template<typename T >
std::istream& Hg::operator>> ( std::istream &  is,
T &  msg 
)

Reads the values of a message from an istream object.

Parameters
isThe input stream that will provide the data to populate the message.
msgThe message to be serialized.
Returns
A reference to is will be returned to allow these calls to be chained.

Definition at line 81 of file unpack_message.h.

template<typename MsgT , typename BufferT , typename SizeTraitT >
size_t Hg::pack_message ( MsgT &  msg_values,
BufferT &  buffer,
size_t  offset 
)

Writes the values of a variable-sized message into a packed memory buffer. A separate instance exists to eliminate dynamic size tests from messages that are completely fixed in size.

Parameters
msg_valuesThe message structure that contains the values to be written.
bufferThe buffer this data should be written into.
offsetThe offset the writing should be at.
Returns
The buffer that has been allocated to store the message.

Definition at line 67 of file pack_message.h.

template<typename MsgT , typename BufferT , typename SizeTraitT >
BufferT& Hg::pack_message ( MsgT &  msg_values,
size_t  size,
BufferT &  buffer 
)

Writes the values of a message into a packed memory buffer.

Parameters
msg_valuesThe message structure that contains the values to be written.
sizeThe calculated size required for this message.
Returns
The buffer that has been allocated to store the message.

Definition at line 36 of file pack_message.h.

template<typename MsgT , typename BufferT , typename SizeTraitT >
bool Hg::pack_message ( MsgT &  msg_values,
BufferT &  fixed_buffer 
)

Writes the values of a message into a packed memory buffer.

Parameters
msg_valuesThe message structure that contains the values to be written.
sizeThe calculated size required for this message.
Returns
The buffer that has been allocated to store the message.

Definition at line 95 of file pack_message.h.

template<typename T >
T::base_type::big_t Hg::to_big_endian ( T &  from)

Parameterized function to convert a Hg::Message to bit endian byte-order.

Parameters
T[typename] The Hg::basic_msg format definition of the message to be converted.
fromThe message object to convert from. Ownership of the memory that belongs to the input type will be transferred to the returned instance, and the conversion will occur in-place.
Returns
A Hg::basic_msg object using the same format and data type as the input buffer will be returned. The data in the buffer will be in big endian byte-order.

If the input format was already in big endian byte-order, no conversion operations will be performed.

Definition at line 93 of file message_byte_order.h.

template<typename T >
T::base_type::host_t Hg::to_host ( T &  from)

Parameterized function to convert a Hg::Message to host byte-order.

Parameters
T[typename] The Hg::basic_msg format definition of the message to be converted.
fromThe message object to convert from. Ownership of the memory that belongs to the input type will be transferred to the returned instance, and the conversion will occur in-place.
Returns
A Hg::basic_msg object using the same format and data type as the input buffer will be returned. The data in the buffer will be in host byte-order.

If the input format was already in host byte-order, no conversion operations will be performed.

Definition at line 65 of file message_byte_order.h.

template<typename T >
T::base_type::little_t Hg::to_little_endian ( T &  from)

Parameterized function to convert a Hg::Message to little endian byte-order.

Parameters
T[typename] The Hg::basic_msg format definition of the message to be converted.
fromThe message object to convert from. Ownership of the memory that belongs to the input type will be transferred to the returned instance, and the conversion will occur in-place.
Returns
A Hg::basic_msg object using the same format and data type as the input buffer will be returned. The data in the buffer will be in little endian byte-order.

If the input format was already in little endian byte-order, no conversion operations will be performed.

Definition at line 121 of file message_byte_order.h.

template<typename T >
T::base_type::net_t Hg::to_network ( T &  from)

Parameterized function to convert a Hg::Message to network byte-order.

Parameters
T[typename] The Hg::basic_msg format definition of the message to be converted.
fromThe message object to convert from. Ownership of the memory that belongs to the input type will be transferred to the returned instance, and the conversion will occur in-place.
Returns
A Hg::basic_msg object using the same format and data type as the input buffer will be returned. The data in the buffer will be in network byte-order.

If the input format was already in network byte-order, no conversion operations will be performed.

Definition at line 36 of file message_byte_order.h.

template<typename MsgT , typename BufferT , typename SizeTraitT >
MsgT & Hg::unpack_message ( MsgT &  msg_values,
const BufferT &  buffer 
)

Reads the values of a message structure from a packed memory buffer.

Parameters
msg_valuesThe message structure that contains the values to be read.
bufferThe buffer this data should be read from.
Returns
The message object populated by the input buffer. This is simply the same message object reference passed as input for expressive syntax.

Definition at line 36 of file unpack_message.h.

template<typename MsgT , typename BufferT , typename SizeTraitT >
size_t Hg::unpack_message ( MsgT &  msg_values,
const BufferT &  buffer,
size_t  offset 
)

Reads the values of a message structure from a packed memory buffer.

Parameters
msg_valuesThe message structure that contains the values to be read.
bufferThe buffer this data should be read from.
offsetThe offset the reading should occur.
Returns
The number of bytes that were read in from the buffer.

Definition at line 59 of file unpack_message.h.