YARP
Yet Another Robot Platform
BinPortable-inl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_BINPORTABLE_INL_H
11 #define YARP_OS_BINPORTABLE_INL_H
12 
15 
16 template <class T>
18 {
19  return t;
20 }
21 
22 template <class T>
23 
25 {
26  // An exception will get thrown upon error.
27  // Pending: translate this in expectBlock to a return value.
28  connection.convertTextMode(); // if connection is text-mode, convert!
29  connection.expectBlock((char*)(&t), sizeof(T));
30  return true;
31 }
32 
33 template <class T>
35 {
36  connection.appendBlock((char*)(&t), sizeof(T));
37  connection.convertTextMode(); // if connection is text-mode, convert!
38  return true;
39 }
40 
41 #endif // YARP_OS_BINPORTABLE_INL_H
float t
bool read(ConnectionReader &connection) override
Read this object from a network connection.
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
T & content()
Get the internal structure that will be read or written.
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
An interface for writing to a network connection.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.