mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 10:32:42 +00:00
Correctly interpret integer tokens without a leading #. Bug report: https://sourceforge.net/projects/ifcopenshell/forums/forum/1782717/topic/5280357
This commit is contained in:
@@ -311,9 +311,13 @@ bool TokenFunc::isDatatype(Token t) {
|
|||||||
return ! isOperator(t) && startsWith(t, 'I');
|
return ! isOperator(t) && startsWith(t, 'I');
|
||||||
}
|
}
|
||||||
int TokenFunc::asInt(Token t) {
|
int TokenFunc::asInt(Token t) {
|
||||||
if ( ! isIdentifier(t) ) throw IfcException("Token is not an identifier");
|
|
||||||
const std::string str = asString(t);
|
const std::string str = asString(t);
|
||||||
return atoi(str.c_str()+1);
|
// In case of an ENTITY_INSTANCE_NAME skip the leading #
|
||||||
|
const char* start = str.c_str() + (isIdentifier(t) ? 1 : 0);
|
||||||
|
char* end;
|
||||||
|
long result = strtol(start,&end,10);
|
||||||
|
if ( start == end ) throw IfcException("Token is not an integer or identifier");
|
||||||
|
return (int) result;
|
||||||
}
|
}
|
||||||
bool TokenFunc::asBool(Token t) {
|
bool TokenFunc::asBool(Token t) {
|
||||||
const std::string str = asString(t);
|
const std::string str = asString(t);
|
||||||
|
|||||||
Reference in New Issue
Block a user