Files
IfcOpenShell/src/serializers/JsonSerializer.h
T

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

62 lines
1.6 KiB
C++
Raw Normal View History

2025-11-17 14:06:39 +01:00
#ifndef JSONSERIALIZER_H
#define JSONSERIALIZER_H
#ifdef WITH_GLTF
#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"
2025-11-17 14:06:39 +01:00
#include "../serializers/serializers_api.h"
#include <boost/function.hpp>
#include <map>
class SERIALIZERS_API JsonSerializer : public Serializer {
public:
enum Dialect {
JSON_DIALECT_CREOOX
};
private:
2026-04-17 11:24:09 +02:00
JsonSerializer* implementation_ = nullptr;
2025-11-17 14:06:39 +01:00
protected:
std::string json_filename;
Dialect dialect_;
public:
2026-03-31 15:32:36 +02:00
JsonSerializer(ifcopenshell::file* file, const std::string& json_filename, Dialect dialect = Dialect::JSON_DIALECT_CREOOX);
2025-11-17 14:06:39 +01:00
virtual ~JsonSerializer() {}
bool ready() { return true; }
void writeHeader() {}
void finalize() { implementation_->finalize(); }
2026-03-31 15:32:36 +02:00
void setFile(ifcopenshell::file*) { throw ifcopenshell::exception("Should be supplied on construction"); }
2025-11-17 14:06:39 +01:00
};
struct SERIALIZERS_API JsonSerializerFactory {
2026-03-31 15:32:36 +02:00
typedef boost::function3<JsonSerializer*, ifcopenshell::file*, std::string, JsonSerializer::Dialect> fn;
2025-11-17 14:06:39 +01:00
2026-04-17 11:24:09 +02:00
class SERIALIZERS_API Factory {
2025-11-17 14:06:39 +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
JsonSerializer* construct(const std::string& schema_name, ifcopenshell::file*, std::string, JsonSerializer::Dialect);
2026-04-17 11:24:09 +02:00
private:
struct entry {
fn fn_;
ifcopenshell::plugin::module module_;
};
std::map<std::string, entry> entries_;
2025-11-17 14:06:39 +01:00
};
static Factory& implementations();
};
#endif
#endif