vrshoot

annotate libs/assimp/boost/format.hpp @ 2:334d17aed7de

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