diff options
author | rtk0c <[email protected]> | 2023-10-19 22:50:07 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2025-08-16 11:31:16 -0700 |
commit | 297232d21594b138bb368a42b5b0d085ff9ed6aa (patch) | |
tree | 075d5407e1e12a9d35cbee6e4c20ad34e0765c42 /src/brussel.codegen.comp/CodegenModel.hpp | |
parent | d5cd34ff69f7fd134d5450696f298af1a864afbc (diff) |
The great renaming: switch to "module style"
Diffstat (limited to 'src/brussel.codegen.comp/CodegenModel.hpp')
-rw-r--r-- | src/brussel.codegen.comp/CodegenModel.hpp | 61 |
1 files changed, 61 insertions, 0 deletions
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 <sqlite3.h> +#include <cinttypes> +#include <cstdint> +#include <string> +#include <string_view> + +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); +}; |