Bayeux  3.4.1
Core Foundation library for SuperNEMO
Macros
command_macros.h File Reference
#include <sstream>
#include <datatools/command_utils.h>

Go to the source code of this file.

Macros

#define DT_COMMAND_RETURNED_ERROR(ReturnedInfo, ErrorCode, ErrorMessage)
 
#define DT_COMMAND_RETURNED_SUCCESS(ReturnedInfo, OutputMessage)
 

Macro Definition Documentation

◆ DT_COMMAND_RETURNED_ERROR

#define DT_COMMAND_RETURNED_ERROR (   ReturnedInfo,
  ErrorCode,
  ErrorMessage 
)
Value:
{ \
std::ostringstream s; \
s << "[" << BOOST_CURRENT_FUNCTION << ":" << __LINE__ << ": " << ErrorMessage << "]"; \
ReturnedInfo.set_failure(ErrorCode, s.str()); \
} \

Build a command::returned_info object with proper error code and comprehensive message.

This macro is intended to simplify the common use case of initializing command::returned_info objects when some error is detected. This macro takes three arguments as follows

Parameters
ReturnedInfoThe command::returned_info target object
ErrorCodeThe error code (as a command::error_code_type value)
ErrorMessageMessage to supply to the command::returned_info object, this must take the form of a string or output stream sequence

In the simplest case it may be used as

command::returned_error cri;
DT_COMMAND_RETURNED_ERROR(cri, command::CEC_FAILURE, "parameter i is negative!");

If Message is composed from several streamable objects, it can be composed using the streaming operator:

command::returned_error cri;
DT_COMMAND_RETURNED_ERROR(cri, command::CEC_FAILURE, "Operation '" << "compute" << "' failed!");

◆ DT_COMMAND_RETURNED_SUCCESS

#define DT_COMMAND_RETURNED_SUCCESS (   ReturnedInfo,
  OutputMessage 
)
Value:
{ \
std::ostringstream s; \
s << OutputMessage; \
ReturnedInfo.set_success(s.str()); \
} \

Build a command::returned_info object with proper output message.

This macro is intended to simplify the common use case of initializing command::returned_info objects when no error is detected. This macro takes two arguments as follows

Parameters
ReturnedInfoThe command::returned_info target object
OutputMessageOuptut to supply to the command::returned_info object, this must take the form of a string or output stream sequence

In the simplest case it may be used as

command::returned_error cri;
DT_COMMAND_RETURNED_SUCCESS(cri, "this command was successful!");

If Message is composed from several streamable objects, it can be composed using the streaming operator:

command::returned_error cri;
DT_COMMAND_RETURNED_SUCCESS(cri, "Operation '" << "compute" << "' was successful!");