mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
8c003110fe
Generated with the assistance of an AI coding tool.
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
#ifndef XMLSERIALIZER_H
|
|
#define XMLSERIALIZER_H
|
|
|
|
#define SCHEMA_METHOD
|
|
|
|
#include "../serializers/serializers_api.h"
|
|
#include "../ifcgeom/serializer.h"
|
|
#include "../ifcparse/file.h"
|
|
#include "../plugin/plugin.h"
|
|
#include "../serializers/document_serializer_plugin.h"
|
|
|
|
#include <memory>
|
|
|
|
class xml_serializer : public ifcopenshell::geom::serializer {
|
|
private:
|
|
std::shared_ptr<ifcopenshell::geom::serializer> implementation_;
|
|
|
|
protected:
|
|
std::string xml_filename;
|
|
|
|
public:
|
|
xml_serializer(ifcopenshell::file* file, const std::string& xml_filename, ifcopenshell::logger& logger = ifcopenshell::logger::root())
|
|
: 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);
|
|
}
|
|
|
|
virtual ~xml_serializer() {}
|
|
|
|
bool ready() { return true; }
|
|
void writeHeader() {}
|
|
|
|
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"); }
|
|
};
|
|
|
|
#endif
|