12 #ifndef ECL_FORMATTERS_STRINGS_HPP_ 13 #define ECL_FORMATTERS_STRINGS_HPP_ 20 #include <ecl/exceptions/standard_exception.hpp> 62 Format<std::string>& width(
int w) { width_ = w;
return *
this; }
68 Format<std::string>& align(
Alignment a) { alignment_ = a;
return *
this; }
79 Format<std::string>& operator ()(
int w,
Alignment a);
89 Format<std::string>& operator() (
const std::string &input_string);
100 Format<std::string>& operator() (
const std::string &input_string,
int w);
109 Format<std::string>& operator() (
const std::string &input_string,
int w,
Alignment a);
126 template <
typename OutputStream>
friend OutputStream& operator << (OutputStream& ostream, Format<std::string>& formatter)
ecl_assert_throw_decl(StandardException);
134 bool ready_to_format;
145 template <
typename OutputStream>
void pad(
int n, OutputStream &ostream)
const;
151 template <
typename OutputStream>
void prePad(
int n, OutputStream &ostream)
const;
157 template <
typename OutputStream>
void postPad(
int n, OutputStream &ostream)
const;
166 template <
typename OutputStream>
void format(OutputStream &ostream)
const;
173 template <
typename OutputStream>
178 prePad(width_ - (size),ostream);
180 postPad(width_ - (size),ostream);
183 template <
typename OutputStream>
186 if ( n <= 0 ) {
return; }
187 switch ( alignment_ )
191 case (
RightAlign ) : { pad(n,ostream);
break; }
192 case (
CentreAlign ) : { pad(n/2+ n%2,ostream);
break; }
196 template <
typename OutputStream>
199 if ( n <= 0 ) {
return; }
200 switch ( alignment_ )
203 case (
LeftAlign ) : { pad(n,ostream);
break; }
205 case (
CentreAlign ) : { pad(n/2,ostream);
break; }
209 template <
typename OutputStream>
212 for (
int i = n; i > 0; --i )
222 template <
typename OutputStream>
225 bool ready = formatter.ready_to_format;
228 "either there is no data available, or you have tried to use the " 229 "formatter more than once in a single streaming operation. " 230 "C++ produces unspecified results when functors are used multiply " 231 "in the same stream sequence, so this is not permitted here.") );
234 formatter.format(ostream);
235 formatter.ready_to_format =
false;
#define LOC
Stringify the line of code you are at.
#define ecl_assert_throw(expression, exception)
Debug mode throw with a logical condition check.
Standard exception type, provides code location and error string.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
ecl_geometry_PUBLIC int size(const Trajectory2D &trajectory)
TFSIMD_FORCE_INLINE const tfScalar & w() const
#define ecl_assert_throw_decl(exception)
Assure throw exception declaration.