Make header values writable

This commit is contained in:
Thomas Krijnen
2015-01-16 16:26:40 +00:00
parent f6f541ee3b
commit 7b17c2dccd
10 changed files with 370 additions and 165 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ int main(int argc, char** argv) {
// The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
// convenience functions for working with geometry in IFC files. // convenience functions for working with geometry in IFC files.
IfcHierarchyHelper file; IfcHierarchyHelper file;
file.filename("IfcOpenHouse.ifc"); file.header().file_name().name("IfcOpenHouse.ifc");
// Start by adding a wall to the file, initially leaving most attributes blank. // Start by adding a wall to the file, initially leaving most attributes blank.
IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase( IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase(
+9 -17
View File
@@ -51,13 +51,7 @@ private:
IfcSpfHeader _header; IfcSpfHeader _header;
std::string _filename; void setDefaultHeaderValues();
std::string _timestamp;
std::string _author;
std::string _author_email;
std::string _author_organisation;
void initTimestamp();
public: public:
IfcParse::IfcSpfLexer* tokens; IfcParse::IfcSpfLexer* tokens;
IfcParse::IfcSpfStream* stream; IfcParse::IfcSpfStream* stream;
@@ -76,7 +70,11 @@ public:
template <class T> template <class T>
typename T::list::ptr EntitiesByType() { typename T::list::ptr EntitiesByType() {
IfcEntityList::ptr untyped_list = EntitiesByType(T::Class()); IfcEntityList::ptr untyped_list = EntitiesByType(T::Class());
return untyped_list->as<T>(); if (untyped_list) {
return untyped_list->as<T>();
} else {
return typename T::list::ptr(new typename T::list);
}
} }
/// Returns all entities in the file that match the positional argument. /// Returns all entities in the file that match the positional argument.
@@ -110,16 +108,10 @@ public:
void AddEntity(IfcUtil::IfcBaseClass* entity); void AddEntity(IfcUtil::IfcBaseClass* entity);
void AddEntities(IfcEntityList::ptr es); void AddEntities(IfcEntityList::ptr es);
void filename(const std::string& s);
std::string filename() const;
void timestamp(const std::string& s);
std::string timestamp() const;
void author(const std::string& name, const std::string& email, const std::string& organisation);
std::string authorName() const;
std::string authorEmail() const;
std::string authorOrganisation() const;
const IfcSpfHeader& header() const { return _header; } const IfcSpfHeader& header() const { return _header; }
IfcSpfHeader& header() { return _header; }
std::string createTimestamp() const;
bool create_latebound_entities() const { return _create_latebound_entities; } bool create_latebound_entities() const { return _create_latebound_entities; }
}; };
+72 -52
View File
@@ -420,25 +420,31 @@ EntityArgument::EntityArgument(const Token& t) {
// Reads the arguments from a list of token // Reads the arguments from a list of token
// Aditionally, stores the ids (i.e. #[\d]+) in a vector // Aditionally, stores the ids (i.e. #[\d]+) in a vector
// //
ArgumentList::ArgumentList(IfcSpfLexer* t, std::vector<unsigned int>& ids) { void ArgumentList::read(IfcSpfLexer* t, std::vector<unsigned int>& ids) {
IfcParse::IfcFile* file = t->file; IfcParse::IfcFile* file = t->file;
Token next = t->Next(); Token next = t->Next();
while( next.second || next.first ) { while( next.second || next.first ) {
if ( TokenFunc::isOperator(next,',') ) {} if ( TokenFunc::isOperator(next,',') ) {
else if ( TokenFunc::isOperator(next,')') ) break; // do nothing
else if ( TokenFunc::isOperator(next,'(') ) Push( new ArgumentList(t,ids) ); } else if ( TokenFunc::isOperator(next,')') ) {
else { break;
if ( TokenFunc::isIdentifier(next) ) ids.push_back(TokenFunc::asInt(next)); } else if ( TokenFunc::isOperator(next,'(') ) {
if ( TokenFunc::isKeyword(next) ) { ArgumentList* list = new ArgumentList();
list->read(t, ids);
push(list);
} else {
if ( TokenFunc::isIdentifier(next) ) {
ids.push_back(TokenFunc::asInt(next));
} if ( TokenFunc::isKeyword(next) ) {
t->Next(); t->Next();
try { try {
Push ( new EntityArgument(next) ); push ( new EntityArgument(next) );
} catch ( IfcException& e ) { } catch ( IfcException& e ) {
Logger::Message(Logger::LOG_ERROR,e.what()); Logger::Message(Logger::LOG_ERROR,e.what());
} }
} else { } else {
Push ( new TokenArgument(next) ); push ( new TokenArgument(next) );
} }
} }
next = t->Next(); next = t->Next();
@@ -461,7 +467,7 @@ IfcUtil::ArgumentType ArgumentList::type() const {
} }
} }
void ArgumentList::Push(Argument* l) { void ArgumentList::push(Argument* l) {
list.push_back(l); list.push_back(l);
} }
@@ -523,10 +529,22 @@ ArgumentList::operator IfcEntityListList::ptr() const {
} }
unsigned int ArgumentList::size() const { return (unsigned int) list.size(); } unsigned int ArgumentList::size() const { return (unsigned int) list.size(); }
Argument* ArgumentList::operator [] (unsigned int i) const { Argument* ArgumentList::operator [] (unsigned int i) const {
if ( i >= list.size() ) if ( i >= list.size() ) {
throw IfcException("Argument index out of range"); throw IfcException("Argument index out of range");
}
return list[i]; return list[i];
} }
void ArgumentList::set(unsigned int i, Argument* argument) {
while (size() < i) {
push(new TokenArgument(Token(static_cast<IfcSpfLexer*>(0), '$')));
}
if (i < size()) {
delete list[i];
list[i] = argument;
} else {
list.push_back(argument);
}
}
std::string ArgumentList::toString(bool upper) const { std::string ArgumentList::toString(bool upper) const {
std::stringstream ss; std::stringstream ss;
ss << "("; ss << "(";
@@ -666,7 +684,8 @@ void Entity::Load(std::vector<unsigned int>& ids, bool seek) const {
_type = IfcSchema::Type::FromString(TokenFunc::asString(datatype)); _type = IfcSchema::Type::FromString(TokenFunc::asString(datatype));
} }
Token open = file->tokens->Next(); Token open = file->tokens->Next();
args = new ArgumentList(file->tokens, ids); args = new ArgumentList();
args->read(file->tokens, ids);
unsigned int old_offset = file->tokens->stream->Tell(); unsigned int old_offset = file->tokens->stream->Tell();
Token semilocon = file->tokens->Next(); Token semilocon = file->tokens->Next();
if ( ! TokenFunc::isOperator(semilocon,';') ) file->tokens->stream->Seek(old_offset); if ( ! TokenFunc::isOperator(semilocon,';') ) file->tokens->stream->Seek(old_offset);
@@ -697,7 +716,10 @@ std::string Entity::toString(bool upper) const {
if ( upper ) { if ( upper ) {
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p); for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
} }
ss << "#" << _id << "=" << dt << args->toString(upper); if (!IfcSchema::Type::IsSimple(type()) || _id != 0) {
ss << "#" << _id << "=";
}
ss << dt << args->toString(upper);
return ss.str(); return ss.str();
} }
@@ -721,12 +743,12 @@ IfcWrite::IfcWritableEntity* Entity::isWritable() {
IfcFile::IfcFile(bool create_latebound_entities) IfcFile::IfcFile(bool create_latebound_entities)
: _create_latebound_entities(create_latebound_entities) : _create_latebound_entities(create_latebound_entities)
, stream(0)
, lastId(0)
, tokens(0)
, MaxId(0)
{ {
stream = 0; setDefaultHeaderValues();
lastId = 0;
tokens = 0;
MaxId = 0;
initTimestamp();
} }
// //
@@ -998,25 +1020,7 @@ IfcFile::entity_by_id_t::const_iterator IfcFile::end() const {
} }
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) { std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
os << "ISO-10303-21;" << std::endl; f.header().write(os);
os << "HEADER;" << std::endl;
os << "FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');" << std::endl;
os << "FILE_NAME("
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.filename())) << ","
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.timestamp())) << ",("
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorOrganisation())) << "),("
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorName())) << ","
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorEmail()))
<< "),'IfcOpenShell " << IFCOPENSHELL_VERSION
<< "','IfcOpenShell " << IFCOPENSHELL_VERSION
<< "','');" << std::endl;
#ifdef USE_IFC4
os << "FILE_SCHEMA(('IFC4'));" << std::endl;
#else
os << "FILE_SCHEMA(('IFC2X3'));" << std::endl;
#endif
os << "ENDSEC;" << std::endl;
os << "DATA;" << std::endl;
for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) { for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) {
const IfcUtil::IfcBaseClass* e = it->second; const IfcUtil::IfcBaseClass* e = it->second;
@@ -1029,26 +1033,20 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
return os; return os;
} }
void IfcFile::filename(const std::string& s) { _filename = s; } std::string IfcFile::createTimestamp() const {
std::string IfcFile::filename() const { return _filename; }
void IfcFile::timestamp(const std::string& s) { _timestamp = s; }
std::string IfcFile::timestamp() const { return _timestamp; }
void IfcFile::author(const std::string& name, const std::string& email, const std::string& organisation) {
_author = name;
_author_email = email;
_author_organisation = organisation;
}
std::string IfcFile::authorName() const { return _author; }
std::string IfcFile::authorEmail() const { return _author_email; }
std::string IfcFile::authorOrganisation() const { return _author_organisation; }
void IfcFile::initTimestamp() {
char buf[255]; char buf[255];
time_t t; time_t t;
time(&t); time(&t);
struct tm * ti = localtime (&t);
struct tm* ti = localtime (&t);
std::string result = "";
if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) { if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) {
_timestamp = std::string(buf); result = std::string(buf);
} }
return result;
} }
IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) { IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) {
@@ -1079,3 +1077,25 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty
return l; return l;
} }
void IfcFile::setDefaultHeaderValues() {
const std::string empty_string = "";
std::vector<std::string> file_description, schema_identifiers, empty_vector;
file_description.push_back("ViewDefinition [CoordinationView]");
schema_identifiers.push_back(IfcSchema::Identifier);
header().file_description().description(file_description);
header().file_description().implementation_level("2;1");
header().file_name().name(empty_string);
header().file_name().time_stamp(createTimestamp());
header().file_name().author(empty_vector);
header().file_name().organization(empty_vector);
header().file_name().preprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name().originating_system("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name().authorization(empty_string);
header().file_schema().schema_identifiers(schema_identifiers);
}
+7 -3
View File
@@ -122,11 +122,12 @@ namespace IfcParse {
class ArgumentList: public Argument { class ArgumentList: public Argument {
private: private:
std::vector<Argument*> list; std::vector<Argument*> list;
void Push(Argument* l); void push(Argument* l);
public: public:
ArgumentList(IfcSpfLexer* t, std::vector<unsigned int>& ids);
~ArgumentList(); ~ArgumentList();
void read(IfcSpfLexer* t, std::vector<unsigned int>& ids);
IfcUtil::ArgumentType type() const; IfcUtil::ArgumentType type() const;
operator int() const; operator int() const;
@@ -140,7 +141,10 @@ namespace IfcParse {
operator IfcEntityList::ptr() const; operator IfcEntityList::ptr() const;
operator IfcEntityListList::ptr() const; operator IfcEntityListList::ptr() const;
unsigned int size() const; unsigned int size() const;
Argument* operator [] (unsigned int i) const; Argument* operator [] (unsigned int i) const;
void set(unsigned int i, Argument*);
std::string toString(bool upper=false) const; std::string toString(bool upper=false) const;
bool isNull() const; bool isNull() const;
}; };
@@ -206,7 +210,7 @@ namespace IfcParse {
/// ============================ /// ============================
class Entity : public IfcAbstractEntity { class Entity : public IfcAbstractEntity {
private: private:
mutable Argument* args; mutable ArgumentList* args;
mutable IfcSchema::Type::Enum _type; mutable IfcSchema::Type::Enum _type;
public: public:
/// The EXPRESS ENTITY_INSTANCE_NAME /// The EXPRESS ENTITY_INSTANCE_NAME
+48 -6
View File
@@ -62,14 +62,17 @@ void IfcSpfHeader::read() {
readTerminal(HEADER, TRAILING_SEMICOLON); readTerminal(HEADER, TRAILING_SEMICOLON);
readTerminal(FILE_DESCRIPTION, TRAILING_PAREN); readTerminal(FILE_DESCRIPTION, TRAILING_PAREN);
delete _file_description;
_file_description = new FileDescription(_lexer); _file_description = new FileDescription(_lexer);
readSemicolon(); readSemicolon();
readTerminal(FILE_NAME, TRAILING_PAREN); readTerminal(FILE_NAME, TRAILING_PAREN);
delete _file_name;
_file_name = new FileName(_lexer); _file_name = new FileName(_lexer);
readSemicolon(); readSemicolon();
readTerminal(FILE_SCHEMA, TRAILING_PAREN); readTerminal(FILE_SCHEMA, TRAILING_PAREN);
delete _file_schema;
_file_schema = new FileSchema(_lexer); _file_schema = new FileSchema(_lexer);
readSemicolon(); readSemicolon();
} }
@@ -83,26 +86,65 @@ bool IfcSpfHeader::tryRead() {
} }
} }
const FileDescription& IfcSpfHeader::file_description() { void IfcSpfHeader::write(std::ostream& os) const {
os << ISO_10303_21 << ";" << "\n";
os << HEADER << ";" << "\n";
os << file_description().toString(true) << "\n";
os << file_name().toString(true) << "\n";
os << file_schema().toString(true) << "\n";
os << ENDSEC << ";" << "\n";
os << DATA << ";" << "\n";
}
const FileDescription& IfcSpfHeader::file_description() const {
if (_file_description) { if (_file_description) {
return *_file_description; return *_file_description;
} else { } else {
throw IfcException("File description not read"); throw IfcException("File description not set");
} }
} }
const FileName& IfcSpfHeader::file_name() { const FileName& IfcSpfHeader::file_name() const {
if (_file_name) { if (_file_name) {
return *_file_name; return *_file_name;
} else { } else {
throw IfcException("File name not read"); throw IfcException("File name not set");
} }
} }
const FileSchema& IfcSpfHeader::file_schema() { const FileSchema& IfcSpfHeader::file_schema() const {
if (_file_schema) { if (_file_schema) {
return *_file_schema; return *_file_schema;
} else { } else {
throw IfcException("File schema not read"); throw IfcException("File schema not set");
} }
} }
FileDescription& IfcSpfHeader::file_description() {
if (_file_description) {
return *_file_description;
} else {
throw IfcException("File description not set");
}
}
FileName& IfcSpfHeader::file_name() {
if (_file_name) {
return *_file_name;
} else {
throw IfcException("File name not set");
}
}
FileSchema& IfcSpfHeader::file_schema() {
if (_file_schema) {
return *_file_schema;
} else {
throw IfcException("File schema not set");
}
}
FileDescription::FileDescription(IfcSpfLexer* lexer) : HeaderEntity(FILE_DESCRIPTION, lexer) {}
FileName::FileName(IfcSpfLexer* lexer) : HeaderEntity(FILE_NAME, lexer) {}
FileSchema::FileSchema(IfcSpfLexer* lexer) : HeaderEntity(FILE_SCHEMA, lexer) {}
+109 -19
View File
@@ -21,45 +21,124 @@
#define IFCSPFHEADER_H #define IFCSPFHEADER_H
#include "../ifcparse/IfcSpfStream.h" #include "../ifcparse/IfcSpfStream.h"
#include "../ifcparse/IfcWrite.h"
namespace IfcParse { namespace IfcParse {
class HeaderEntity { class HeaderEntity : public IfcAbstractEntity {
private: private:
ArgumentList* list; ArgumentList* _list;
const char * const _datatype;
protected: protected:
HeaderEntity(IfcSpfLexer* lexer) { HeaderEntity(const char * const datatype, IfcSpfLexer* lexer)
: _datatype(datatype), _list(0)
{
std::vector<unsigned int> ids; std::vector<unsigned int> ids;
list = new ArgumentList(lexer, ids); _list = new ArgumentList();
}; if (lexer) {
_list->read(lexer, ids);
}
}
~HeaderEntity() {
delete _list;
}
void setArgument(unsigned int i, const std::string& s) {
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this);
argument->set(s);
_list->set(i, argument);
}
void setArgument(unsigned int i, const std::vector<std::string>& s) {
IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this);
argument->set(s);
_list->set(i, argument);
}
public:
Argument* getArgument(unsigned int i) const { Argument* getArgument(unsigned int i) const {
return (*list)[i]; return (*_list)[i];
}
Argument* getArgument(unsigned int i) {
return (*_list)[i];
}
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index) {
return IfcEntityList::ptr(new IfcEntityList);
}
std::string datatype() const {
return _datatype;
}
unsigned int getArgumentCount() const {
return _list->size();
}
IfcSchema::Type::Enum type() const {
return (IfcSchema::Type::Enum) -1;
}
bool is(IfcSchema::Type::Enum v) const {
return false;
}
std::string toString(bool upper=false) const {
std::stringstream ss;
ss << _datatype << _list->toString(upper) << ";";
return ss.str();
}
unsigned int id() {
return 0;
}
IfcWrite::IfcWritableEntity* isWritable() {
return 0;
} }
}; };
class FileDescription : private HeaderEntity { class FileDescription : public HeaderEntity {
public: public:
FileDescription(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} explicit FileDescription(IfcSpfLexer* = 0);
std::vector<std::string> description() const { return *getArgument(0); } std::vector<std::string> description() const { return *getArgument(0); }
std::string implementation_level() const { return *getArgument(1); } std::string implementation_level() const { return *getArgument(1); }
void description(const std::vector<std::string>& value) { setArgument(0, value); }
void implementation_level(const std::string& value) { setArgument(1, value); }
}; };
class FileName : private HeaderEntity { class FileName : public HeaderEntity {
public: public:
FileName(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} explicit FileName(IfcSpfLexer* = 0);
std::string name() const { return *getArgument(0); } std::string name() const { return *getArgument(0); }
std::string time_stamp() const { return *getArgument(1); } std::string time_stamp() const { return *getArgument(1); }
std::vector<std::string> author() const { return *getArgument(2); } std::vector<std::string> author() const { return *getArgument(2); }
std::vector<std::string> organization() const { return *getArgument(3); } std::vector<std::string> organization() const { return *getArgument(3); }
std::string preprocessor_version() const { return *getArgument(4); } std::string preprocessor_version() const { return *getArgument(4); }
std::string originating_system() const { return *getArgument(5); } std::string originating_system() const { return *getArgument(5); }
std::string authorization()const { return *getArgument(6); } std::string authorization() const { return *getArgument(6); }
void name(const std::string& value) { setArgument(0, value); }
void time_stamp(const std::string& value) { setArgument(1, value); }
void author(const std::vector<std::string>& value) { setArgument(2, value); }
void organization(const std::vector<std::string>& value) { setArgument(3, value); }
void preprocessor_version(const std::string& value) { setArgument(4, value); }
void originating_system(const std::string& value) { setArgument(5, value); }
void authorization(const std::string& value) { setArgument(6, value); }
}; };
class FileSchema : private HeaderEntity { class FileSchema : public HeaderEntity {
public: public:
FileSchema(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} explicit FileSchema(IfcSpfLexer* = 0);
std::vector<std::string> schema_identifiers() const { return *getArgument(0); } std::vector<std::string> schema_identifiers() const { return *getArgument(0); }
void schema_identifiers(const std::vector<std::string>& value) { setArgument(0, value); }
}; };
class IfcSpfHeader { class IfcSpfHeader {
@@ -69,7 +148,7 @@ private:
FileName* _file_name; FileName* _file_name;
FileSchema* _file_schema; FileSchema* _file_schema;
void readParen(); void readParen();
void readSemicolon();\ void readSemicolon();
enum Trail { enum Trail {
TRAILING_SEMICOLON, TRAILING_SEMICOLON,
TRAILING_PAREN, TRAILING_PAREN,
@@ -77,8 +156,13 @@ private:
}; };
void readTerminal(const std::string& term, Trail trail); void readTerminal(const std::string& term, Trail trail);
public: public:
IfcSpfHeader() : _lexer(0), _file_description(0), _file_name(0), _file_schema(0) {} explicit IfcSpfHeader(IfcSpfLexer* lexer = 0)
explicit IfcSpfHeader(IfcSpfLexer* lexer) : _lexer(lexer) {} : _lexer(lexer), _file_description(0), _file_name(0), _file_schema(0)
{
_file_description = new FileDescription();
_file_name = new FileName();
_file_schema = new FileSchema();
}
IfcSpfLexer* lexer() { return _lexer; } IfcSpfLexer* lexer() { return _lexer; }
void lexer(IfcSpfLexer* l) { _lexer = l; } void lexer(IfcSpfLexer* l) { _lexer = l; }
@@ -86,9 +170,15 @@ public:
void read(); void read();
bool tryRead(); bool tryRead();
const FileDescription& file_description(); void write(std::ostream& os) const;
const FileName& file_name();
const FileSchema& file_schema(); const FileDescription& file_description() const;
const FileName& file_name() const;
const FileSchema& file_schema() const;
FileDescription& file_description();
FileName& file_name();
FileSchema& file_schema();
}; };
} }
+33 -11
View File
@@ -217,14 +217,6 @@ private:
} }
return oss.str(); return oss.str();
} }
void serialize_double(const std::vector<double>& i) {
data << "(";
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << format_double(*it);
}
data << ")";
}
bool upper; bool upper;
public: public:
StringBuilderVisitor(std::ostringstream& stream, bool upper = false) StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
@@ -239,9 +231,9 @@ public:
if (upper) s = IfcCharacterEncoder(s); if (upper) s = IfcCharacterEncoder(s);
data << s; data << s;
} }
void operator()(const std::vector<int>& i) { serialize(i); } void operator()(const std::vector<int>& i);
void operator()(const std::vector<double>& i) { serialize_double(i); } void operator()(const std::vector<double>& i);
void operator()(const std::vector<std::string>& i) { serialize(i); } void operator()(const std::vector<std::string>& i);
void operator()(const IfcWriteArgument::EnumerationReference& i) { void operator()(const IfcWriteArgument::EnumerationReference& i) {
data << "." << i.enumeration_value << "."; data << "." << i.enumeration_value << ".";
} }
@@ -277,6 +269,36 @@ public:
operator std::string() { return data.str(); } operator std::string() { return data.str(); }
}; };
template <>
void StringBuilderVisitor::serialize(const std::vector<std::string>& i) {
data << "(";
for (std::vector<std::string>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
if (upper) {
std::string s = IfcCharacterEncoder(*it);
data << s;
} else {
data << *it;
}
}
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector<double>& i) {
data << "(";
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << format_double(*it);
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector<int>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { serialize(i); }
IfcWriteArgument::operator int() const { return as<int>(); } IfcWriteArgument::operator int() const { return as<int>(); }
IfcWriteArgument::operator bool() const { return as<bool>(); } IfcWriteArgument::operator bool() const { return as<bool>(); }
IfcWriteArgument::operator double() const { return as<double>(); } IfcWriteArgument::operator double() const { return as<double>(); }
+14 -14
View File
@@ -1,20 +1,20 @@
/******************************************************************************** /********************************************************************************
* * * *
* This file is part of IfcOpenShell. * * This file is part of IfcOpenShell. *
* * * *
* IfcOpenShell is free software: you can redistribute it and/or modify * * IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by * * it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or * * the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* IfcOpenShell is distributed in the hope that it will be useful, * * IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. * * Lesser GNU General Public License for more details. *
* * * *
* You should have received a copy of the Lesser GNU General Public License * * You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* * * *
********************************************************************************/ ********************************************************************************/
%rename("settings") IteratorSettings; %rename("settings") IteratorSettings;
+61 -26
View File
@@ -1,22 +1,35 @@
/******************************************************************************** /********************************************************************************
* * * *
* This file is part of IfcOpenShell. * * This file is part of IfcOpenShell. *
* * * *
* IfcOpenShell is free software: you can redistribute it and/or modify * * IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by * * it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or * * the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* IfcOpenShell is distributed in the hope that it will be useful, * * IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. * * Lesser GNU General Public License for more details. *
* * * *
* You should have received a copy of the Lesser GNU General Public License * * You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* * * *
********************************************************************************/ ********************************************************************************/
// Two class declarations to silence SWIG warning about base classes being
// undefined, the constructors are private so that SWIG does not wrap them
class IfcAbstractEntity {
private:
IfcAbstractEntity();
};
namespace IfcUtil {
class IfcBaseEntity {
private:
IfcBaseEntity();
};
}
%ignore IfcParse::IfcLateBoundEntity::is; %ignore IfcParse::IfcLateBoundEntity::is;
%ignore IfcParse::IfcLateBoundEntity::type; %ignore IfcParse::IfcLateBoundEntity::type;
%ignore IfcParse::IfcLateBoundEntity::getArgument; %ignore IfcParse::IfcLateBoundEntity::getArgument;
@@ -32,9 +45,11 @@
%ignore IfcParse::FileName::FileName; %ignore IfcParse::FileName::FileName;
%ignore IfcParse::FileSchema::FileSchema; %ignore IfcParse::FileSchema::FileSchema;
%ignore IfcParse::IfcFile::tokens; %ignore IfcParse::IfcFile::tokens;
%ignore IfcParse::IfcSpfHeader::IfcSpfHeader(IfcSpfLexer*); %ignore IfcParse::IfcSpfHeader::IfcSpfHeader(IfcSpfLexer*);
%ignore IfcParse::IfcSpfHeader::lexer; %ignore IfcParse::IfcSpfHeader::lexer;
%ignore IfcParse::IfcSpfHeader::stream; %ignore IfcParse::IfcSpfHeader::stream;
%ignore IfcParse::HeaderEntity::is;
%rename("by_type") EntitiesByType; %rename("by_type") EntitiesByType;
%rename("__len__") getArgumentCount; %rename("__len__") getArgumentCount;
@@ -190,23 +205,41 @@
%extend IfcParse::FileDescription { %extend IfcParse::FileDescription {
%pythoncode %{ %pythoncode %{
if _newclass: if _newclass:
# Hide the getters with read-only property implementations # Hide the getters with read-write property implementations
description = property(description) __swig_getmethods__["description"] = description
implementation_level = property(implementation_level) __swig_setmethods__["description"] = description
description = property(description, description)
__swig_getmethods__["implementation_level"] = implementation_level
__swig_setmethods__["implementation_level"] = implementation_level
implementation_level = property(implementation_level, implementation_level)
%} %}
}; };
%extend IfcParse::FileName { %extend IfcParse::FileName {
%pythoncode %{ %pythoncode %{
if _newclass: if _newclass:
# Hide the getters with read-only property implementations # Hide the getters with read-write property implementations
name = property(name) __swig_getmethods__["name"] = name
time_stamp = property(time_stamp) __swig_setmethods__["name"] = name
author = property(author) name = property(name, name)
organization = property(organization) __swig_getmethods__["time_stamp"] = time_stamp
preprocessor_version = property(preprocessor_version) __swig_setmethods__["time_stamp"] = time_stamp
originating_system = property(originating_system) timestamp = property(time_stamp, time_stamp)
authorization = property(authorization) __swig_getmethods__["author"] = author
__swig_setmethods__["author"] = author
author = property(author, author)
__swig_getmethods__["organization"] = organization
__swig_setmethods__["organization"] = organization
organization = property(organization, organization)
__swig_getmethods__["preprocessor_version"] = preprocessor_version
__swig_setmethods__["preprocessor_version"] = preprocessor_version
preprocessor_version = property(preprocessor_version, preprocessor_version)
__swig_getmethods__["originating_system"] = originating_system
__swig_setmethods__["originating_system"] = originating_system
originating_system = property(originating_system, originating_system)
__swig_getmethods__["authorization"] = authorization
__swig_setmethods__["authorization"] = authorization
authorization = property(authorization, authorization)
%} %}
}; };
@@ -214,7 +247,9 @@
%pythoncode %{ %pythoncode %{
if _newclass: if _newclass:
# Hide the getters with read-only property implementations # Hide the getters with read-only property implementations
schema_identifiers = property(schema_identifiers) __swig_getmethods__["schema_identifiers"] = schema_identifiers
__swig_setmethods__["schema_identifiers"] = schema_identifiers
schema_identifiers = property(schema_identifiers, schema_identifiers)
%} %}
}; };
+14 -14
View File
@@ -1,20 +1,20 @@
/******************************************************************************** /********************************************************************************
* * * *
* This file is part of IfcOpenShell. * * This file is part of IfcOpenShell. *
* * * *
* IfcOpenShell is free software: you can redistribute it and/or modify * * IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by * * it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or * * the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* IfcOpenShell is distributed in the hope that it will be useful, * * IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of * * but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. * * Lesser GNU General Public License for more details. *
* * * *
* You should have received a copy of the Lesser GNU General Public License * * You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
* * * *
********************************************************************************/ ********************************************************************************/
%include "std_vector.i" %include "std_vector.i"