#include #include #include #include #include "refptr/refptr.h" #include "serialize.h" #include "unicode.h" #include "parse-input.h" using namespace std; int main(int argc, char * argv[]) { int longind = 1; int opt; const char * encoding = "UTF-8"; static struct option longopts[] = { /* name, has_arg, flag, val */ { "encoding", required_argument, NULL, 'e' }, { NULL, 0, NULL, 0 } }; while ((opt = getopt_long(argc, argv, "", longopts, &longind)) != -1) { switch (opt) { case 'e': /* encoding */ encoding = optarg; break; } } ifstream ifs; ifs.open(argv[optind], ios::binary); if (!ifs.is_open()) { cerr << "Error opening input file: '" << argv[optind] << "'"; return 2; } refptr< vector > ucs = deserialize(encoding, ifs); if (ucs.isNull()) { cerr << "Error deserializing input file." << endl; return 1; } parse_input(ucs); return 0; }