4 * Inline implementations of TCEString class.
6 * @author Pekka Jääskeläinen 2008 (pekka.jaaskelainen@tut.fi)
10 #include "StringTools.hh"
11 #include "Conversion.hh"
14 * Returns true in case the string starts with the given string.
17 TCEString::startsWith(const std::string& str) const {
18 return str.size() <= size() && substr(0, str.size()) == str;
22 * Returns true in case the string ends with the given string.
25 TCEString::endsWith(const std::string& str) const {
26 return str.size() <= size() && substr(size() - str.size(), size()) == str;
30 * Appends appender that is convertible to integer to string toAppend.
32 * @return returns reference toAppend with appended integer.
34 template<typename IntegerType>
36 TCEString::appendInteger(
37 std::string& toAppend,
38 const IntegerType& appender) {
40 toAppend += Conversion::toString(appender);
45 * Appends appender that is convertible to integer to string toAppend.
47 * @return returns string of toAppend with appended integer.
49 template<typename IntegerType>
51 TCEString::appendInteger(
53 const IntegerType& appender) {
55 return std::string(toAppend + Conversion::toString(appender));
59 * Makes single string from container's elements separated by delimiter.
61 * Default delimiter is ", ".
64 template<typename IterableContainer>
66 TCEString::makeString(
67 const IterableContainer& container,
68 const std::string& separator) {
72 typename IterableContainer::const_iterator it;
73 for (it = container.begin(); it != container.end(); it++) {
74 appendToNonEmpty(result, separator);
76 Conversion::toString<typename IterableContainer::value_type>(*it);