Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
codegen_typescript.h
1#ifndef SOURCEMETA_BLAZE_CODEGEN_TYPESCRIPT_H_
2#define SOURCEMETA_BLAZE_CODEGEN_TYPESCRIPT_H_
3
4#ifndef SOURCEMETA_BLAZE_CODEGEN_EXPORT
5#include <sourcemeta/blaze/codegen_export.h>
6#endif
7
8#include <sourcemeta/core/jsonpointer.h>
9
10#include <map> // std::map
11#include <ostream> // std::ostream
12#include <string> // std::string
13#include <string_view> // std::string_view
14
15namespace sourcemeta::blaze {
16
17struct CodegenIRScalar;
19struct CodegenIRObject;
21struct CodegenIRAny;
22struct CodegenIRArray;
24struct CodegenIRTuple;
25struct CodegenIRUnion;
28
30class SOURCEMETA_BLAZE_CODEGEN_EXPORT TypeScript {
31public:
32 TypeScript(std::ostream &stream, std::string_view type_prefix);
33 auto operator()(const CodegenIRScalar &entry) -> void;
34 auto operator()(const CodegenIREnumeration &entry) -> void;
35 auto operator()(const CodegenIRObject &entry) -> void;
36 auto operator()(const CodegenIRImpossible &entry) -> void;
37 auto operator()(const CodegenIRAny &entry) -> void;
38 auto operator()(const CodegenIRArray &entry) -> void;
39 auto operator()(const CodegenIRReference &entry) -> void;
40 auto operator()(const CodegenIRTuple &entry) -> void;
41 auto operator()(const CodegenIRUnion &entry) -> void;
42 auto operator()(const CodegenIRIntersection &entry) -> void;
43 auto operator()(const CodegenIRConditional &entry) -> void;
44
45private:
46// Exporting symbols that depends on the standard C++ library is considered
47// safe.
48// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
49#if defined(_MSC_VER)
50#pragma warning(disable : 4251)
51#endif
52 // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
53 std::ostream &output_;
54 std::string_view prefix_;
55 std::map<std::string, sourcemeta::core::Pointer> cache_;
56#if defined(_MSC_VER)
57#pragma warning(default : 4251)
58#endif
59};
60
61} // namespace sourcemeta::blaze
62
63#endif
Definition codegen.h:103
Definition codegen.h:89
Definition codegen.h:80
Definition codegen.h:49
Definition codegen.h:94
Definition codegen.h:59