#include <iostream>
#include "univcont.h"
using namespace std;using namespace JAD;
void print_person(UniversalContainer& uc)
{
string name = uc["name"];
string age = uc["age"];
char sex = uc["sex"];
cout << name << '\t' << sex << '\t' << age << endl;
}
int main(int argc, char** argv)
{
try {
UniversalContainer solider; solider["name"] = "Kansas Smith";
solider["age"] = 23;
solider["officer"] = false;
solider["serial"] = 789456;
solider["sex"] = "M";
solider["wage"] = 25.75; solider["spouse"]["name"] = "Sue Smith";
solider["spouse"]["sex"] = "F";
solider["spouse"]["age"] = "Won't Say"; solider["dependants"][0]["name"] = "Joe Smith";
solider["dependants"][0]["age"] = 3;
solider["dependants"][0]["sex"] = "M";
solider["dependants"][1]["name"] = "Ann Smith";
solider["dependants"][1]["age"] = 1;
solider["dependants"][1]["sex"] = "F";
solider["dependants"][2]["name"] = "On the way";
cout << "NAME" << "\t\t" << "SEX" << "\t" << "AGE" << endl;
print_person(solider); print_person(solider["spouse"]); for (unsigned i = 0; i < solider["dependants"].size(); i++)
print_person(solider["dependants"][i]); cout << "The litte girls name is " <<
(string)solider["dependants.1.name"] << endl; double combat_pay = (double)solider["wage"] + 5.35;
cout << "Combat pay is " << combat_pay << endl; Buffer* buf = uc_encode_ini(solider);
write_from_buffer(buf,stdout);
delete buf;
} catch(UniversalContainer uce) {
cout << "An exception was thrown." << endl;
print(uce);
}
}