Files
IfcOpenShell/src/serializers/xml_serializer.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
C++
Raw Normal View History

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
#include "../serializers/serializers_api.h"
2026-08-08 14:19:57 +02: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"
2026-04-18 15:46:21 +02:00
#include "../serializers/document_serializer_plugin.h"
2018-03-04 10:43:40 +01:00
2026-08-08 15:37:53 +02:00
#include <memory>
2018-03-04 10:43:40 +01:00
class xml_serializer : public ifcopenshell::geom::serializer {
2018-03-16 16:04:48 +01:00
private:
2026-08-08 15:37:53 +02:00
std::shared_ptr<ifcopenshell::geom::serializer> implementation_;
2018-03-04 10:43:40 +01:00
2018-03-16 16:04:48 +01:00
protected:
std::string xml_filename;
public:
xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& logger = ifcopenshell::logger::root())
2026-04-18 15:46:21 +02:00
: xml_filename(xml_filename)
{
if (!file) {
return;
}
ifcopenshell::serializers::document_serializer_context context;
context.file = file;
context.output_filename = xml_filename;
context.schema_name = file->schema()->name();
implementation_ = ifcopenshell::serializers::document_serializer_registry_instance().create("xml", context);
}
2018-03-16 16:04:48 +01:00
2026-08-08 07:42:45 +02:00
virtual ~xml_serializer() {}
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
2026-04-18 15:46:21 +02:00
void finalize() {
if (!implementation_) {
throw ifcopenshell::exception("No XML serializer implementation constructed");
}
implementation_->finalize();
}
void setFile(ifcopenshell::file&) { throw ifcopenshell::exception("Should be supplied on construction"); }
2018-03-04 10:43:40 +01:00
};
2026-04-17 11:24:09 +02:00
#endif