#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <regex>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
Go to the source code of this file.
◆ outputTypes()
      
        
          | void outputTypes  | 
          ( | 
          std::ostream & |           out,  | 
        
        
           | 
           | 
          const Includes & |           includes ) | 
        
      
 
Definition at line 19 of file classdef2code.cc.
   19                                                            {
   20  out << R"(#ifndef __JDB__JDBTypes__
   21#define __JDB__JDBTypes__
   22 
   23
   24
   25
   26
   27 
   28namespace JDATABASE {
   29 
   30)";
   31 
   32  for (
auto v1 : includes.
api) {
 
std::vector< std::string > api
 
 
 
 
◆ outputIncludes()
      
        
          | void outputIncludes  | 
          ( | 
          std::ostream & |           out,  | 
        
        
           | 
           | 
          const Includes & |           includes ) | 
        
      
 
Definition at line 34 of file classdef2code.cc.
   36                              {\n\n";
   37  for (auto v2 : includes.apiV2) {
   38    out << "    class " << v2 << ";\n";
   39  }
   40 
 
 
 
◆ parseIncludes()
Definition at line 42 of file classdef2code.cc.
   48                                                               {
   49  out << R"(
   50
   51
   52
   53 
   54)";
   55  for (auto i : includes.files) {
   56    std::filesystem::path p(i);
   57    out << "#include \"JDB/" << p.filename().string() << "\"\n";
   58  }
   59}
   60 
   63  for (auto infile : includes) {
   64    ifstream in(infile);
   65    if (!in.is_open()) {
   66      std::cerr << "Cannot open input file " << infile << "\n";
   67      exit(1);
   68    }
   69    string line;
   70    std::regex classDefRegex(R"(ClassDef\s*(?:NV)?\(\s*(.*)\s*,\s*(\d*))");
   71    std::regex apiV2Regex("namespace.*APIV2");
   72    std::smatch classDefMatch;
   73    bool v2{false};
   74    string stype{""};
   75    bool used{false};
   77      if (std::regex_search(line, apiV2Regex)) {
   78        v2 = true;
Includes parseIncludes(const std::vector< std::string > &includes)
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
 
 
 
 
◆ main()
      
        
          | int main  | 
          ( | 
          int |           argc,  | 
        
        
           | 
           | 
          char ** |           argv ) | 
        
      
 
Helper program to create includes files for types and includes from a list of JDB includes. 
Definition at line 85 of file classdef2code.cc.
   86               {
   87          cn.api.emplace_back(stype);
   88          used = true;
   89        }
   90      }
   91    }
   92    if (used) {
   93      cn.files.emplace_back(infile);
   94    }
   95  }
   96  return cn;
   97}
   98 
   99
  100
  101
  102
  103
  104int main(
int argc, 
char **argv) {
 
  105  if (argc < 5) {
  106    throw runtime_error("need at least 4 arguments");
  107  }
  108  string outfile = argv[1];    
  109  string outputType = argv[2]; 
  111                            
  112  for (int i = 3; i < argc; i++) {
  113    classdefs.emplace_back(argv[i]);
  114  }
  115 
int main(int argc, char **argv)
Helper program to create includes files for types and includes from a list of JDB includes.