1//
2// BinaryReaderWriter.cpp
3//
4// This sample demonstrates the BinaryWriter and BinaryReader classes.
5//
6// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
7// and Contributors.
8//
9// SPDX-License-Identifier: BSL-1.0
10//
11
12
13#include "Poco/BinaryWriter.h"
14#include "Poco/BinaryReader.h"
15#include <sstream>
16#include <iostream>
17
18
19using Poco::BinaryWriter;
20using Poco::BinaryReader;
21
22
23int main(int argc, char** argv)
24{
25 std::stringstream str;
26
27 BinaryWriter writer(str);
28 writer << true
29 << 'x'
30 << 42
31 << 3.14159265
32 << "foo bar";
33
34 bool b;
35 char c;
36 int i;
37 double d;
38 std::string s;
39
40 BinaryReader reader(str);
41 reader >> b
42 >> c
43 >> i
44 >> d
45 >> s;
46
47 std::cout << b << std::endl
48 << c << std::endl
49 << i << std::endl
50 << d << std::endl
51 << s << std::endl;
52
53 return 0;
54}
55