From 2c92e07f337e42cf58970443f9de678f85a9b2a4 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 19 Oct 2023 22:50:07 -0700 Subject: The great renaming: switch to "module style" --- src/brussel.codegen.comp/CodegenModel.hpp | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/brussel.codegen.comp/CodegenModel.hpp (limited to 'src/brussel.codegen.comp/CodegenModel.hpp') diff --git a/src/brussel.codegen.comp/CodegenModel.hpp b/src/brussel.codegen.comp/CodegenModel.hpp new file mode 100644 index 0000000..99c345d --- /dev/null +++ b/src/brussel.codegen.comp/CodegenModel.hpp @@ -0,0 +1,61 @@ +#pragma once + +#include "CodegenConfig.hpp" +#include "CodegenDecl.hpp" +#include "CodegenModel.hpp" +#include "CodegenUtils.hpp" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +class CodegenRuntimeModel { +private: + class Private; + Private* m; + +public: + CodegenRuntimeModel(); + ~CodegenRuntimeModel(); + + // Implementation detail helper, don't use outside + Private& GetPimpl() const { return *m; } + + DeclEnum* AddEnum(std::string fullname, DeclEnum decl); + DeclStruct* AddStruct(std::string fullname, DeclStruct decl); + + const DeclEnum* FindEnum(std::string_view name) const; + const DeclStruct* FindStruct(std::string_view name) const; + + DeclNamespace* AddNamespace(DeclNamespace ns); + + const DeclNamespace* FindNamespace(std::string_view fullname) const; + DeclNamespace* FindNamespace(std::string_view name); +}; + +class CodegenArchiveModel { +private: + class Private; + Private* m; + +public: + CodegenArchiveModel(std::string_view dbPath); + ~CodegenArchiveModel(); + + // Implementation detail helper, don't use outside + Private& GetPimpl() const { return *m; } + + void DeleteDeclsRelatedToFile(std::string_view filename); + + void Store(const CodegenRuntimeModel& model); + void LoadInto(CodegenRuntimeModel& model) const; + CodegenRuntimeModel Load() const; + + void StoreStruct(const DeclStruct& decl); + void StoreFunction(const DeclFunction& decl); + void StoreEnum(const DeclEnum& decl); +}; -- cgit v1.2.3-70-g09d2