#include #include #include #include #include #include #include "JIO/JByteArrayIO.hh" #include "JIO/JSTDIO.hh" #include "JLang/JObjectID.hh" #include "Jeep/JStreamToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JIO::JByteArrayReader and JIO::JByteArrayWriter. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; int debug; try { JParser<> zap("Example program to test byte array I/O."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } int i1 = 999; double x1 = 123.456; string s1 = "hello world"; JObjectID o1 = 999; vector v1; for (double x = 0.0; x < 10.5; x += 1.0) { v1.push_back(x); } list l1; l1.push_back("hello"); l1.push_back("world"); map m1; m1[1] = 1; m1[2] = 4; m1[3] = 9; JByteArrayWriter out; out << i1 << x1 << s1 << v1 << l1 << m1 << o1; DEBUG("Buffer size " << out.size() << endl); JByteArrayReader in(out.data(), out.size()); int i2 = 0; double x2 = 0.0; string s2 = ""; JObjectID o2 = -1; vector v2; list l2; map m2; in >> i2 >> x2 >> s2 >> v2 >> l2 >> m2 >> o2; ASSERT(i1 == i2); ASSERT(x1 == x2); ASSERT(s1 == s2); ASSERT(v1 == v2); ASSERT(l1 == l2); ASSERT(m1 == m2); ASSERT(o1 == o2); return 0; }