SystemCall.h File Reference

#include <sstream>
#include "NetworkEx.h"

Go to the source code of this file.

Defines

#define socket_error   ( errno )
#define NET_FORMAT_CONCATENATE(ARG)   " " << (ARG) << ", // " << #ARG << "\n"
#define NET_FORMAT_END(ARG)   " " << (ARG) << " // " << #ARG
#define FORMAT_2(ARG1, ARG2)
#define FORMAT_3(ARG1, ARG2, ARG3)
#define FORMAT_5(ARG1, ARG2, ARG3, ARG4, ARG5)
#define FORMAT_6(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)
#define THROW_FORMATTED_ERROR(CODE, NOTE)
#define SOCKET_CALL_2(PREFIX, FUNC, ARG1, ARG2)
#define SOCKET_CALL_3(PREFIX, FUNC, ARG1, ARG2, ARG3)
#define SOCKET_CALL_5(PREFIX, FUNC, ARG1, ARG2, ARG3, ARG4, ARG5)
#define SOCKET_CALL_6(PREFIX, FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6)


Define Documentation

#define FORMAT_2 ARG1,
ARG2   ) 
 

Value:

"\n                (\n" << NET_FORMAT_CONCATENATE(ARG1) << NET_FORMAT_END(ARG2) \
   << "\n                )"

Definition at line 142 of file SystemCall.h.

#define FORMAT_3 ARG1,
ARG2,
ARG3   ) 
 

Value:

"\n                (\n" << NET_FORMAT_CONCATENATE(ARG1) << NET_FORMAT_CONCATENATE(ARG2) \
   << NET_FORMAT_END(ARG3) << "\n                )"

Definition at line 146 of file SystemCall.h.

#define FORMAT_5 ARG1,
ARG2,
ARG3,
ARG4,
ARG5   ) 
 

Value:

"\n                (\n" << NET_FORMAT_CONCATENATE(ARG1) << NET_FORMAT_CONCATENATE(ARG2) \
  << NET_FORMAT_CONCATENATE(ARG3) << NET_FORMAT_CONCATENATE(ARG4) << NET_FORMAT_END(ARG5) \
  << "\n                )"

Definition at line 150 of file SystemCall.h.

#define FORMAT_6 ARG1,
ARG2,
ARG3,
ARG4,
ARG5,
ARG6   ) 
 

Value:

"\n                (\n" << NET_FORMAT_CONCATENATE(ARG1) << NET_FORMAT_CONCATENATE(ARG2) \
  << NET_FORMAT_CONCATENATE(ARG3) << NET_FORMAT_CONCATENATE(ARG4) << NET_FORMAT_CONCATENATE(ARG5) \
  << NET_FORMAT_END(ARG6) << "\n                )"

Definition at line 155 of file SystemCall.h.

#define NET_FORMAT_CONCATENATE ARG   )     " " << (ARG) << ", // " << #ARG << "\n"
 

Definition at line 136 of file SystemCall.h.

#define NET_FORMAT_END ARG   )     " " << (ARG) << " // " << #ARG
 

Definition at line 139 of file SystemCall.h.

#define SOCKET_CALL_2 PREFIX,
FUNC,
ARG1,
ARG2   ) 
 

Value:

{ \
        if ((PREFIX FUNC (ARG1,ARG2)) == -1) \
                THROW_FORMATTED_ERROR(socket_error, #FUNC << FORMAT_2(ARG1,ARG2) ) \
}

Definition at line 171 of file SystemCall.h.

Referenced by TcpConnectionServer::listen(), and Socket::shutdown().

#define SOCKET_CALL_3 PREFIX,
FUNC,
ARG1,
ARG2,
ARG3   ) 
 

Value:

{ \
        if ((PREFIX FUNC (ARG1,ARG2,ARG3)) == -1) \
                THROW_FORMATTED_ERROR(socket_error, #FUNC << FORMAT_3(ARG1,ARG2,ARG3) ) \
}

Definition at line 177 of file SystemCall.h.

Referenced by TcpConnectionServer::accept(), Socket::bind(), ConnectableSocket::connectTo(), Socket::name(), ConnectableSocket::peerAddress(), Socket::reset(), and Socket::Socket().

#define SOCKET_CALL_5 PREFIX,
FUNC,
ARG1,
ARG2,
ARG3,
ARG4,
ARG5   ) 
 

Value:

{ \
        if ((PREFIX FUNC (ARG1,ARG2,ARG3,ARG4,ARG5)) == -1) \
                THROW_FORMATTED_ERROR(socket_error, #FUNC << FORMAT_5(ARG1,ARG2,ARG3,ARG4,ARG5) ) \
}

Definition at line 183 of file SystemCall.h.

Referenced by Socket::getOption(), and Socket::setOption().

#define SOCKET_CALL_6 PREFIX,
FUNC,
ARG1,
ARG2,
ARG3,
ARG4,
ARG5,
ARG6   ) 
 

Value:

{ \
        if ((PREFIX FUNC (ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)) == -1) \
                THROW_FORMATTED_ERROR(socket_error, #FUNC << FORMAT_6(ARG1,ARG2,ARG3,ARG4,ARG5,ARG6) ) \
}

Definition at line 189 of file SystemCall.h.

Referenced by ConnectableSocket::receiveFrom().

#define socket_error   ( errno )
 

Can we use this mechanism to wrap calls to the Operating System?? This would make our code more readable by getting rid of the macros

Functional extensions (see unary_function and binary_funcation for description)

template <class Arg1, class Arg2, class Arg3, class Result> struct trinary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Result> struct quadrary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Result> struct quinary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Arg5 fifth_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Result> struct hexary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Arg5 fifth_argument_type; typedef Arg6 sixth_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Result> struct septary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Arg5 fifth_argument_type; typedef Arg6 sixth_argument_type; typedef Arg7 seventh_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Result> struct octal_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Arg5 fifth_argument_type; typedef Arg6 sixth_argument_type; typedef Arg7 seventh_argument_type; typedef Arg8 eigth_argument_type; typedef Result result_type; };

template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Result> struct nonary_function { typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Arg3 third_argument_type; typedef Arg4 fourth_argument_type; typedef Arg5 fifth_argument_type; typedef Arg6 sixth_argument_type; typedef Arg7 seventh_argument_type; typedef Arg8 eigth_argument_type; typedef Arg9 ninth_argument_type; typedef Result result_type; };

Definition at line 127 of file SystemCall.h.

Referenced by ConnectableSocket::read(), and ConnectableSocket::write().

#define THROW_FORMATTED_ERROR CODE,
NOTE   ) 
 

Value:

{ \
        std::ostringstream stream; \
        stream << NetworkException::getErrorSymbol(NetworkException::system_call_failure) \
                   << ": " << NOTE << " [" << __FILE__ << ':' << __LINE__ << "]" << std::ends; \
        throw NetworkException(NetworkException::system_call_failure,stream.str().c_str(),CODE ); \
}

Definition at line 160 of file SystemCall.h.


Generated on Tue Mar 28 09:10:15 2006 for Simple SOAP by  doxygen 1.4.6