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) Lumiera.org
5  2011, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
48 #ifndef LIB_META_SIZE_TRAIT_H
49 #define LIB_META_SIZE_TRAIT_H
50 
51 
52 
53 #include <vector>
54 #include <string>
55 
56 
57 namespace lib {
58 namespace meta {
59 
60 
86  class SizeTrait
87  {
88  //-------------------------------------mimicked-definitions--
89 
90  typedef std::vector<size_t> Vector;
91  typedef std::vector<bool> BVector;
92 
94  : std::allocator<char>
95  { };
96 
97  struct Locale
98  {
99  void* _M_impl;
100  };
101 
102  template<class T>
103  struct Optional
104  {
105  bool m_initialized_;
106  T m_storage_;
107  };
108 
109  enum IOS_Openmode
110  {
111  _S_app = 1L << 0,
112  _S_ate = 1L << 1,
113  _S_bin = 1L << 2,
114  _S_in = 1L << 3,
115  _S_out = 1L << 4,
116  _S_trunc = 1L << 5,
117  _S_ios_openmode_end = 1L << 16
118  };
119 
121  {
122  char * _M_in_beg;
123  char * _M_in_cur;
124  char * _M_in_end;
125  char * _M_out_beg;
126  char * _M_out_cur;
127  char * _M_out_end;
128 
129  Locale _M_buf_locale;
130 
131  virtual ~BasicStringbuf() { }
132  };
133 
136  {
137  char * putend_;
138  bool is_allocated_;
139  IOS_Openmode mode_;
140  CompatAllocator alloc_;
141  };
142 
143  struct BoostFormat
144  {
145  Vector items_;
146  BVector bound_; // note: differs in size
147  int style_;
148  int cur_arg_;
149  int num_args_;
150  mutable bool dumped_;
151  std::string prefix_;
152  unsigned char exceptions;
153  BasicAltstringbuf buf_;
154  Optional<Locale> loc_;
155  };
156  //-------------------------------------mimicked-definitions--
157 
158 
159  public:/* ===== Interface: size constants ===== */
160 
161  enum { ALIGNMENT = sizeof(size_t)
162 
163  , STRING = sizeof(std::string)
164  , VECTOR = sizeof(Vector)
165  , BVECTOR = sizeof(BVector)
166 
167  , BOOST_FORMAT = sizeof(BoostFormat)
168  };
169  };
170 
171 
172 }} // namespace lib::meta
173 #endif
A collection of constants to describe the expected size of some known classes, without needing to inc...
Definition: size-trait.hpp:86
Implementation namespace for support and library code.