Click here to Skip to main content
15,897,518 members
Articles / Programming Languages / C++

RMI for C++

Rate me:
Please Sign up or sign in to vote.
4.87/5 (113 votes)
6 Aug 2009CPOL8 min read 844K   4.6K   153  
User-friendly remote method invocation in C++.
//*****************************************************************************
// RCF - Remote Call Framework
// Copyright (c) 2005, Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//
// Distributed under the so-called MIT license, see accompanying file license.txt.
//*****************************************************************************

#ifndef _SF_PORTABLETYPES_HPP_
#define _SF_PORTABLETYPES_HPP_

#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>

namespace SF {

    //***********************************************************************
    // Define some portable types (sizeof(...) will be same on all platforms)

    typedef bool                                Bool8;
    typedef char                                Char8;
    typedef unsigned char                       UChar8;
    typedef char                                Byte8;
    typedef float                               Float32;
    typedef double                              Double64;
    typedef boost::uint16_t                     Short16;
    typedef boost::int32_t                      Int32;
    typedef boost::uint32_t                     UInt32;
    
    BOOST_STATIC_ASSERT( sizeof(Bool8) == 1 );
    BOOST_STATIC_ASSERT( sizeof(Char8) == 1 );
    BOOST_STATIC_ASSERT( sizeof(UChar8) == 1 );
    BOOST_STATIC_ASSERT( sizeof(Byte8) == 1 );
    BOOST_STATIC_ASSERT( sizeof(Short16) == 2 );
    BOOST_STATIC_ASSERT( sizeof(Int32) == 4 );
    BOOST_STATIC_ASSERT( sizeof(UInt32) == 4 );
    BOOST_STATIC_ASSERT( sizeof(Float32) == 4 );
    BOOST_STATIC_ASSERT( sizeof(Double64) == 8 );

    template<typename T> struct PortableT;
    template<> struct PortableT<bool>            { typedef Bool8 Val; };
    template<> struct PortableT<char>            { typedef Char8 Val; };
    template<> struct PortableT<unsigned char>    { typedef Char8 Val; };
    template<> struct PortableT<short>            { typedef Short16 Val; };
    template<> struct PortableT<unsigned short>    { typedef Short16 Val; };
    template<> struct PortableT<int>            { typedef Int32 Val; };
    template<> struct PortableT<unsigned int>    { typedef Int32 Val; };
    template<> struct PortableT<long>            { typedef Int32 Val; };
    template<> struct PortableT<unsigned long>    { typedef Int32 Val; };
    template<> struct PortableT<float>            { typedef Float32 Val; };
    template<> struct PortableT<double>            { typedef Double64 Val; };
    template<> struct PortableT<long double>    { typedef Double64 Val; };

} // namespace SF

#endif // ! _SF_PORTABLETYPES_HPP_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Australia Australia
Software developer, from Sweden and now living in Canberra, Australia, working on distributed C++ applications. When he is not programming, Jarl enjoys skiing and playing table tennis. He derives immense satisfaction from referring to himself in third person.

Comments and Discussions