lunch-rest/restaurants/functions.cpp

18 lines
523 B
C++

#include "functions.hpp"
std::string LunchRest::nodeToText(xmlpp::Node *node) {
return dynamic_cast<const xmlpp::ContentNode *>(node)->get_content();
}
std::string LunchRest::trim(const std::string &input) {
const std::string whitespace = "\t\n\v\f\r ";
std::string ret = input;
ret.erase(0, ret.find_first_not_of(whitespace));
ret.erase(ret.find_last_not_of(whitespace) + 1);
for(size_t i = 0; i < ret.length(); i++) {
if(ret[i] == '\n')
ret[i] = ' ';
}
return ret;
}