00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef MOCKPP_FORMATTER_H
00031 #define MOCKPP_FORMATTER_H
00032
00033 #include <mockpp/mockpp.h>
00034
00035
00036 MOCKPP_NS_START
00037
00038
00045 MOCKPP_API_DECL(MOCKPP_NS::String) number(long n, unsigned base = 10);
00046
00047 #ifndef UPS_NO_LONG_LONG
00048
00055 MOCKPP_API_DECL(MOCKPP_NS::String) number(long long n, unsigned base = 10);
00056
00057 #endif
00058
00065 MOCKPP_API_DECL(MOCKPP_NS::String) number(unsigned long n, unsigned base = 10);
00066
00067
00068 #ifndef UPS_NO_LONG_LONG
00069
00076 MOCKPP_API_DECL(MOCKPP_NS::String) number(unsigned long long n, unsigned base = 10);
00077
00078 #endif
00079
00087 MOCKPP_API_DECL(MOCKPP_NS::String) number(double n, unsigned prec = 0);
00088
00089
00097 MOCKPP_API_DECL(MOCKPP_NS::String) number(long double n, unsigned prec = 0);
00098
00099
00108 MOCKPP_API_DECL(String &) replaceFormatterString(String &formatter, const String &repdata);
00109
00110
00111 MOCKPP_NS_END
00112
00113
00122 MOCKPP_API_DECL(MOCKPP_NS::String &)
00123 operator << (MOCKPP_NS::String &formatter, const int &repdata);
00124
00125
00134 MOCKPP_API_DECL(MOCKPP_NS::String &)
00135 operator << (MOCKPP_NS::String &formatter, const bool &repdata);
00136
00137
00146 MOCKPP_API_DECL(MOCKPP_NS::String &)
00147 operator << (MOCKPP_NS::String &formatter, const unsigned int &repdata);
00148
00149
00158 MOCKPP_API_DECL(MOCKPP_NS::String &
00159 operator) << (MOCKPP_NS::String &formatter, const unsigned long &repdata);
00160
00161
00170 MOCKPP_API_DECL(MOCKPP_NS::String &)
00171 operator << (MOCKPP_NS::String &formatter, const signed char &repdata);
00172
00173
00182 MOCKPP_API_DECL(MOCKPP_NS::String &)
00183 operator << (MOCKPP_NS::String &formatter, const unsigned char &repdata);
00184
00185
00194 MOCKPP_API_DECL(MOCKPP_NS::String &)
00195 operator << (MOCKPP_NS::String &formatter, const char &repdata);
00196
00197
00206 MOCKPP_API_DECL(MOCKPP_NS::String &)
00207 operator << (MOCKPP_NS::String &formatter, const char * repdata);
00208
00209
00218 MOCKPP_API_DECL(MOCKPP_NS::String &)
00219 operator << (MOCKPP_NS::String &formatter, const float &repdata);
00220
00221 #ifdef MOCKPP_UNICODE
00222
00231 MOCKPP_API_DECL(MOCKPP_NS::String &)
00232 operator << (MOCKPP_NS::String &formatter, const wchar_t &repdata);
00233
00234
00243 MOCKPP_API_DECL(MOCKPP_NS::String &)
00244 operator << (MOCKPP_NS::String &formatter, const wchar_t * repdata);
00245
00246 #endif // MOCKPP_UNICODE
00247
00248
00257 MOCKPP_API_DECL(MOCKPP_NS::String &)
00258 operator << (MOCKPP_NS::String &formatter, const long &repdata);
00259
00260
00269 MOCKPP_API_DECL(MOCKPP_NS::String &)
00270 operator << (MOCKPP_NS::String &formatter, const MOCKPP_NS::String &repdata);
00271
00272
00273 #ifdef MOCKPP_UNICODE
00274
00283 MOCKPP_API_DECL(MOCKPP_NS::String &)
00284 operator << (MOCKPP_NS::String &formatter, const MOCKPP_STL::string &repdata);
00285
00286 #else // MOCKPP_UNICODE
00287
00296
00297
00298 #endif // MOCKPP_UNICODE
00299
00300
00309 MOCKPP_API_DECL(MOCKPP_NS::String &)
00310 operator << (MOCKPP_NS::String &formatter, const double &repdata);
00311
00312
00321 MOCKPP_API_DECL(MOCKPP_NS::String &)
00322 operator << (MOCKPP_NS::String &formatter, const long double &repdata);
00323
00324
00325 #ifdef MOCKPP_ENABLE_DEFAULT_FORMATTER
00326
00336 template <typename T>
00337 MOCKPP_NS::String & operator << (MOCKPP_NS::String &formatter, const T &o)
00338 {
00339 MOCKPP_NS::String s = MOCKPP_PCHAR("[")
00340 #ifdef MOCKPP_NO_RTTI
00341 + MOCKPP_GET_STRING("[rtti-disabled]")
00342 #else
00343 + MOCKPP_GET_STRING(typeid(o).name())
00344 #endif
00345 + MOCKPP_PCHAR("&]");
00346 formatter << s;
00347 #ifdef __BORLANDC__
00348 MOCKPP_UNUSED(o);
00349 #endif
00350 return formatter;
00351 }
00352
00353
00363 template <typename T>
00364 MOCKPP_NS::String & operator << (MOCKPP_NS::String &formatter, const T * &po)
00365 {
00366 MOCKPP_NS::String s = MOCKPP_PCHAR("[")
00367 #ifdef MOCKPP_NO_RTTI
00368 + MOCKPP_GET_STRING("[rtti-disabled]")
00369 #else
00370 + MOCKPP_GET_STRING(typeid(*po).name())
00371 #endif
00372 + MOCKPP_PCHAR("*]");
00373 formatter << s;
00374 #ifdef __BORLANDC__
00375 MOCKPP_UNUSED(po);
00376 #endif
00377 return formatter;
00378 }
00379
00380
00381 #endif // MOCKPP_ENABLE_DEFAULT_FORMATTER
00382
00383
00384 #ifndef MOCKPP_DISABLE_OSTREAMED
00385
00386 #include <sstream>
00387
00388
00389 MOCKPP_NS_START
00390
00391
00395 template <class T>
00396 MOCKPP_NS::String ostreamed(const T& t)
00397 {
00398 MOCKPP_STD_NS::basic_ostringstream<char> oss;
00399 oss << t;
00400 #ifdef MOCKPP_UNICODE
00401 # ifdef MOCKPP_ALTERNATIVE_STL
00402 return MOCKPP_NS::getUnicode(oss.str().c_str());
00403 # else
00404 return MOCKPP_NS::getUnicode(oss.str());
00405 # endif
00406 #else
00407 # ifdef MOCKPP_ALTERNATIVE_STL
00408 return oss.str().c_str();
00409 # else
00410 return oss.str();
00411 # endif
00412 #endif
00413 }
00414
00415
00416 MOCKPP_NS_END
00417
00418
00422 #define MOCKPP_OSTREAMABLE(T) \
00423 MOCKPP_NS::String & \
00424 operator << (MOCKPP_NS::String &formatter, const T &o) \
00425 { \
00426 formatter << MOCKPP_NS::ostreamed(o); \
00427 return formatter; \
00428 }
00429
00430
00431 #ifdef MOCKPP_UNICODE
00432
00433
00434 MOCKPP_NS_START
00435
00439 template <class T>
00440 MOCKPP_NS::String owstreamed(const T& t)
00441 {
00442 MOCKPP_STD_NS::basic_ostringstream<wchar_t> oss;
00443 oss << t;
00444 #ifndef MOCKPP_ALTERNATIVE_STL
00445 return oss.str();
00446 #else
00447 return oss.str().c_str();
00448 #endif
00449 }
00450
00451 MOCKPP_NS_END
00452
00457 #define MOCKPP_OWSTREAMABLE(T) \
00458 MOCKPP_NS::String & \
00459 operator << (MOCKPP_NS::String &formatter, const T &o) \
00460 { \
00461 formatter << MOCKPP_NS::owstreamed(o); \
00462 return formatter; \
00463 }
00464
00465
00466 #endif // MOCKPP_UNICODE
00467
00468
00469 #endif // MOCKPP_DISABLE_OSTREAMED
00470
00471 #endif // MOCKPP_FORMATTER_H
00472