Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

RMI for C++

, 6 Aug 2009
User-friendly remote method invocation in C++.
rcf.zip
RCF
demo
vs2003
RCF
Client
Server
doc
include
RCF
Connection.inl
Marshal.inl
Multiplexer.inl
RCF.inl
RcfServer.inl
ServerStub.inl
Protocol
util
Platform
Compiler
bcc55
cw80
gcc32
icl70
msvc71
Library
bcc55
cw80
gcc32
msvc60
msvc71
Machine
SPARC
x86
OS
Cygwin
Unix
Windows
System
NonWindows
Windows
Threads
SF
src
RCF
Protocol
util
SF
test
Jamfile
Jamrules
borland
Jamfile
Jamrules
vs2003
RCF
RCF
RCFTest
//*****************************************************************************
// Copyright (c) 2003. All rights reserved.
// Developed by Jarl Lindrud.
// Contact: jlindrud@hotmail.com .
//*****************************************************************************

#ifndef _UTIL_ASSERT_HPP_
#define _UTIL_ASSERT_HPP_

#include <cassert>
#include <exception>

#include <boost/current_function.hpp>

#include "VariableArgMacro.hpp"

//*************************************************
// Assert utility

namespace util {

    template<typename E> 
    struct AssertFunctorDebug : public VariableArgMacroFunctor
    {
        ~AssertFunctorDebug() 
        { 
            assert(0); 
        }
    };

    template<typename E> struct AssertFunctorRelease : public VariableArgMacroFunctor
    {
        ~AssertFunctorRelease() 
        { 
            if (!std::uncaught_exception()) 
            {
                throw E( (header.str() + args.str()).c_str() ); 
            }
        }
    };


#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4355 )  // warning C4355: 'this' : used in base member initializer list
#endif

    DECLARE_VARIABLE_ARG_MACRO_T1( UTIL_ASSERT_DEBUG, AssertFunctorDebug );
    #define UTIL_ASSERT_DEBUG(cond, E)                if (cond) ; else util::VariableArgMacro<util::AssertFunctorDebug< E > >().init( "ASSERT: ", #cond, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION ).cast( (util::VariableArgMacro<util::AssertFunctorDebug< E > > *) NULL).UTIL_ASSERT_DEBUG_A
    #define UTIL_ASSERT_DEBUG_A(x)                    UTIL_ASSERT_DEBUG_OP(x, B)
    #define UTIL_ASSERT_DEBUG_B(x)                    UTIL_ASSERT_DEBUG_OP(x, A)
    #define UTIL_ASSERT_DEBUG_OP(x, next)             UTIL_ASSERT_DEBUG_A.notify_((x), #x).UTIL_ASSERT_DEBUG_ ## next

    DECLARE_VARIABLE_ARG_MACRO_T1( UTIL_ASSERT_RELEASE, AssertFunctorRelease );
    #define UTIL_ASSERT_RELEASE(cond, E)                if (cond) ; else  util::VariableArgMacro<util::AssertFunctorRelease< E > >().init( "ASSERT: ", #cond, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION ).cast( (util::VariableArgMacro<util::AssertFunctorRelease< E > > *) NULL).UTIL_ASSERT_RELEASE_A
    #define UTIL_ASSERT_RELEASE_A(x)                    UTIL_ASSERT_RELEASE_OP(x, B)
    #define UTIL_ASSERT_RELEASE_B(x)                    UTIL_ASSERT_RELEASE_OP(x, A)
    #define UTIL_ASSERT_RELEASE_OP(x, next)             UTIL_ASSERT_RELEASE_A.notify_((x), #x).UTIL_ASSERT_RELEASE_ ## next

    #define UTIL_ASSERT_NULL(cond, E) DUMMY_VARIABLE_ARG_MACRO()

#ifdef _MSC_VER
#pragma warning( pop )
#endif


    #ifdef NDEBUG
    //#define UTIL_ASSERT UTIL_ASSERT_NULL    
    #define UTIL_ASSERT UTIL_ASSERT_RELEASE
    #else
    #define UTIL_ASSERT UTIL_ASSERT_DEBUG
    #endif

} // namespace util

#endif //! _UTIL_ASSERT_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)

Share

About the Author

Jarl Lindrud

Australia Australia
Software developer, ex-resident of Sweden and now living in Canberra, Australia, working on distributed C++ applications. Jarl enjoys programming, but prefers skiing and playing table tennis. He derives immense satisfaction from referring to himself in third person.

| Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 6 Aug 2009
Article Copyright 2005 by Jarl Lindrud
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid