#include "TecioSZL.h"
#include "ThirdPartyHeadersBegin.h"
#include <cstring>
#include <iostream>
#include <string>
#include "ThirdPartyHeadersEnd.h"
void printUsage(char const* programName) { std::cerr << "Usage: " << programName << " infilebasename [-c] [-o outfilename]" << std::endl << std::endl; std::cerr << "Type " << programName << " -h for detailed instructions." << std::endl; } int main(int argc, char** argv) { if (argc < 2 || 5 < argc) { printUsage(argv[0]); return 1; } if (std::string(argv[1]) == "-h" || std::string(argv[1]) == "--help") { std::cout << "Usage: " << argv[0] << " [-c] [-o outfilename] infilebasename" << std::endl << std::endl; std::cout << "Combine a set of szl intermediate files into a .szplt file." << std::endl << std::endl; std::cout << "infilebasename represents a group of intermediate files output" << std::endl; std::cout << "by the Tecio library's flush routine. All six intermediate files" << std::endl; std::cout << "must exist for the command to succeed. For example, the command" << std::endl << std::endl; std::cout << "    " << argv[0] << " myfile.szplt" << std::endl << std::endl; std::cout << "would copy the files myfile.szplt.szhdr, myfile.szplt.szdat," << std::endl; std::cout << "myfile.szplt.sztxt, myfile.szplt.szgeo, myfile.szplt.szaux," << std::endl; std::cout << "and myfile.szplt.szlab, into file myfile.szplt." << std::endl; std::cout << "If myfile.szplt already existed, it would be overwritten." << std::endl << std::endl; std::cout << "If you wish to remove the set of intermediate files, then" << std::endl; std::cout << "use the -c (cleanup) flag. If you wish to supply a different output" << std::endl; std::cout << "file name, then use the -o option and provide the file name." << std::endl << std::endl; std::cout << "Please note that using the -c flag is much faster because it" << std::endl; std::cout << "combines the files in-place and avoids copying a lot of data." << std::endl; return 0; } std::string intermediateFileBaseName; std::string szpltFileName; bool cleanup = false; for (int i = 1; i < argc; ++i) { if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--cleanup") == 0) { cleanup = true; } else if (strcmp(argv[i], "-o") == 0 || strcmp(argv[i], "--outfilename") == 0) { if (i == argc - 1) { std::cerr << "Missing outfilename." << std::endl; printUsage(argv[0]); return 1; } else { szpltFileName = argv[i + 1]; ++i; } } else if (intermediateFileBaseName.empty()) { intermediateFileBaseName = argv[i]; } else { std::cerr << "Unrecognized argument: " << argv[i] << std::endl; printUsage(argv[0]); return 1; } } if (intermediateFileBaseName.empty()) { std::cerr << "Missing argument infilebasename." << std::endl; printUsage(argv[0]); return 1; } if (szpltFileName.empty()) szpltFileName = intermediateFileBaseName; return tecplot::tecioszl::convertIntermediateFilesToSZLFile(NULL, intermediateFileBaseName, cleanup, szpltFileName, argv[0]); }
