1919
2020#include < functional>
2121#include < limits>
22+ #include < list>
2223#include < string>
2324
2425#include " flatbuffers/bfbs_generator.h"
@@ -31,6 +32,30 @@ namespace flatbuffers {
3132extern void LogCompilerWarn (const std::string &warn);
3233extern void LogCompilerError (const std::string &err);
3334
35+ struct FlatCOptions {
36+ IDLOptions opts;
37+
38+ std::string program_name;
39+
40+ std::string output_path;
41+
42+ std::vector<std::string> filenames;
43+
44+ std::list<std::string> include_directories_storage;
45+ std::vector<const char *> include_directories;
46+ std::vector<const char *> conform_include_directories;
47+ std::vector<bool > generator_enabled;
48+ size_t binary_files_from = std::numeric_limits<size_t >::max();
49+ std::string conform_to_schema;
50+ std::string annotate_schema;
51+ bool any_generator = false ;
52+ bool print_make_rules = false ;
53+ bool raw_binary = false ;
54+ bool schema_binary = false ;
55+ bool grpc_enabled = false ;
56+ bool requires_bfbs = false ;
57+ };
58+
3459struct FlatCOption {
3560 std::string short_opt;
3661 std::string long_opt;
@@ -85,15 +110,18 @@ class FlatCompiler {
85110
86111 explicit FlatCompiler (const InitParams ¶ms) : params_(params) {}
87112
88- int Compile (int argc, const char **argv);
113+ int Compile (const FlatCOptions &options);
114+
115+ std::string GetShortUsageString (const std::string& program_name) const ;
116+ std::string GetUsageString (const std::string& program_name) const ;
89117
90- std::string GetShortUsageString ( const char *program_name) const ;
91- std::string GetUsageString ( const char *program_name) const ;
118+ // Parse the FlatC options from command line arguments.
119+ FlatCOptions ParseFromCommandLineArguments ( int argc, const char **argv) ;
92120
93121 private:
94122 void ParseFile (flatbuffers::Parser &parser, const std::string &filename,
95123 const std::string &contents,
96- std::vector<const char *> &include_directories) const ;
124+ const std::vector<const char *> &include_directories) const ;
97125
98126 void LoadBinarySchema (Parser &parser, const std::string &filename,
99127 const std::string &contents);
@@ -105,9 +133,16 @@ class FlatCompiler {
105133
106134 void AnnotateBinaries (const uint8_t *binary_schema,
107135 uint64_t binary_schema_size,
108- const std::string & schema_filename,
136+ const std::string &schema_filename,
109137 const std::vector<std::string> &binary_files);
110138
139+ void ValidateOptions (const FlatCOptions &options);
140+
141+ Parser GetConformParser (const FlatCOptions &options);
142+
143+ std::unique_ptr<Parser> GenerateCode (const FlatCOptions &options,
144+ Parser &conform_parser);
145+
111146 InitParams params_;
112147};
113148
0 commit comments