vrshoot

view libs/assimp/boost/format.hpp @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line source
4 /* DEPRECATED! - use code/TinyFormatter.h instead.
5 *
6 *
7 * */
9 #ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
10 #define AI_BOOST_FORMAT_DUMMY_INCLUDED
12 #if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)
14 #include <string>
15 #include <vector>
17 namespace boost
18 {
21 class format
22 {
23 public:
24 format (const std::string& _d)
25 : d(_d)
26 {
27 }
29 template <typename T>
30 format& operator % (T in)
31 {
32 // XXX add replacement for boost::lexical_cast?
34 std::ostringstream ss;
35 ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*.
36 chunks.push_back( ss.str());
37 return *this;
38 }
41 operator std::string () const {
42 std::string res; // pray for NRVO to kick in
44 size_t start = 0, last = 0;
46 std::vector<std::string>::const_iterator chunkin = chunks.begin();
48 for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) {
49 res += d.substr(last,start-last);
50 last = start+2;
51 if (d[start+1] == '%') {
52 res += "%";
53 continue;
54 }
56 if (chunkin == chunks.end()) {
57 break;
58 }
60 res += *chunkin++;
61 }
62 res += d.substr(last);
63 return res;
64 }
66 private:
67 std::string d;
68 std::vector<std::string> chunks;
69 };
71 inline std::string str(const std::string& s) {
72 return s;
73 }
74 }
77 #else
78 # error "format.h was already included"
79 #endif //
80 #endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED