mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Make header values writable
This commit is contained in:
@@ -55,7 +55,7 @@ int main(int argc, char** argv) {
|
||||
// The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
|
||||
// convenience functions for working with geometry in IFC files.
|
||||
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.
|
||||
IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase(
|
||||
|
||||
+9
-17
@@ -51,13 +51,7 @@ private:
|
||||
|
||||
IfcSpfHeader _header;
|
||||
|
||||
std::string _filename;
|
||||
std::string _timestamp;
|
||||
std::string _author;
|
||||
std::string _author_email;
|
||||
std::string _author_organisation;
|
||||
|
||||
void initTimestamp();
|
||||
void setDefaultHeaderValues();
|
||||
public:
|
||||
IfcParse::IfcSpfLexer* tokens;
|
||||
IfcParse::IfcSpfStream* stream;
|
||||
@@ -76,7 +70,11 @@ public:
|
||||
template <class T>
|
||||
typename T::list::ptr EntitiesByType() {
|
||||
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.
|
||||
@@ -110,16 +108,10 @@ public:
|
||||
void AddEntity(IfcUtil::IfcBaseClass* entity);
|
||||
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; }
|
||||
IfcSpfHeader& header() { return _header; }
|
||||
|
||||
std::string createTimestamp() const;
|
||||
|
||||
bool create_latebound_entities() const { return _create_latebound_entities; }
|
||||
};
|
||||
|
||||
+73
-53
@@ -420,25 +420,31 @@ EntityArgument::EntityArgument(const Token& t) {
|
||||
// Reads the arguments from a list of token
|
||||
// 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;
|
||||
|
||||
Token next = t->Next();
|
||||
while( next.second || next.first ) {
|
||||
if ( TokenFunc::isOperator(next,',') ) {}
|
||||
else if ( TokenFunc::isOperator(next,')') ) break;
|
||||
else if ( TokenFunc::isOperator(next,'(') ) Push( new ArgumentList(t,ids) );
|
||||
else {
|
||||
if ( TokenFunc::isIdentifier(next) ) ids.push_back(TokenFunc::asInt(next));
|
||||
if ( TokenFunc::isKeyword(next) ) {
|
||||
if ( TokenFunc::isOperator(next,',') ) {
|
||||
// do nothing
|
||||
} else if ( TokenFunc::isOperator(next,')') ) {
|
||||
break;
|
||||
} else if ( TokenFunc::isOperator(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();
|
||||
try {
|
||||
Push ( new EntityArgument(next) );
|
||||
push ( new EntityArgument(next) );
|
||||
} catch ( IfcException& e ) {
|
||||
Logger::Message(Logger::LOG_ERROR,e.what());
|
||||
}
|
||||
} else {
|
||||
Push ( new TokenArgument(next) );
|
||||
push ( new TokenArgument(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);
|
||||
}
|
||||
|
||||
@@ -523,10 +529,22 @@ ArgumentList::operator IfcEntityListList::ptr() const {
|
||||
}
|
||||
unsigned int ArgumentList::size() const { return (unsigned int) list.size(); }
|
||||
Argument* ArgumentList::operator [] (unsigned int i) const {
|
||||
if ( i >= list.size() )
|
||||
if ( i >= list.size() ) {
|
||||
throw IfcException("Argument index out of range");
|
||||
}
|
||||
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::stringstream ss;
|
||||
ss << "(";
|
||||
@@ -666,7 +684,8 @@ void Entity::Load(std::vector<unsigned int>& ids, bool seek) const {
|
||||
_type = IfcSchema::Type::FromString(TokenFunc::asString(datatype));
|
||||
}
|
||||
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();
|
||||
Token semilocon = file->tokens->Next();
|
||||
if ( ! TokenFunc::isOperator(semilocon,';') ) file->tokens->stream->Seek(old_offset);
|
||||
@@ -697,7 +716,10 @@ std::string Entity::toString(bool upper) const {
|
||||
if ( upper ) {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -721,12 +743,12 @@ IfcWrite::IfcWritableEntity* Entity::isWritable() {
|
||||
|
||||
IfcFile::IfcFile(bool create_latebound_entities)
|
||||
: _create_latebound_entities(create_latebound_entities)
|
||||
, stream(0)
|
||||
, lastId(0)
|
||||
, tokens(0)
|
||||
, MaxId(0)
|
||||
{
|
||||
stream = 0;
|
||||
lastId = 0;
|
||||
tokens = 0;
|
||||
MaxId = 0;
|
||||
initTimestamp();
|
||||
setDefaultHeaderValues();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -998,25 +1020,7 @@ IfcFile::entity_by_id_t::const_iterator IfcFile::end() const {
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
|
||||
os << "ISO-10303-21;" << std::endl;
|
||||
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;
|
||||
f.header().write(os);
|
||||
|
||||
for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) {
|
||||
const IfcUtil::IfcBaseClass* e = it->second;
|
||||
@@ -1029,26 +1033,20 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
|
||||
return os;
|
||||
}
|
||||
|
||||
void IfcFile::filename(const std::string& s) { _filename = s; }
|
||||
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() {
|
||||
std::string IfcFile::createTimestamp() const {
|
||||
char buf[255];
|
||||
|
||||
time_t 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)) {
|
||||
_timestamp = std::string(buf);
|
||||
result = std::string(buf);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) {
|
||||
@@ -1078,4 +1076,26 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,11 +122,12 @@ namespace IfcParse {
|
||||
class ArgumentList: public Argument {
|
||||
private:
|
||||
std::vector<Argument*> list;
|
||||
void Push(Argument* l);
|
||||
void push(Argument* l);
|
||||
public:
|
||||
ArgumentList(IfcSpfLexer* t, std::vector<unsigned int>& ids);
|
||||
~ArgumentList();
|
||||
|
||||
void read(IfcSpfLexer* t, std::vector<unsigned int>& ids);
|
||||
|
||||
IfcUtil::ArgumentType type() const;
|
||||
|
||||
operator int() const;
|
||||
@@ -140,7 +141,10 @@ namespace IfcParse {
|
||||
operator IfcEntityList::ptr() const;
|
||||
operator IfcEntityListList::ptr() const;
|
||||
unsigned int size() const;
|
||||
|
||||
Argument* operator [] (unsigned int i) const;
|
||||
void set(unsigned int i, Argument*);
|
||||
|
||||
std::string toString(bool upper=false) const;
|
||||
bool isNull() const;
|
||||
};
|
||||
@@ -206,7 +210,7 @@ namespace IfcParse {
|
||||
/// ============================
|
||||
class Entity : public IfcAbstractEntity {
|
||||
private:
|
||||
mutable Argument* args;
|
||||
mutable ArgumentList* args;
|
||||
mutable IfcSchema::Type::Enum _type;
|
||||
public:
|
||||
/// The EXPRESS ENTITY_INSTANCE_NAME
|
||||
|
||||
@@ -62,14 +62,17 @@ void IfcSpfHeader::read() {
|
||||
readTerminal(HEADER, TRAILING_SEMICOLON);
|
||||
|
||||
readTerminal(FILE_DESCRIPTION, TRAILING_PAREN);
|
||||
delete _file_description;
|
||||
_file_description = new FileDescription(_lexer);
|
||||
readSemicolon();
|
||||
|
||||
readTerminal(FILE_NAME, TRAILING_PAREN);
|
||||
delete _file_name;
|
||||
_file_name = new FileName(_lexer);
|
||||
readSemicolon();
|
||||
|
||||
readTerminal(FILE_SCHEMA, TRAILING_PAREN);
|
||||
delete _file_schema;
|
||||
_file_schema = new FileSchema(_lexer);
|
||||
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) {
|
||||
return *_file_description;
|
||||
} 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) {
|
||||
return *_file_name;
|
||||
} 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) {
|
||||
return *_file_schema;
|
||||
} 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) {}
|
||||
+110
-20
@@ -21,45 +21,124 @@
|
||||
#define IFCSPFHEADER_H
|
||||
|
||||
#include "../ifcparse/IfcSpfStream.h"
|
||||
#include "../ifcparse/IfcWrite.h"
|
||||
|
||||
namespace IfcParse {
|
||||
|
||||
class HeaderEntity {
|
||||
class HeaderEntity : public IfcAbstractEntity {
|
||||
private:
|
||||
ArgumentList* list;
|
||||
ArgumentList* _list;
|
||||
const char * const _datatype;
|
||||
protected:
|
||||
HeaderEntity(IfcSpfLexer* lexer) {
|
||||
HeaderEntity(const char * const datatype, IfcSpfLexer* lexer)
|
||||
: _datatype(datatype), _list(0)
|
||||
{
|
||||
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 {
|
||||
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:
|
||||
FileDescription(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
explicit FileDescription(IfcSpfLexer* = 0);
|
||||
|
||||
std::vector<std::string> description() const { return *getArgument(0); }
|
||||
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:
|
||||
FileName(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
explicit FileName(IfcSpfLexer* = 0);
|
||||
|
||||
std::string name() const { return *getArgument(0); }
|
||||
std::string time_stamp() const { return *getArgument(1); }
|
||||
std::vector<std::string> author() const { return *getArgument(2); }
|
||||
std::vector<std::string> organization() const { return *getArgument(3); }
|
||||
std::string preprocessor_version() const { return *getArgument(4); }
|
||||
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:
|
||||
FileSchema(IfcSpfLexer* lexer) : HeaderEntity(lexer) {}
|
||||
explicit FileSchema(IfcSpfLexer* = 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 {
|
||||
@@ -69,7 +148,7 @@ private:
|
||||
FileName* _file_name;
|
||||
FileSchema* _file_schema;
|
||||
void readParen();
|
||||
void readSemicolon();\
|
||||
void readSemicolon();
|
||||
enum Trail {
|
||||
TRAILING_SEMICOLON,
|
||||
TRAILING_PAREN,
|
||||
@@ -77,18 +156,29 @@ private:
|
||||
};
|
||||
void readTerminal(const std::string& term, Trail trail);
|
||||
public:
|
||||
IfcSpfHeader() : _lexer(0), _file_description(0), _file_name(0), _file_schema(0) {}
|
||||
explicit IfcSpfHeader(IfcSpfLexer* lexer) : _lexer(lexer) {}
|
||||
explicit IfcSpfHeader(IfcSpfLexer* lexer = 0)
|
||||
: _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; }
|
||||
void lexer(IfcSpfLexer* l) { _lexer = l; }
|
||||
|
||||
|
||||
void read();
|
||||
bool tryRead();
|
||||
|
||||
void write(std::ostream& os) const;
|
||||
|
||||
const FileDescription& file_description();
|
||||
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
@@ -217,14 +217,6 @@ private:
|
||||
}
|
||||
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;
|
||||
public:
|
||||
StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
|
||||
@@ -239,9 +231,9 @@ public:
|
||||
if (upper) s = IfcCharacterEncoder(s);
|
||||
data << s;
|
||||
}
|
||||
void operator()(const std::vector<int>& i) { serialize(i); }
|
||||
void operator()(const std::vector<double>& i) { serialize_double(i); }
|
||||
void operator()(const std::vector<std::string>& i) { serialize(i); }
|
||||
void operator()(const std::vector<int>& i);
|
||||
void operator()(const std::vector<double>& i);
|
||||
void operator()(const std::vector<std::string>& i);
|
||||
void operator()(const IfcWriteArgument::EnumerationReference& i) {
|
||||
data << "." << i.enumeration_value << ".";
|
||||
}
|
||||
@@ -277,6 +269,36 @@ public:
|
||||
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 bool() const { return as<bool>(); }
|
||||
IfcWriteArgument::operator double() const { return as<double>(); }
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* 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;
|
||||
|
||||
@@ -1,22 +1,35 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* 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::type;
|
||||
%ignore IfcParse::IfcLateBoundEntity::getArgument;
|
||||
@@ -32,9 +45,11 @@
|
||||
%ignore IfcParse::FileName::FileName;
|
||||
%ignore IfcParse::FileSchema::FileSchema;
|
||||
%ignore IfcParse::IfcFile::tokens;
|
||||
|
||||
%ignore IfcParse::IfcSpfHeader::IfcSpfHeader(IfcSpfLexer*);
|
||||
%ignore IfcParse::IfcSpfHeader::lexer;
|
||||
%ignore IfcParse::IfcSpfHeader::stream;
|
||||
%ignore IfcParse::HeaderEntity::is;
|
||||
|
||||
%rename("by_type") EntitiesByType;
|
||||
%rename("__len__") getArgumentCount;
|
||||
@@ -190,23 +205,41 @@
|
||||
%extend IfcParse::FileDescription {
|
||||
%pythoncode %{
|
||||
if _newclass:
|
||||
# Hide the getters with read-only property implementations
|
||||
description = property(description)
|
||||
implementation_level = property(implementation_level)
|
||||
# Hide the getters with read-write property implementations
|
||||
__swig_getmethods__["description"] = description
|
||||
__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 {
|
||||
%pythoncode %{
|
||||
if _newclass:
|
||||
# Hide the getters with read-only property implementations
|
||||
name = property(name)
|
||||
time_stamp = property(time_stamp)
|
||||
author = property(author)
|
||||
organization = property(organization)
|
||||
preprocessor_version = property(preprocessor_version)
|
||||
originating_system = property(originating_system)
|
||||
authorization = property(authorization)
|
||||
# Hide the getters with read-write property implementations
|
||||
__swig_getmethods__["name"] = name
|
||||
__swig_setmethods__["name"] = name
|
||||
name = property(name, name)
|
||||
__swig_getmethods__["time_stamp"] = time_stamp
|
||||
__swig_setmethods__["time_stamp"] = time_stamp
|
||||
timestamp = property(time_stamp, time_stamp)
|
||||
__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 %{
|
||||
if _newclass:
|
||||
# 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
@@ -1,20 +1,20 @@
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* 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 *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* 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"
|
||||
|
||||
Reference in New Issue
Block a user