Lumiera  0.pre.03
»edit your freedom«
size-trait.hpp
Go to the documentation of this file.
1 /*
2  SIZE-TRAIT.hpp - helpers and definitions to deal with the size of some known types
3 
4  Copyright (C)
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
39 #ifndef LIB_META_SIZE_TRAIT_H
40 #define LIB_META_SIZE_TRAIT_H
41 
42 
43 
44 #include <vector>
45 #include <string>
46 
47 
48 namespace lib {
49 namespace meta {
50 
51 
77  class SizeTrait
78  {
79  //-------------------------------------mimicked-definitions--
80 
81  typedef std::vector<size_t> Vector;
82  typedef std::vector<bool> BVector;
83 
85  : std::allocator<char>
86  { };
87 
88  struct Locale
89  {
90  void* _M_impl;
91  };
92 
93  template<class T>
94  struct Optional
95  {
96  bool m_initialized_;
97  T m_storage_;
98  };
99 
100  enum IOS_Openmode
101  {
102  _S_app = 1L << 0,
103  _S_ate = 1L << 1,
104  _S_bin = 1L << 2,
105  _S_in = 1L << 3,
106  _S_out = 1L << 4,
107  _S_trunc = 1L << 5,
108  _S_ios_openmode_end = 1L << 16
109  };
110 
112  {
113  char * _M_in_beg;
114  char * _M_in_cur;
115  char * _M_in_end;
116  char * _M_out_beg;
117  char * _M_out_cur;
118  char * _M_out_end;
119 
120  Locale _M_buf_locale;
121 
122  virtual ~BasicStringbuf() { }
123  };
124 
127  {
128  char * putend_;
129  bool is_allocated_;
130  IOS_Openmode mode_;
131  CompatAllocator alloc_;
132  };
133 
134  struct BoostFormat
135  {
136  Vector items_;
137  BVector bound_; // note: differs in size
138  int style_;
139  int cur_arg_;
140  int num_args_;
141  mutable bool dumped_;
142  std::string prefix_;
143  unsigned char exceptions;
144  BasicAltstringbuf buf_;
145  Optional<Locale> loc_;
146  };
147  //-------------------------------------mimicked-definitions--
148 
149 
150  public:/* ===== Interface: size constants ===== */
151 
152  enum { ALIGNMENT = sizeof(size_t)
153 
154  , STRING = sizeof(std::string)
155  , VECTOR = sizeof(Vector)
156  , BVECTOR = sizeof(BVector)
157 
158  , BOOST_FORMAT = sizeof(BoostFormat)
159  };
160  };
161 
162 
163 }} // namespace lib::meta
164 #endif
A collection of constants to describe the expected size of some known classes, without needing to inc...
Definition: size-trait.hpp:77
Implementation namespace for support and library code.