Ticket #4260: stream.cpp

File stream.cpp, 1.3 KB (added by crispin.boylan@…, 12 years ago)

Simple test

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