serializationExample.cpp

This example show how to serialize and deserialize objects.

Serializing objects
Deserializing objects
Rate1
ACT365_Simple

Rate2
ACTACT_ISDA_Simple

Rate3
ACT365_Exponential

#include <juliant.hpp>
#include <utility>
using namespace julian;
int main() {
//
// Creating objects to serialize
//
std::map<std::string, InterestRate> rates;
SimpleRate comp1;
ACT365 yf1;
InterestRate rate1(comp1, yf1);
InterestRate rate2(comp1, yf2);
InterestRate rate3(comp2, yf1);
rates["Rate1"] = rate1;
rates["Rate2"] = rate2;
rates["Rate3"] = rate3;
//
// Serialization
//
std::cout << "Serializing objects" << std::endl;
serializeBinary(rates,"rates.dat");
//
// Deserialization
//
std::cout << "Deserializing objects" << std::endl;
std::map<std::string, InterestRate> rates_reread = deserializeBinary<std::map<std::string, InterestRate> >("rates.dat");
for (auto x : rates_reread) {
std::cout << x.first << "\n" << x.second << std::endl << std::endl;
}
}