} // eo join_string(const std::list< std::string >&,const std::string&)
+/** @brief same as join_string for list, except uses a vector */
+std::string join_string(
+ const std::vector< std::string >& parts,
+ const std::string& delimiter
+)
+{
+ std::string result;
+ if (! parts.empty() )
+ {
+ std::vector< std::string >::const_iterator it= parts.begin();
+ result = *it;
+ while ( ++it != parts.end() )
+ {
+ result+= delimiter;
+ result+= *it;
+ }
+ }
+ return result;
+} // eo join_string(const std::vector< std::string >&,const std::string&)
+
+
/*
** conversions
#define __STRINGFUNC_HXX
#include <list>
+#include <vector>
#include <string>
#include <sstream>
#include <stdexcept>
const std::string& delimiter = "\n"
);
+std::string join_string(
+ const std::vector< std::string >& parts,
+ const std::string& delimiter = "\n"
+);
+
/*
** conversions:
} // eo JoinString1
+BOOST_AUTO_TEST_CASE(JoinStringVector)
+{
+ std::vector< std::string > parts;
+ get_push_back_filler(parts)("1")("2")("drei");
+
+ std::string joined_string= join_string(parts,"/");
+ // we should have slashes between the strings:
+ BOOST_CHECK_EQUAL( std::string("1/2/drei") , joined_string );
+
+ parts.push_back( std::string() );
+ joined_string= join_string(parts,"/");
+ // now we should have an additional trailing slash:
+ BOOST_CHECK_EQUAL( std::string("1/2/drei/") , joined_string );
+
+ parts.insert(parts.begin(), "");
+ joined_string= join_string(parts,"/");
+ // now we should have an additional leading slash:
+ BOOST_CHECK_EQUAL( std::string("/1/2/drei/") , joined_string );
+
+} // eo JoinStringVector
+
BOOST_AUTO_TEST_CASE(ConversionStringInt)
{