summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/assimp/code/BoostWorkaround/boost/format.hpp
blob: d250c5533008d0b3f1035385fc8f615291a196c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81



/* DEPRECATED! - use code/TinyFormatter.h instead.
 *
 *
 * */

#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
#define AI_BOOST_FORMAT_DUMMY_INCLUDED

#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)

#include <string>
#include <vector>

namespace boost
{


	class format
	{
	public:
		format (const std::string& _d)
			: d(_d)
		{
		}

		template <typename T>
		format& operator % (T in) 
		{
			// XXX add replacement for boost::lexical_cast?
			
			std::ostringstream ss;
			ss << in; // note: ss cannot be an rvalue, or  the global operator << (const char*) is not called for T == const char*.
			chunks.push_back( ss.str());
			return *this;
		}


		operator std::string () const {
			std::string res; // pray for NRVO to kick in

			size_t start = 0, last = 0;

			std::vector<std::string>::const_iterator chunkin = chunks.begin();

			for ( start = d.find('%');start != std::string::npos;  start = d.find('%',last)) {
				res += d.substr(last,start-last);
				last = start+2;
				if (d[start+1] == '%') {
					res += "%";
					continue;
				}

				if (chunkin == chunks.end()) {
					break;
				}

				res += *chunkin++;
			}
			res += d.substr(last);
			return res;
		}

	private:
		std::string d;
		std::vector<std::string> chunks;
	};

	inline std::string str(const std::string& s) {
		return s;
	} 
}


#else
#	error "format.h was already included"
#endif //
#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED