aboutsummaryrefslogtreecommitdiff
path: root/tests/manifest-roundtrip/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manifest-roundtrip/driver.cxx')
-rw-r--r--tests/manifest-roundtrip/driver.cxx52
1 files changed, 23 insertions, 29 deletions
diff --git a/tests/manifest-roundtrip/driver.cxx b/tests/manifest-roundtrip/driver.cxx
index 1f0b311..654763e 100644
--- a/tests/manifest-roundtrip/driver.cxx
+++ b/tests/manifest-roundtrip/driver.cxx
@@ -31,40 +31,34 @@ using namespace std;
using namespace butl;
int
-main (int argc, char* argv[])
+main ()
+try
{
- if (argc != 2)
- {
- cerr << "usage: " << argv[0] << " <file>" << endl;
- return 1;
- }
+ // Read/write in binary mode.
+ //
+ stdin_fdmode (fdstream_mode::binary);
+ stdout_fdmode (fdstream_mode::binary);
- try
- {
- ifdstream ifs (argv[1]);
- manifest_parser p (ifs, argv[1]);
+ manifest_parser p (cin, "stdin");
+ manifest_serializer s (cout, "stdout");
- stdout_fdmode (fdstream_mode::binary); // Write in binary mode.
- manifest_serializer s (cout, "stdout");
+ for (bool eom (true), eos (false); !eos; )
+ {
+ manifest_name_value nv (p.next ());
- for (bool eom (true), eos (false); !eos; )
+ if (nv.empty ()) // End pair.
{
- manifest_name_value nv (p.next ());
-
- if (nv.empty ()) // End pair.
- {
- eos = eom;
- eom = true;
- }
- else
- eom = false;
-
- s.next (nv.name, nv.value);
+ eos = eom;
+ eom = true;
}
+ else
+ eom = false;
+
+ s.next (nv.name, nv.value);
}
- catch (const exception& e)
- {
- cerr << e << endl;
- return 1;
- }
+}
+catch (const exception& e)
+{
+ cerr << e << endl;
+ return 1;
}