Initial attempt at new python wrapper

This commit is contained in:
Thomas Krijnen
2012-10-21 17:54:09 +02:00
parent da616ffd64
commit 509c34d66a
29 changed files with 3358 additions and 422 deletions
+20 -4
View File
@@ -24,9 +24,10 @@
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcSpfStream.h"
#include "../ifcparse/IfcWritableEntity.h"
using namespace IfcParse;
@@ -468,7 +469,13 @@ TokenArgument::operator IfcUtil::IfcSchemaEntity() const { return token.first->f
TokenArgument::operator IfcEntities() const { throw IfcException("Argument is not a list of entities"); }
unsigned int TokenArgument::Size() const { return 1; }
ArgumentPtr TokenArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
std::string TokenArgument::toString(bool upper) const { return TokenFunc::toString(token); }
std::string TokenArgument::toString(bool upper) const {
if ( upper && TokenFunc::isString(token) ) {
return IfcWrite::IfcCharacterEncoder(TokenFunc::asString(token));
} else {
return TokenFunc::toString(token);
}
}
bool TokenArgument::isNull() const { return TokenFunc::isOperator(token,'$'); }
//
// Functions for casting the EntityArgument to other types
@@ -488,10 +495,18 @@ ArgumentPtr EntityArgument::operator [] (unsigned int i) const { throw IfcExcept
std::string EntityArgument::toString(bool upper) const {
ArgumentPtr arg = entity->wrappedValue();
IfcParse::TokenArgument* token_arg = dynamic_cast<IfcParse::TokenArgument*>(arg);
std::string token_string = ( token_arg ) ? TokenFunc::toString(token_arg->token) : "";
const bool is_string = TokenFunc::isString(token_arg->token);
std::string token_string = token_arg ? (is_string
? TokenFunc::asString(token_arg->token)
: TokenFunc::toString(token_arg->token))
: std::string();
std::string dt = Ifc2x3::Type::ToString(entity->type());
if ( upper ) {
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
if (is_string) token_string = IfcWrite::IfcCharacterEncoder(token_string);
} else {
token_string.insert(token_string.begin(),'\'');
token_string.push_back('\'');
}
return dt + "(" + token_string + ")";
}
@@ -662,7 +677,8 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* f) {
if ( currentId ) {
try {
e = new Entity(currentId,this);
entity = Ifc2x3::SchemaEntity(e);
//entity = Ifc2x3::SchemaEntity(e);
entity = new Ifc::IfcUntypedEntity(e);
} catch (IfcException ex) {
currentId = 0;
Logger::Message(Logger::LOG_ERROR,ex.what());