20 out << R
"(#ifndef __JDB__JDBTypes__
21#define __JDB__JDBTypes__
32 for (
auto v1 : includes.
api) {
33 out <<
" class " << v1 <<
";\n";
36 out <<
"\n namespace APIV2 {\n\n";
37 for (
auto v2 : includes.
apiV2) {
38 out <<
" class " << v2 <<
";\n";
55 for (
auto i : includes.
files) {
56 std::filesystem::path p(i);
57 out <<
"#include \"JDB/" << p.filename().string() <<
"\"\n";
63 for (
auto infile : includes) {
66 std::cerr <<
"Cannot open input file " << infile <<
"\n";
70 std::regex classDefRegex(R
"(ClassDef\s*(?:NV)?\(\s*(.*)\s*,\s*(\d*))");
71 std::regex apiV2Regex("namespace.*APIV2");
72 std::smatch classDefMatch;
77 if (std::regex_search(line, apiV2Regex)) {
80 if (std::regex_search(line, classDefMatch, classDefRegex)) {
82 stype = classDefMatch[1];
84 cn.
apiV2.emplace_back(stype);
87 cn.
api.emplace_back(stype);
93 cn.
files.emplace_back(infile);
104int main(
int argc,
char **argv) {
106 throw runtime_error(
"need at least 4 arguments");
108 string outfile = argv[1];
109 string outputType = argv[2];
112 for (
int i = 3; i < argc; i++) {
113 classdefs.emplace_back(argv[i]);
118 ofstream out(outfile);
119 if (!out.is_open()) {
120 std::cerr <<
"Cannot open output file " << outfile <<
"\n";
124 if (outputType ==
"types") {
126 }
else if (outputType ==
"includes") {
129 std::cerr <<
"don't know what to do with outputType " << outputType
130 <<
" : I only know 'types' or 'includes'\n";
Includes parseIncludes(const std::vector< std::string > &includes)
void outputIncludes(std::ostream &out, const Includes &includes)
int main(int argc, char **argv)
Helper program to create includes files for types and includes from a list of JDB includes.
void outputTypes(std::ostream &out, const Includes &includes)
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
std::vector< std::string > apiV2
std::vector< std::string > files
std::vector< std::string > api