|
| 1 | +#include <iostream> |
| 2 | +#include <string> |
| 3 | +#include <vector> |
| 4 | + |
| 5 | +#include "models/coek_models.hpp" |
| 6 | + |
| 7 | +void print_help() |
| 8 | +{ |
| 9 | + std::cout << "coek_build [-d] <model> [<data> ...]" << std::endl; |
| 10 | + std::cout << std::endl << "TEST MODELS" << std::endl; |
| 11 | + print_models(std::cout); |
| 12 | + std::cout << std::endl; |
| 13 | +} |
| 14 | + |
| 15 | +int main(int argc, char* argv[]) |
| 16 | +{ |
| 17 | + if (argc <= 2) { |
| 18 | + print_help(); |
| 19 | + return 1; |
| 20 | + } |
| 21 | + |
| 22 | + bool debug = false; |
| 23 | + std::string model_name; |
| 24 | + std::vector<size_t> data; |
| 25 | + |
| 26 | + std::vector<std::string> args(argv + 1, argv + argc); |
| 27 | + |
| 28 | + // Loop over command-line args |
| 29 | + size_t i = 0; |
| 30 | + while (i < args.size()) { |
| 31 | + if (args[i] == "-h" || args[i] == "--help") { |
| 32 | + print_help(); |
| 33 | + return 0; |
| 34 | + } |
| 35 | + else if (args[i] == "-d") { |
| 36 | + debug = true; |
| 37 | + i++; |
| 38 | + } |
| 39 | + else { |
| 40 | + model_name = args[i++]; |
| 41 | + while (i < args.size()) |
| 42 | + data.push_back(std::stoul(args[i++])); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + if (debug) |
| 47 | + std::cout << " Model: " << model_name << " Data: " << data[0] |
| 48 | + << std::endl; |
| 49 | + coek::Model model; |
| 50 | + try { |
| 51 | + create_instance(model, model_name, data); |
| 52 | + } |
| 53 | + catch (std::exception& e) { |
| 54 | + std::cout << "ERROR - " << e.what() << std::endl; |
| 55 | + return 1; |
| 56 | + } |
| 57 | + |
| 58 | +#ifdef COEK_WITH_COMPACT_MODEL |
| 59 | + coek::CompactModel cmodel; |
| 60 | + try { |
| 61 | + create_instance(cmodel, model_name, data); |
| 62 | + } |
| 63 | + catch (std::exception& e) { |
| 64 | + std::cout << "ERROR - " << e.what() << std::endl; |
| 65 | + return 1; |
| 66 | + } |
| 67 | +#endif |
| 68 | + |
| 69 | + std::cout << "coek_build - DONE" << std::endl; |
| 70 | + return 0; |
| 71 | +} |
0 commit comments