Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
byte_io_impl.h
Package: ioSerialization.rar [view]
Upload User: kx_jwh
Upload Date: 2021-09-03
Package Size: 76k
Code Size: 3k
Category:
STL
Development Platform:
Visual C++
- /* vim: set tabstop=4 : */
- #ifndef __febird_io_byte_io_impl_h__
- #define __febird_io_byte_io_impl_h__
- #if defined(_MSC_VER) && (_MSC_VER >= 1020)
- # pragma once
- #endif
- // #include "IOException.h"
- // #include "sstream"
- #define BYTE_IO_EMPTY
- #define FEBIRD_GEN_ensureRead(prefix)
- void prefix ensureRead(void* vbuf, size_t length)
- {
- size_t n = this->read(vbuf, length);
- if (n != length)
- {
- std::ostringstream oss;
- oss << """ << BOOST_CURRENT_FUNCTION << """
- << ", ReadBytes[want=" << length << ", read=" << n << "]";
- throw EndOfFileException(oss.str().c_str());
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #define FEBIRD_GEN_ensureWrite(prefix)
- void prefix ensureWrite(const void* vbuf, size_t length)
- {
- size_t n = this->write(vbuf, length);
- if (n != length)
- {
- std::ostringstream oss;
- oss << """ << BOOST_CURRENT_FUNCTION << """
- << ", WriteBytes[want=" << length << ", written=" << n << "]";
- throw OutOfSpaceException(oss.str().c_str());
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #define FEBIRD_GEN_getByte(prefix)
- int prefix getByte()
- {
- unsigned char b;
- if (this->read(&b, 1) == 0)
- return -1;
- return b;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #define FEBIRD_GEN_readByte(prefix)
- unsigned char prefix readByte()
- {
- unsigned char b;
- if (this->read(&b, 1) == 0)
- throw EndOfFileException(BOOST_CURRENT_FUNCTION);
- return b;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #define FEBIRD_GEN_writeByte(prefix)
- void prefix writeByte(unsigned char b)
- {
- if (this->write(&b, 1) == 0)
- throw OutOfSpaceException(BOOST_CURRENT_FUNCTION);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- /*
- namespace febird {
- template<class Stream>
- class InputStream_Method_Impl
- {
- public:
- unsigned char readByte()
- {
- unsigned char b;
- if (static_cast<Stream&>(*this).read(&b, 1) == 0)
- throw EndOfFileException(BOOST_CURRENT_FUNCTION);
- return b;
- }
- void ensureRead(void* vbuf, size_t length)
- {
- size_t n = static_cast<Stream&>(*this).read(vbuf, length);
- if (n != length)
- {
- std::ostringstream oss;
- oss << """ << BOOST_CURRENT_FUNCTION << """
- << ", ReadBytes[want=" << length << ", read=" << n << "]";
- throw EndOfFileException(oss.str().c_str());
- }
- }
- };
- template<class Stream>
- class OutputStream_Method_Impl
- {
- public:
- void writeByte(unsigned char b)
- {
- if (static_cast<Stream&>(*this).write(&b, 1) == 0)
- throw OutOfSpaceException(BOOST_CURRENT_FUNCTION);
- }
- void ensureWrite(const void* vbuf, size_t length)
- {
- size_t n = static_cast<Stream&>(*this).write(vbuf, length);
- if (n != length)
- {
- std::ostringstream oss;
- oss << """ << BOOST_CURRENT_FUNCTION << """
- << ", WriteBytes[want=" << length << ", written=" << n << "]";
- throw OutOfSpaceException(oss.str().c_str());
- }
- }
- };
- template<class Stream>
- class ByteIoImplement :
- public InputStream_Method_Impl<Stream>,
- public OutputStream_Method_Impl<Stream>
- {
- public:
- };
- } // namespace febird
- */
- #endif