Skip to content

Commit

Permalink
Fixed a bug in Collada importer - it didn't take tabs as whitespace.
Browse files Browse the repository at this point in the history
Also greatly improved the exceptions that are thrown if invalid characters are encountered.
  • Loading branch information
Martin Pecka committed May 29, 2015
1 parent bd18c77 commit e6b216f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions StringHelper.h
Expand Up @@ -32,6 +32,7 @@
#include <vector>
#include <string>
#include <sstream>
#include <stdexcept>
#include "vec3.h"
#include "mat4.h"

Expand Down Expand Up @@ -72,6 +73,7 @@ class StringHelper
delims.push_back(' ');
delims.push_back('\n');
delims.push_back('\r');
delims.push_back('\t');
std::vector<T> tarray;
std::string str="";
int slen = string.length();
Expand All @@ -84,8 +86,14 @@ class StringHelper
tarray.push_back(f);
str = "";
}
else
throw 1;
else {
std::stringstream ss;
ss << "COLLADA import error: the following string cannot be parsed as array element: '";
ss << str << "', with ASCII codes ";
for (int j=0; j<str.length(); j++)
ss << (int)str[j] << " ";
throw std::runtime_error(ss.str());
}
}
}
else
Expand All @@ -97,8 +105,14 @@ class StringHelper
tarray.push_back(f);
str = "";
}
else
throw 1;
else {
std::stringstream ss;
ss << "COLLADA import error: the following string cannot be parsed as array element: '";
ss << str << "', with ASCII codes ";
for (int j=0; j<str.length(); j++)
ss << (int)str[j] << " ";
throw std::runtime_error(ss.str());
}
}

return tarray;
Expand Down

0 comments on commit e6b216f

Please sign in to comment.