1 | #include <sstream>
|
---|
2 | #include <iostream>
|
---|
3 | #include <string.h>
|
---|
4 | #include <boost/archive/text_oarchive.hpp>
|
---|
5 | #include <boost/archive/text_iarchive.hpp>
|
---|
6 |
|
---|
7 | int main()
|
---|
8 | {
|
---|
9 |
|
---|
10 | std::string arc = "22 serialization::archive 5 1 2 3 4\n";
|
---|
11 |
|
---|
12 | std::istringstream inStringStream(arc);
|
---|
13 |
|
---|
14 | std::istringstream iTest("1 2 3 4\n");
|
---|
15 |
|
---|
16 | int a;
|
---|
17 |
|
---|
18 | iTest >> a;
|
---|
19 | std::cout << a << std::endl;
|
---|
20 | iTest >> a;
|
---|
21 | std::cout << a << std::endl;
|
---|
22 | iTest >> a;
|
---|
23 | std::cout << a << std::endl;
|
---|
24 |
|
---|
25 | std::cout << inStringStream.str() << std::endl;
|
---|
26 |
|
---|
27 | boost::archive::text_iarchive inStream(inStringStream);
|
---|
28 |
|
---|
29 | int b;
|
---|
30 |
|
---|
31 | std::cout << inStringStream.tellg() << " " << inStringStream.gcount() << std::endl;
|
---|
32 |
|
---|
33 | inStream >> b;
|
---|
34 |
|
---|
35 | std::cout << "Val: " << b << " " << inStringStream.tellg() << " " << inStringStream.gcount() << std::endl;
|
---|
36 |
|
---|
37 | inStream >> b;
|
---|
38 |
|
---|
39 | std::cout << "Val: " << b << " " << inStringStream.tellg() << " " << inStringStream.gcount() << std::endl;
|
---|
40 |
|
---|
41 | inStream >> b;
|
---|
42 |
|
---|
43 | std::cout << "Val: " << b << " " << inStringStream.tellg() << " " << inStringStream.gcount() << std::endl;
|
---|
44 |
|
---|
45 | if(inStringStream.eof()) { std::cout << "EOF" << std::endl; }
|
---|
46 | if(inStringStream.bad()) { std::cout << "BAD" << std::endl; }
|
---|
47 |
|
---|
48 | inStream >> b;
|
---|
49 |
|
---|
50 | std::cout << "Type: " << b << " " << inStringStream.tellg() << " " << inStringStream.gcount() << std::endl;
|
---|
51 |
|
---|
52 | std::cout << "Restored all" << std::endl;
|
---|
53 |
|
---|
54 | }
|
---|