framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bit_field.hpp
Go to the documentation of this file.
1 // Copyright (C) 2012 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
13 #pragma once
14 
17 
18 namespace framework
19 {
20  namespace serializable
21  {
26  template <typename Block, typename... Specification>
27  struct bit_field : public container_type <
28  pack_container <Specification...>,
29  pack_container <Specification...>,
30  false>
31  {
32  };
33 
41  template <
42  typename Input,
43  typename Output,
44  typename Block,
45  typename... Specification>
48  Input& in, Output& out)
49  {
50  bit_stream <Input, Block> wrapper(in);
51  return dispatch_read <alias <Specification...>> (wrapper, out);
52  }
53 
61  template <
62  typename Input,
63  typename Output,
64  typename Block,
65  typename... Specification>
68  Input const& in, Output& out)
69  {
70  bit_stream <Output, Block> wrapper(out);
71  if (!dispatch_write <alias <Specification...>> (in, wrapper))
72  return false;
73 
74  if (!wrapper.flush())
75  return false;
76 
77  return true;
78  }
79  }
80 }