templates.py: disable C4100 warnings for headers created by this file + move <map> inclusion to .cpp as it's not needed in .h + use spaces instead of tabs consistently for these files as seems to be the convention.

This commit is contained in:
Stinkfist0
2015-11-22 02:20:34 +02:00
parent b562508f5b
commit 16a82f035f
8 changed files with 111 additions and 79 deletions
+3 -1
View File
@@ -4,6 +4,8 @@ the IFC schema and will most likely fail on any other Express schema.
The code can be invoked in the following way and results in two header files The code can be invoked in the following way and results in two header files
and a single implementation file named according to the schema name in the and a single implementation file named according to the schema name in the
Express file. A python 3 interpreter with the pyparsing library is required. Express file. A python 3 interpreter with the pyparsing [1] library is required.
$ python bootstrap.py express.bnf > express_parser.py && python express_parser.py IFC2X3_TC1.exp $ python bootstrap.py express.bnf > express_parser.py && python express_parser.py IFC2X3_TC1.exp
[1] http://pyparsing.wikispaces.com/Download+and+Installation
+35 -25
View File
@@ -23,7 +23,6 @@ header = """
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@@ -31,6 +30,11 @@ header = """
#include "../ifcparse/IfcException.h" #include "../ifcparse/IfcException.h"
#include "../ifcparse/%(schema_name)senum.h" #include "../ifcparse/%(schema_name)senum.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
#define IfcSchema %(schema_name)s #define IfcSchema %(schema_name)s
namespace %(schema_name)s { namespace %(schema_name)s {
@@ -47,6 +51,10 @@ void InitStringMap();
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0); IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif #endif
""" """
@@ -107,6 +115,8 @@ implementation= """
#include "../ifcparse/IfcWrite.h" #include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h" #include "../ifcparse/IfcWritableEntity.h"
#include <map>
using namespace %(schema_name)s; using namespace %(schema_name)s;
using namespace IfcParse; using namespace IfcParse;
using namespace IfcWrite; using namespace IfcWrite;
@@ -261,49 +271,49 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
} }
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) { std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
while (true) { for(;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
jt = it->second.find(a); jt = it->second.find(a);
if (jt != it->second.end()) { if (jt != it->second.end()) {
return jt->second; return jt->second;
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
throw IfcException("Attribute not found"); throw IfcException("Attribute not found");
} }
std::set<std::string> Type::GetInverseAttributeNames(Enum t) { std::set<std::string> Type::GetInverseAttributeNames(Enum t) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
std::set<std::string> return_value; std::set<std::string> return_value;
while (true) { for (;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
for (jt = it->second.begin(); jt != it->second.end(); ++jt) { for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first); return_value.insert(jt->first);
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
return return_value; return return_value;
} }
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) { void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type()); std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type());
if (i != derived_map.end()) { if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) { for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it); e->setArgumentDerived(*it);
} }
} }
} }
""" """
+24 -24
View File
@@ -4247,48 +4247,48 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
} }
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) { std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
for (;;) { for(;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
jt = it->second.find(a); jt = it->second.find(a);
if (jt != it->second.end()) { if (jt != it->second.end()) {
return jt->second; return jt->second;
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
throw IfcException("Attribute not found"); throw IfcException("Attribute not found");
} }
std::set<std::string> Type::GetInverseAttributeNames(Enum t) { std::set<std::string> Type::GetInverseAttributeNames(Enum t) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
std::set<std::string> return_value; std::set<std::string> return_value;
for (;;) { for (;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
for (jt = it->second.begin(); jt != it->second.end(); ++jt) { for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first); return_value.insert(jt->first);
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
return return_value; return return_value;
} }
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) { void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type()); std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type());
if (i != derived_map.end()) { if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) { for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it); e->setArgumentDerived(*it);
} }
} }
} }
#endif #endif
+2
View File
@@ -31,6 +31,8 @@
#include "../ifcparse/IfcWrite.h" #include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h" #include "../ifcparse/IfcWritableEntity.h"
#include <map>
using namespace Ifc2x3; using namespace Ifc2x3;
using namespace IfcParse; using namespace IfcParse;
using namespace IfcWrite; using namespace IfcWrite;
+9 -1
View File
@@ -29,7 +29,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@@ -37,6 +36,11 @@
#include "../ifcparse/IfcException.h" #include "../ifcparse/IfcException.h"
#include "../ifcparse/Ifc2x3enum.h" #include "../ifcparse/Ifc2x3enum.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
#define IfcSchema Ifc2x3 #define IfcSchema Ifc2x3
namespace Ifc2x3 { namespace Ifc2x3 {
@@ -41583,4 +41587,8 @@ void InitStringMap();
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0); IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif #endif
+24 -24
View File
@@ -4941,48 +4941,48 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
} }
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) { std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
while (true) { for(;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
jt = it->second.find(a); jt = it->second.find(a);
if (jt != it->second.end()) { if (jt != it->second.end()) {
return jt->second; return jt->second;
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
throw IfcException("Attribute not found"); throw IfcException("Attribute not found");
} }
std::set<std::string> Type::GetInverseAttributeNames(Enum t) { std::set<std::string> Type::GetInverseAttributeNames(Enum t) {
if (inverse_map.empty()) ::InitInverseMap(); if (inverse_map.empty()) ::InitInverseMap();
inverse_map_t::const_iterator it; inverse_map_t::const_iterator it;
inverse_map_t::mapped_type::const_iterator jt; inverse_map_t::mapped_type::const_iterator jt;
std::set<std::string> return_value; std::set<std::string> return_value;
while (true) { for (;;) {
it = inverse_map.find(t); it = inverse_map.find(t);
if (it != inverse_map.end()) { if (it != inverse_map.end()) {
for (jt = it->second.begin(); jt != it->second.end(); ++jt) { for (jt = it->second.begin(); jt != it->second.end(); ++jt) {
return_value.insert(jt->first); return_value.insert(jt->first);
} }
} }
if ((t = Parent(t)) == -1) break; if ((t = Parent(t)) == -1) break;
} }
return return_value; return return_value;
} }
void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) { void Type::PopulateDerivedFields(IfcWrite::IfcWritableEntity* e) {
std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type()); std::map<Type::Enum, std::set<int> >::const_iterator i = derived_map.find(e->type());
if (i != derived_map.end()) { if (i != derived_map.end()) {
for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) { for (std::set<int>::const_iterator it = i->second.begin(); it != i->second.end(); ++it) {
e->setArgumentDerived(*it); e->setArgumentDerived(*it);
} }
} }
} }
#endif #endif
+2
View File
@@ -31,6 +31,8 @@
#include "../ifcparse/IfcWrite.h" #include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h" #include "../ifcparse/IfcWritableEntity.h"
#include <map>
using namespace Ifc4; using namespace Ifc4;
using namespace IfcParse; using namespace IfcParse;
using namespace IfcWrite; using namespace IfcWrite;
+9 -1
View File
@@ -29,7 +29,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map>
#include <boost/optional.hpp> #include <boost/optional.hpp>
@@ -37,6 +36,11 @@
#include "../ifcparse/IfcException.h" #include "../ifcparse/IfcException.h"
#include "../ifcparse/Ifc4enum.h" #include "../ifcparse/Ifc4enum.h"
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
#endif
#define IfcSchema Ifc4 #define IfcSchema Ifc4
namespace Ifc4 { namespace Ifc4 {
@@ -55147,4 +55151,8 @@ void InitStringMap();
IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0); IfcUtil::IfcBaseClass* SchemaEntity(IfcAbstractEntity* e = 0);
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif #endif