Alchemy  1.0
A framework to robustly process network messages and structured data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
message_dynamic.h
Go to the documentation of this file.
1 /// @file message_dynamic.h
2 ///
3 /// Provides utility functions related to messages with dynamic fields.
4 ///
5 /// The MIT License(MIT)
6 /// @copyright 2014 Paul M Watt
7 // ****************************************************************************
8 #ifndef MESSAGE_DYNAMIC_H_INCLUDED
9 #define MESSAGE_DYNAMIC_H_INCLUDED
10 // Includes *******************************************************************
12 
13 namespace Hg
14 {
15 
16 // ****************************************************************************
17 /// Query for the amount of dynamic memory required by a specified Hg::basic_msg.
18 ///
19 /// @paramt T [typename] The Hg::basic_msg format definition of the
20 /// message to be converted.
21 /// @param msg The message object to be queried.
22 ///
23 /// @return The number of bytes required to populate the dynamically
24 /// sized fields from the message is returned.
25 /// 0 is returned when there is no dynamic data.
26 ///
27 template< typename T >
28 size_t dynamic_size_of(const T& msg)
29 {
30  return detail::DynamicSizeWorker<T, has_dynamic<T>::value>().size(msg);
31 }
32 
33 
34 // ****************************************************************************
35 /// Reports the total size of the dynamic buffers required for this message.
36 ///
37 template< typename MsgT,
38  typename StorageT
39  >
41 {
42  return detail::DynamicSizeWorker< MsgT,
44  >().size(msg);
45 }
46 
47 } // namespace Hg
48 
49 #endif
50