| 1 | //
|
|---|
| 2 | // Create simple binary archive
|
|---|
| 3 | //
|
|---|
| 4 | #include <fstream>
|
|---|
| 5 | #include <ios>
|
|---|
| 6 | #include <iostream>
|
|---|
| 7 | #include <boost/integer_traits.hpp>
|
|---|
| 8 | #include <boost/archive/binary_oarchive.hpp>
|
|---|
| 9 | #include <boost/version.hpp>
|
|---|
| 10 |
|
|---|
| 11 | using namespace std;
|
|---|
| 12 | int main(int argc, char *argv[])
|
|---|
| 13 | {
|
|---|
| 14 | string file_name("arch_");
|
|---|
| 15 | file_name += BOOST_LIB_VERSION;
|
|---|
| 16 | file_name += ".dat";
|
|---|
| 17 | ofstream arch(file_name.c_str(), ios_base::binary);
|
|---|
| 18 | if(!arch.is_open()){
|
|---|
| 19 | std::cout << file_name << " failed to open" << std::endl;
|
|---|
| 20 |
|
|---|
| 21 | }
|
|---|
| 22 | try
|
|---|
| 23 | {
|
|---|
| 24 | boost::archive::binary_oarchive oa(arch);
|
|---|
| 25 | short short_val = 0x1111;
|
|---|
| 26 | int int_val = 0x22222222;
|
|---|
| 27 | double double_val = 3.0;
|
|---|
| 28 | oa << short_val;
|
|---|
| 29 | oa << int_val;
|
|---|
| 30 | oa << double_val;
|
|---|
| 31 | }
|
|---|
| 32 | catch(exception &e)
|
|---|
| 33 | {
|
|---|
| 34 | cout << "archive serializations error - " << e.what() << endl;
|
|---|
| 35 | return 1;
|
|---|
| 36 | }
|
|---|
| 37 | cout << "create archive - " << file_name << endl;
|
|---|
| 38 | return 0;
|
|---|
| 39 | }
|
|---|