noboost: Add working implementation for boost.format to get proper Collada error messages. See https://sourceforge.net/projects/assimp/forums/forum/817654/topic/3820367.

Add unit test for this.

Fix build errors due to invalid pch settings in vc9 | release-noboost.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@798 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2010-08-23 17:49:03 +00:00
parent 9623663671
commit 20cc623ecd
6 changed files with 1077 additions and 752 deletions

View File

@@ -1,7 +1,7 @@
/* DEPRECATED placebo workaround, use code/TinyFormatter.h instead.
/* DEPRECATED! - use code/TinyFormatter.h instead.
*
*
* */
@@ -12,14 +12,14 @@
#ifndef BOOST_FORMAT_HPP
#include <string>
#include <vector>
namespace boost
{
class str;
class format
{
friend class str;
public:
format (const std::string& _d)
: d(_d)
@@ -27,26 +27,53 @@ namespace boost
}
template <typename T>
const format& operator % (T in) const
format& operator % (T in)
{
// XXX add replacement for boost::lexical_cast?
std::stringstream 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;
};
class str : public std::string
{
public:
str(const format& f)
{
*((std::string* const)this) = std::string( f.d );
}
};
inline std::string str(const std::string& s) {
return s;
}
}
#else
# error "format.h was already included"
#endif //