2013-06-04 19:50:16 -04:00
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
std::string intToString(int theInt) {
|
|
|
|
|
std::stringstream converter;
|
|
|
|
|
converter << theInt;
|
|
|
|
|
return converter.str();
|
2013-06-23 05:54:58 -04:00
|
|
|
}
|
|
|
|
|
std::string truncateEnd(std::string to_truncate)
|
|
|
|
|
{
|
|
|
|
|
std::string to_return = "";
|
|
|
|
|
for (unsigned int i = 0; i < to_truncate.length()-1; i++)
|
|
|
|
|
to_return = to_return + to_truncate[i];
|
|
|
|
|
return to_return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string removeBeginning(std::string to_remove)
|
|
|
|
|
{
|
|
|
|
|
std::string to_return = "";
|
|
|
|
|
for (unsigned int i = 1; i < to_remove.length(); i++)
|
|
|
|
|
to_return = to_return + to_remove[i];
|
|
|
|
|
return to_return;
|
2013-08-11 00:37:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string replace(std::string first, std::string search, std::string replace) {
|
|
|
|
|
size_t pos = 0;
|
|
|
|
|
while (pos < first.size()-search.size()) {
|
|
|
|
|
pos = first.find(search, pos);
|
|
|
|
|
if (pos == std::string::npos)
|
|
|
|
|
break;
|
|
|
|
|
//std::cout << "Position is " << pos << " size of first is " << first.size() << " size of replace is " << replace.size() << std::endl;
|
|
|
|
|
first = first.replace(pos, search.size(), replace);
|
|
|
|
|
pos++;
|
|
|
|
|
}
|
|
|
|
|
return first;
|
|
|
|
|
}
|