5 #include <Atlas/Codecs/XML.h> 7 #include <Atlas/Codecs/Packed.h> 8 #include <Atlas/Message/QueuedDecoder.h> 9 #include <Atlas/Message/MEncoder.h> 10 #include <Atlas/Formatter.h> 18 int option_format = 0;
19 int option_spacing = -1;
24 else if (type ==
"Bach")
26 else if (type ==
"Packed")
33 std::cout <<
"Unknown CODEC required!" << std::endl;
38 int convert(
const std::string& file_in,
const std::string& codec_in,
39 const std::string& file_out,
const std::string& codec_out) {
40 std::cout <<
"Convert " << codec_in <<
" to " << codec_out << std::endl;
44 in.open(file_in.c_str(), std::ios::in);
47 std::cerr <<
"Unable to open " << file_in <<
" for input" 48 << std::endl << std::flush;
52 out.open(file_out.c_str(), std::ios::out);
55 std::cerr <<
"Unable to open " << file_out <<
" for output" 56 << std::endl << std::flush;
60 std::cout <<
"Reading... ";
68 std::cout <<
"done." << std::endl;
69 std::cout <<
"Writing... ";
71 Atlas::Codec* outCodec = getCodec(codec_out, out, decoder);
77 if (option_spacing != -1) {
78 format->setSpacing(option_spacing);
85 encoder.streamBegin();
87 Atlas::Message::MapType msg(decoder.
popMessage());
88 encoder.streamMessageElement(msg);
92 std::cout <<
"done." << std::endl;
100 void usage(
const char* program) {
101 std::cout <<
"usage: " << program
102 <<
" [-i infile] [-o outfile] <input file> <output file>" 104 std::cout <<
"Supported Codecs: XML Back Packed" 105 << std::endl << std::flush;
108 int main(
int argc,
char** argv )
110 std::string codec_in(
"XML"),
114 int c = getopt(argc, argv,
"fs:i:o:");
117 }
else if (c ==
'f') {
119 }
else if (c ==
's') {
120 option_spacing = strtol(optarg,
nullptr, 0);
121 }
else if (c ==
'i') {
123 }
else if (c ==
'o') {
128 if ((argc - optind) != 2) {
133 std::string file_in(argv[argc - 2]);
134 std::string file_out(argv[argc - 1]);
136 std::cout <<
"Reading from " << file_in <<
" to " << file_out << std::endl << std::flush;
139 return convert(file_in, codec_in, file_out, codec_out);
size_t queueSize()
Retrieve the current size of the message queue.
MapType popMessage()
Pop an object from the front of the message queue.