mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-05-09 20:47:12 +02:00
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
55 lines
924 B
C++
55 lines
924 B
C++
//
|
|
// BinaryReaderWriter.cpp
|
|
//
|
|
// This sample demonstrates the BinaryWriter and BinaryReader classes.
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/BinaryWriter.h"
|
|
#include "Poco/BinaryReader.h"
|
|
#include <sstream>
|
|
#include <iostream>
|
|
|
|
|
|
using Poco::BinaryWriter;
|
|
using Poco::BinaryReader;
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
std::stringstream str;
|
|
|
|
BinaryWriter writer(str);
|
|
writer << true
|
|
<< 'x'
|
|
<< 42
|
|
<< 3.14159265
|
|
<< "foo bar";
|
|
|
|
bool b;
|
|
char c;
|
|
int i;
|
|
double d;
|
|
std::string s;
|
|
|
|
BinaryReader reader(str);
|
|
reader >> b
|
|
>> c
|
|
>> i
|
|
>> d
|
|
>> s;
|
|
|
|
std::cout << b << std::endl
|
|
<< c << std::endl
|
|
<< i << std::endl
|
|
<< d << std::endl
|
|
<< s << std::endl;
|
|
|
|
return 0;
|
|
}
|