2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
|
2010-04-02 00:17:58 +00:00
|
|
|
|
2010-08-23 17:49:03 +00:00
|
|
|
/* DEPRECATED! - use code/TinyFormatter.h instead.
|
2010-04-02 00:17:58 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* */
|
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
#ifndef AI_BOOST_FORMAT_DUMMY_INCLUDED
|
|
|
|
#define AI_BOOST_FORMAT_DUMMY_INCLUDED
|
|
|
|
|
2010-08-23 18:03:34 +00:00
|
|
|
#if (!defined BOOST_FORMAT_HPP) || (defined ASSIMP_FORCE_NOBOOST)
|
2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
#include <string>
|
2010-08-23 17:49:03 +00:00
|
|
|
#include <vector>
|
2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
2010-08-23 17:49:03 +00:00
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
|
|
|
|
class format
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
format (const std::string& _d)
|
|
|
|
: d(_d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T>
|
2010-08-23 17:49:03 +00:00
|
|
|
format& operator % (T in)
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
2010-08-23 17:49:03 +00:00
|
|
|
// XXX add replacement for boost::lexical_cast?
|
|
|
|
|
2011-04-03 15:12:05 +00:00
|
|
|
std::ostringstream ss;
|
2010-08-23 17:49:03 +00:00
|
|
|
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());
|
2008-10-13 16:45:48 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-23 17:49:03 +00:00
|
|
|
operator std::string () const {
|
|
|
|
std::string res; // pray for NRVO to kick in
|
2008-10-13 16:45:48 +00:00
|
|
|
|
2010-08-23 17:49:03 +00:00
|
|
|
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;
|
2008-10-13 16:45:48 +00:00
|
|
|
}
|
2010-08-23 17:49:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string d;
|
|
|
|
std::vector<std::string> chunks;
|
2008-10-13 16:45:48 +00:00
|
|
|
};
|
2010-08-23 17:49:03 +00:00
|
|
|
|
|
|
|
inline std::string str(const std::string& s) {
|
|
|
|
return s;
|
|
|
|
}
|
2008-10-13 16:45:48 +00:00
|
|
|
}
|
|
|
|
|
2010-08-23 17:49:03 +00:00
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
#else
|
|
|
|
# error "format.h was already included"
|
2009-01-12 22:26:11 +00:00
|
|
|
#endif //
|
|
|
|
#endif // !! AI_BOOST_FORMAT_DUMMY_INCLUDED
|
|
|
|
|