| namespace | |
| { | |
| std::vector<char> read_file(const std::string &path) | |
| { | |
| std::ifstream in(path, std::ios::binary | std::ios::ate); | |
| if (!in) | |
| throw std::runtime_error("failed to open input"); | |
| const auto size = in.tellg(); | |
| if (size < 0) | |
| throw std::runtime_error("failed to measure input"); | |
| std::vector<char> data(static_cast<size_t>(size)); | |
| in.seekg(0); | |
| in.read(data.data(), static_cast<std::streamsize>(data.size())); | |
| if (!in) | |
| throw std::runtime_error("failed to read input"); | |
| return data; | |
| } | |
| } // namespace | |
| int main(int argc, char **argv) | |
| { | |
| if (argc != 2) | |
| { | |
| std::cerr << "usage: " << argv[0] << " model.circle\n"; | |
| return 2; | |
| } | |
| auto raw = read_file(argv[1]); | |
| auto *model = circle::GetModel(raw.data()); | |
| circledump::ModelEx modelex{model, &raw}; | |
| std::cout << modelex << std::endl; | |
| return 0; | |
| } | |