vrshoot
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/boost/format.hpp Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,81 @@ 1.4 + 1.5 + 1.6 + 1.7 +/* DEPRECATED! - use code/TinyFormatter.h instead. 1.8 + * 1.9 + * 1.10 + * */ 1.11 + 1.12 +#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED 1.13 +#define AI_BOOST_FORMAT_DUMMY_INCLUDED 1.14 + 1.15 +#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST) 1.16 + 1.17 +#include <string> 1.18 +#include <vector> 1.19 + 1.20 +namespace boost 1.21 +{ 1.22 + 1.23 + 1.24 + class format 1.25 + { 1.26 + public: 1.27 + format (const std::string& _d) 1.28 + : d(_d) 1.29 + { 1.30 + } 1.31 + 1.32 + template <typename T> 1.33 + format& operator % (T in) 1.34 + { 1.35 + // XXX add replacement for boost::lexical_cast? 1.36 + 1.37 + std::ostringstream ss; 1.38 + ss << in; // note: ss cannot be an rvalue, or the global operator << (const char*) is not called for T == const char*. 1.39 + chunks.push_back( ss.str()); 1.40 + return *this; 1.41 + } 1.42 + 1.43 + 1.44 + operator std::string () const { 1.45 + std::string res; // pray for NRVO to kick in 1.46 + 1.47 + size_t start = 0, last = 0; 1.48 + 1.49 + std::vector<std::string>::const_iterator chunkin = chunks.begin(); 1.50 + 1.51 + for ( start = d.find('%');start != std::string::npos; start = d.find('%',last)) { 1.52 + res += d.substr(last,start-last); 1.53 + last = start+2; 1.54 + if (d[start+1] == '%') { 1.55 + res += "%"; 1.56 + continue; 1.57 + } 1.58 + 1.59 + if (chunkin == chunks.end()) { 1.60 + break; 1.61 + } 1.62 + 1.63 + res += *chunkin++; 1.64 + } 1.65 + res += d.substr(last); 1.66 + return res; 1.67 + } 1.68 + 1.69 + private: 1.70 + std::string d; 1.71 + std::vector<std::string> chunks; 1.72 + }; 1.73 + 1.74 + inline std::string str(const std::string& s) { 1.75 + return s; 1.76 + } 1.77 +} 1.78 + 1.79 + 1.80 +#else 1.81 +# error "format.h was already included" 1.82 +#endif // 1.83 +#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED 1.84 +