diff --git a/code/BoostWorkaround/boost/format.hpp b/code/BoostWorkaround/boost/format.hpp index 5d02899ab..83c164cd3 100644 --- a/code/BoostWorkaround/boost/format.hpp +++ b/code/BoostWorkaround/boost/format.hpp @@ -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 +#include namespace boost { - class str; + class format { - friend class str; public: format (const std::string& _d) : d(_d) @@ -27,26 +27,53 @@ namespace boost } template - 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::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 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 // diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 02c6be77a..64fefc7c1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -112,6 +112,8 @@ SOURCE_GROUP( tests FILES unit/utTriangulate.h unit/utVertexTriangleAdjacency.cpp unit/utVertexTriangleAdjacency.h + unit/utNoBoostTest.cpp + unit/utNoBoostTest.h ) add_executable( unit @@ -158,6 +160,8 @@ add_executable( unit unit/utTriangulate.h unit/utVertexTriangleAdjacency.cpp unit/utVertexTriangleAdjacency.h + unit/utNoBoostTest.cpp + unit/utNoBoostTest.h unit/BoostWorkaround/tupletest.cpp ../contrib/cppunit-1.12.1/src/cppunit/AdditionalMessage.cpp ../contrib/cppunit-1.12.1/src/cppunit/Asserter.cpp diff --git a/test/unit/utNoBoostTest.cpp b/test/unit/utNoBoostTest.cpp new file mode 100644 index 000000000..cf812c8f0 --- /dev/null +++ b/test/unit/utNoBoostTest.cpp @@ -0,0 +1,18 @@ + +#include "UnitTestPCH.h" +#include "utNoBoostTest.h" + + +CPPUNIT_TEST_SUITE_REGISTRATION (NoBoostTest); + +// ------------------------------------------------------------------------------------------------ +void NoBoostTest :: testFormat() +{ + + CPPUNIT_ASSERT( noboost::str( noboost::format("Ahoi!") ) == "Ahoi!" ); + CPPUNIT_ASSERT( noboost::str( noboost::format("Ahoi! %%") ) == "Ahoi! %" ); + CPPUNIT_ASSERT( noboost::str( noboost::format("Ahoi! %s") ) == "Ahoi! " ); + CPPUNIT_ASSERT( noboost::str( noboost::format("Ahoi! %s") % "!!" ) == "Ahoi! !!" ); + CPPUNIT_ASSERT( noboost::str( noboost::format("Ahoi! %s") % "!!" % "!!" ) == "Ahoi! !!" ); + CPPUNIT_ASSERT( noboost::str( noboost::format("%s%s%s") % "a" % std::string("b") % "c" ) == "abc" ); +} diff --git a/test/unit/utNoBoostTest.h b/test/unit/utNoBoostTest.h new file mode 100644 index 000000000..4b492e8a1 --- /dev/null +++ b/test/unit/utNoBoostTest.h @@ -0,0 +1,36 @@ +#ifndef TESTNOBOOST_H +#define TESTNOBOOST_H + +namespace noboost { + +#include "..\..\code\BoostWorkaround\boost\format.hpp" + using boost::format; + using boost::str; + +} + +using namespace std; +using namespace Assimp; + +class NoBoostTest : public CPPUNIT_NS :: TestFixture +{ + CPPUNIT_TEST_SUITE (NoBoostTest); + CPPUNIT_TEST (testFormat); + CPPUNIT_TEST_SUITE_END (); + + public: + void setUp (void) { + } + void tearDown (void) { + } + + protected: + + void testFormat (void); + + private: + + +}; + +#endif \ No newline at end of file diff --git a/workspaces/vc9/UnitTest.vcproj b/workspaces/vc9/UnitTest.vcproj index 5f6ee0e3a..76c496508 100644 --- a/workspaces/vc9/UnitTest.vcproj +++ b/workspaces/vc9/UnitTest.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -1388,6 +1364,14 @@ RelativePath="..\..\test\unit\utMaterialSystem.h" > + + + + @@ -1494,62 +1478,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -1558,6 +1486,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1566,6 +1502,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1574,6 +1518,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1582,6 +1534,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1590,6 +1550,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1598,6 +1566,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1606,6 +1582,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1626,62 +1610,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -1690,6 +1618,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1698,6 +1634,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1706,6 +1650,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1714,6 +1666,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1722,6 +1682,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1730,6 +1698,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1738,6 +1714,14 @@ UsePrecompiledHeader="0" /> + + + @@ -1767,62 +1751,6 @@ UsePrecompiledHeader="1" /> - - - - - - - - - - - - - - - - - - - - - @@ -1831,6 +1759,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1839,6 +1775,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1847,6 +1791,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1855,6 +1807,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1863,6 +1823,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1871,6 +1839,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1879,6 +1855,14 @@ UsePrecompiledHeader="1" /> + + + diff --git a/workspaces/vc9/assimp.vcproj b/workspaces/vc9/assimp.vcproj index 23ec3e0c7..e6e56cda3 100644 --- a/workspaces/vc9/assimp.vcproj +++ b/workspaces/vc9/assimp.vcproj @@ -3420,6 +3420,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3428,6 +3436,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3436,6 +3452,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3444,6 +3468,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3452,6 +3484,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3460,6 +3500,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3468,6 +3516,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3476,6 +3532,14 @@ UsePrecompiledHeader="0" /> + + + + + + @@ -3500,6 +3572,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3508,6 +3588,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3516,6 +3604,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3524,6 +3620,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3532,6 +3636,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3540,6 +3652,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3548,6 +3668,14 @@ UsePrecompiledHeader="0" /> + + + + + + @@ -3584,6 +3720,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3592,6 +3736,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3600,6 +3752,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3608,6 +3768,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3616,6 +3784,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3624,6 +3800,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3632,6 +3816,14 @@ UsePrecompiledHeader="0" /> + + + + + + @@ -3660,6 +3860,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3668,6 +3876,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3676,6 +3892,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3684,6 +3908,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3692,6 +3924,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3700,6 +3940,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3708,6 +3956,14 @@ UsePrecompiledHeader="0" /> + + +