1
- // Boost.Units - A C++ library for zero-overhead dimensional analysis and
1
+ // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2
2
// unit/quantity manipulation and conversion
3
3
//
4
4
// Copyright (C) 2003-2008 Matthias Christian Schabel
@@ -51,7 +51,7 @@ inline void serialize(Archive& ar,boost::units::quantity<Unit,Y>& q,const unsign
51
51
{
52
52
ar & boost::serialization::make_nvp (" value" , units::quantity_cast<Y&>(q));
53
53
}
54
-
54
+
55
55
} // namespace serialization
56
56
57
57
namespace units {
@@ -60,9 +60,9 @@ namespace units {
60
60
template <class T > std::string to_string (const T& t)
61
61
{
62
62
std::stringstream sstr;
63
-
63
+
64
64
sstr << t;
65
-
65
+
66
66
return sstr.str ();
67
67
}
68
68
@@ -126,7 +126,7 @@ enum autoprefix_mode
126
126
namespace detail {
127
127
128
128
template <bool >
129
- struct xalloc_key_holder
129
+ struct xalloc_key_holder
130
130
{
131
131
static int value;
132
132
static bool initialized;
@@ -138,11 +138,11 @@ int xalloc_key_holder<b>::value = 0;
138
138
template <bool b>
139
139
bool xalloc_key_holder<b>::initialized = 0 ;
140
140
141
- struct xalloc_key_initializer_t
141
+ struct xalloc_key_initializer_t
142
142
{
143
- xalloc_key_initializer_t ()
143
+ xalloc_key_initializer_t ()
144
144
{
145
- if (!xalloc_key_holder<true >::initialized)
145
+ if (!xalloc_key_holder<true >::initialized)
146
146
{
147
147
xalloc_key_holder<true >::value = std::ios_base::xalloc ();
148
148
xalloc_key_holder<true >::initialized = true ;
@@ -151,62 +151,62 @@ struct xalloc_key_initializer_t
151
151
};
152
152
153
153
namespace /* */ {
154
-
154
+
155
155
xalloc_key_initializer_t xalloc_key_initializer;
156
156
157
157
} // namespace
158
158
159
159
} // namespace detail
160
160
161
161
// / returns flags controlling output.
162
- inline long get_flags (std::ios_base& ios, long mask)
162
+ inline long get_flags (std::ios_base& ios, long mask)
163
163
{
164
164
return (ios.iword (detail::xalloc_key_holder<true >::value) & mask);
165
165
}
166
166
167
167
// / Set new flags controlling output format.
168
- inline void set_flags (std::ios_base& ios, long new_flags, long mask)
168
+ inline void set_flags (std::ios_base& ios, long new_flags, long mask)
169
169
{
170
170
BOOST_ASSERT ((~mask & new_flags) == 0 );
171
171
long & flags = ios.iword (detail::xalloc_key_holder<true >::value);
172
172
flags = (flags & ~mask) | new_flags;
173
173
}
174
174
175
175
// / returns flags controlling output format.
176
- inline format_mode get_format (std::ios_base& ios)
176
+ inline format_mode get_format (std::ios_base& ios)
177
177
{
178
178
return (static_cast <format_mode>((get_flags)(ios, fmt_mask)));
179
179
}
180
180
181
181
// / Set new flags controlling output format.
182
- inline void set_format (std::ios_base& ios, format_mode new_mode)
182
+ inline void set_format (std::ios_base& ios, format_mode new_mode)
183
183
{
184
184
(set_flags)(ios, new_mode, fmt_mask);
185
185
}
186
186
187
187
// / Set new flags for type_name output format.
188
- inline std::ios_base& typename_format (std::ios_base& ios)
188
+ inline std::ios_base& typename_format (std::ios_base& ios)
189
189
{
190
190
(set_format)(ios, typename_fmt);
191
191
return (ios);
192
192
}
193
193
194
194
// / set new flag for raw format output, for example "m".
195
- inline std::ios_base& raw_format (std::ios_base& ios)
195
+ inline std::ios_base& raw_format (std::ios_base& ios)
196
196
{
197
197
(set_format)(ios, raw_fmt);
198
198
return (ios);
199
199
}
200
200
201
201
// / set new format flag for symbol output, for example "m".
202
- inline std::ios_base& symbol_format (std::ios_base& ios)
202
+ inline std::ios_base& symbol_format (std::ios_base& ios)
203
203
{
204
204
(set_format)(ios, symbol_fmt);
205
205
return (ios);
206
206
}
207
207
208
208
// / set new format for name output, for example "meter".
209
- inline std::ios_base& name_format (std::ios_base& ios)
209
+ inline std::ios_base& name_format (std::ios_base& ios)
210
210
{
211
211
(set_format)(ios, name_fmt);
212
212
return (ios);
@@ -267,7 +267,7 @@ inline std::string base_unit_symbol_string(const T&)
267
267
return base_unit_info<typename T::tag_type>::symbol () + exponent_string (typename T::value_type ());
268
268
}
269
269
270
- template <class T >
270
+ template <class T >
271
271
inline std::string base_unit_name_string (const T&)
272
272
{
273
273
return base_unit_info<typename T::tag_type>::name () + exponent_string (typename T::value_type ());
@@ -317,12 +317,12 @@ struct symbol_string_impl<0>
317
317
};
318
318
319
319
template <int N>
320
- struct scale_symbol_string_impl
320
+ struct scale_symbol_string_impl
321
321
{
322
322
template <class Begin >
323
- struct apply
323
+ struct apply
324
324
{
325
- static void value (std::string& str)
325
+ static void value (std::string& str)
326
326
{
327
327
str += Begin::item::symbol ();
328
328
scale_symbol_string_impl<N - 1 >::template apply<typename Begin::next>::value (str);
@@ -334,7 +334,7 @@ template<>
334
334
struct scale_symbol_string_impl <0 >
335
335
{
336
336
template <class Begin >
337
- struct apply
337
+ struct apply
338
338
{
339
339
static void value (std::string&) { }
340
340
};
@@ -383,12 +383,12 @@ struct name_string_impl<0>
383
383
};
384
384
385
385
template <int N>
386
- struct scale_name_string_impl
386
+ struct scale_name_string_impl
387
387
{
388
388
template <class Begin >
389
- struct apply
389
+ struct apply
390
390
{
391
- static void value (std::string& str)
391
+ static void value (std::string& str)
392
392
{
393
393
str += Begin::item::name ();
394
394
scale_name_string_impl<N - 1 >::template apply<typename Begin::next>::value (str);
@@ -400,7 +400,7 @@ template<>
400
400
struct scale_name_string_impl <0 >
401
401
{
402
402
template <class Begin >
403
- struct apply
403
+ struct apply
404
404
{
405
405
static void value (std::string&) { }
406
406
};
@@ -464,14 +464,14 @@ to_string_impl(const unit<Dimension, heterogeneous_system<heterogeneous_system_i
464
464
f.template append_scale_to <Scale>(str);
465
465
466
466
std::string without_scale = f (unit<Dimension, heterogeneous_system<heterogeneous_system_impl<Units, Dimension, dimensionless_type> > >());
467
-
467
+
468
468
if (f.is_default_string (without_scale, unit<Dimension, heterogeneous_system<heterogeneous_system_impl<Units, Dimension, dimensionless_type> > >()))
469
469
{
470
470
str += " (" ;
471
471
str += without_scale;
472
472
str += " )" ;
473
- }
474
- else
473
+ }
474
+ else
475
475
{
476
476
str += without_scale;
477
477
}
@@ -1011,27 +1011,27 @@ name_string(const unit<Dimension, System>&)
1011
1011
template <class Char , class Traits , class Dimension , class System >
1012
1012
inline std::basic_ostream<Char, Traits>& operator <<(std::basic_ostream<Char, Traits>& os, const unit<Dimension, System>& u)
1013
1013
{
1014
- if (units::get_format (os) == typename_fmt)
1014
+ if (units::get_format (os) == typename_fmt)
1015
1015
{
1016
1016
detail::do_print (os, typename_string (u));
1017
1017
}
1018
- else if (units::get_format (os) == raw_fmt)
1018
+ else if (units::get_format (os) == raw_fmt)
1019
1019
{
1020
1020
detail::do_print (os, detail::to_string_impl (u, detail::format_raw_symbol_impl ()));
1021
1021
}
1022
- else if (units::get_format (os) == symbol_fmt)
1022
+ else if (units::get_format (os) == symbol_fmt)
1023
1023
{
1024
1024
detail::do_print (os, symbol_string (u));
1025
1025
}
1026
- else if (units::get_format (os) == name_fmt)
1026
+ else if (units::get_format (os) == name_fmt)
1027
1027
{
1028
1028
detail::do_print (os, name_string (u));
1029
1029
}
1030
- else
1030
+ else
1031
1031
{
1032
1032
BOOST_ASSERT_MSG (false , " The format mode must be one of: typename_format, raw_format, name_format, symbol_format" );
1033
1033
}
1034
-
1034
+
1035
1035
return (os);
1036
1036
}
1037
1037
0 commit comments