2026-04-17 11:24:09 +02:00
|
|
|
#ifndef XMLSERIALIZER_H
|
|
|
|
|
#define XMLSERIALIZER_H
|
|
|
|
|
|
2018-03-04 10:43:40 +01:00
|
|
|
#define SCHEMA_METHOD
|
|
|
|
|
|
2022-05-03 11:38:12 +02:00
|
|
|
#include "../serializers/serializers_api.h"
|
2023-03-21 20:15:01 +01:00
|
|
|
#include "../ifcgeom/Serializer.h"
|
2026-03-31 15:32:36 +02:00
|
|
|
#include "../ifcparse/file.h"
|
2026-04-17 11:24:09 +02:00
|
|
|
#include "../plugin/plugin.h"
|
2018-03-04 10:43:40 +01:00
|
|
|
|
|
|
|
|
#include <boost/function.hpp>
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
2022-05-03 11:38:12 +02:00
|
|
|
class SERIALIZERS_API XmlSerializer : public Serializer {
|
2018-03-16 16:04:48 +01:00
|
|
|
private:
|
2026-04-17 11:24:09 +02:00
|
|
|
XmlSerializer* implementation_ = nullptr;
|
2018-03-04 10:43:40 +01:00
|
|
|
|
2018-03-16 16:04:48 +01:00
|
|
|
protected:
|
|
|
|
|
std::string xml_filename;
|
|
|
|
|
|
|
|
|
|
public:
|
2026-03-31 15:32:36 +02:00
|
|
|
XmlSerializer(ifcopenshell::file* file, const std::string& xml_filename);
|
2018-03-16 16:04:48 +01:00
|
|
|
|
|
|
|
|
virtual ~XmlSerializer() {}
|
2018-03-04 10:43:40 +01:00
|
|
|
|
2018-03-16 16:04:48 +01:00
|
|
|
bool ready() { return true; }
|
|
|
|
|
void writeHeader() {}
|
2018-03-04 10:43:40 +01:00
|
|
|
|
2018-03-16 16:04:48 +01:00
|
|
|
void finalize() { implementation_->finalize(); }
|
2026-03-31 15:32:36 +02:00
|
|
|
void setFile(ifcopenshell::file*) { throw ifcopenshell::exception("Should be supplied on construction"); }
|
2018-03-04 10:43:40 +01:00
|
|
|
};
|
|
|
|
|
|
2022-05-03 11:38:12 +02:00
|
|
|
struct SERIALIZERS_API XmlSerializerFactory {
|
2026-03-31 15:32:36 +02:00
|
|
|
typedef boost::function2<XmlSerializer*, ifcopenshell::file*, std::string> fn;
|
2018-03-04 10:43:40 +01:00
|
|
|
|
2026-04-17 11:24:09 +02:00
|
|
|
class SERIALIZERS_API Factory {
|
2018-03-04 10:43:40 +01:00
|
|
|
public:
|
|
|
|
|
Factory();
|
2026-04-17 11:24:09 +02:00
|
|
|
void bind(const std::string& schema_name, fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module());
|
2026-03-31 15:32:36 +02:00
|
|
|
XmlSerializer* construct(const std::string& schema_name, ifcopenshell::file*, std::string);
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct entry {
|
|
|
|
|
fn fn_;
|
|
|
|
|
ifcopenshell::plugin::module module_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::map<std::string, entry> entries_;
|
2018-03-04 10:43:40 +01:00
|
|
|
};
|
|
|
|
|
|
2018-03-16 16:04:48 +01:00
|
|
|
static Factory& implementations();
|
2018-03-04 10:43:40 +01:00
|
|
|
};
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
#endif
|