Async 1.8.0
|
A message packing framework. More...
#include <istream>
#include <ostream>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <limits>
#include <endian.h>
#include <stdint.h>
Go to the source code of this file.
Classes | |
class | Async::MsgPacker< T > |
class | Async::MsgPacker< char > |
class | Async::Packer64< T > |
class | Async::MsgPacker< uint64_t > |
class | Async::MsgPacker< int64_t > |
class | Async::MsgPacker< double > |
class | Async::Packer32< T > |
class | Async::MsgPacker< uint32_t > |
class | Async::MsgPacker< int32_t > |
class | Async::MsgPacker< float > |
class | Async::Packer16< T > |
class | Async::MsgPacker< uint16_t > |
class | Async::MsgPacker< int16_t > |
class | Async::Packer8< T > |
class | Async::MsgPacker< uint8_t > |
class | Async::MsgPacker< int8_t > |
class | Async::MsgPacker< std::string > |
class | Async::MsgPacker< std::vector< I > > |
class | Async::MsgPacker< std::set< I > > |
class | Async::MsgPacker< std::map< Tag, Value > > |
class | Async::MsgPacker< std::array< T, N > > |
class | Async::MsgPacker< T[N]> |
class | Async::Msg |
Base class for all messages. More... | |
Namespaces | |
namespace | Async |
Namespace for the asynchronous programming classes. | |
Macros | |
#define | ASYNC_MSG_DERIVED_FROM(BASE_CLASS) |
Define which class is the baseclass. | |
#define | ASYNC_MSG_MEMBERS(...) |
Define which members of the class that should be packed. | |
#define | ASYNC_MSG_NO_MEMBERS |
Specify that this class have no members to pack. | |
A message packing framework.
This is a message packing framework for use when for example sending network messages or storing structured binary data to a file. Messages are defined as classes which can be packed (serialized) and unpacked (deserialized) to/from a stream. This is a simple example class:
The most common types may be packed, like number types, std::string, std::vector, std::map. Adding new types are rather simple. This is an example implementing support for the std::pair type:
Inheritance is also possible. If you want the base class to also be packed when the derived class is packed, use the ASYNC_MSG_DERIVED_FROM macro. The use of the std::pair extension is also demonstrated here.
These classes can be used in the usual way but with the extra property that they can be serialized/deserialized to/from a stream.
For a working example, have a look at the demo application, AsyncMsg_demo.cpp.
Async - A library for programming event driven applications Copyright (C) 2003-2023 Tobias Blomberg / SM0SVX This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Definition in file AsyncMsg.h.
#define ASYNC_MSG_DERIVED_FROM | ( | BASE_CLASS | ) |
Define which class is the baseclass.
BASE_CLASS | The name of the baseclass |
Use this macro in a class definition to define which class is the base class. Multiple inheritance is not supported.
Definition at line 193 of file AsyncMsg.h.
#define ASYNC_MSG_MEMBERS | ( | ... | ) |
Define which members of the class that should be packed.
Use this macro to define which members of the class that should be packed. Variables not listed here will not be included in the serialized version of the class.
Definition at line 214 of file AsyncMsg.h.
#define ASYNC_MSG_NO_MEMBERS |
Specify that this class have no members to pack.
If the class have no members to pack, this macro must be used.
Definition at line 233 of file AsyncMsg.h.