As I tried to create a simple parsing test with irrXML, I started to see that it handles all of the EOLs (End Of Lines) as text, even though it was just a cosmetic EOL. After some searching, I found that a person named Bobby Anguelov had the same problem and that this was intended functionality.

Like him, I think this is something that should be handled by irrXML. But then again, it is open source, so anyone can create the functionality one wants. I decided to do a similar solution to the problem as he did, but I didn’t think it was clean enough.

Since another possible solution to the problem was to just trim every string, I figured I might as well try it. However, to my demise, there isn’t any standard way to do this in C++. Despite it being very annoying I also find it somewhat strange, as this is one of the most useful function one can have while handling strings.

After a bit more searching, I stumbled upon the code below:

#include <string>

const std::string whiteSpaces( " \f\n\r\t\v" );

void trimRight(std::string& str, const std::string& trimChars = whiteSpaces) {
    std::string::size_type pos = str.find_last_not_of(trimChars);
    str.erase(pos + 1);
void trimLeft(std::string& str, const std::string& trimChars = whiteSpaces) {
    std::string::size_type pos = str.find_first_not_of(trimChars);
    str.erase(0, pos);

void trim(std::string& str, const std::string& trimChars = whiteSpaces) {
    trimRight(str, trimChars);
    trimLeft(str, trimChars);

This is a very clean solution and I am stunned at the simplicity of it. I haven’t made any speed checks, but I havent found any notable speed decrease while parsing a single Collada document. Of course there will be some decrease, but since the documents should only be parsed once during the life of the instance of the program, I think it’s a cheap price to pay.