00001 #ifndef __BOOST_RPC_MESSAGE_HPP_
00002 #define __BOOST_RPC_MESSAGE_HPP_
00003 #include <boost/reflect/reflect.hpp>
00004 #include <boost/rpc/varint.hpp>
00005 #include <boost/rpc/required.hpp>
00006 #include <boost/optional.hpp>
00007
00008 namespace boost { namespace rpc {
00009
00010 using boost::optional;
00011
00015 struct error_object : public virtual boost::exception, public virtual std::exception
00016 {
00017 error_object( int32_t c = 0 )
00018 :code(c){}
00019
00020 error_object( int32_t c, const std::string& msg )
00021 :code(c),message(msg){}
00022
00023 ~error_object() throw() {}
00024
00025 required<signed_int> code;
00026 optional<std::string> message;
00027 optional<std::string> data;
00028
00029 const char* what()const throw() { return message ? (*message).c_str() : "error object"; }
00030 virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); }
00031 };
00032
00038 struct message
00039 {
00040 message(){}
00041 message( const std::string& name )
00042 :method(name){}
00043
00044 message( const std::string& name, const std::string& param )
00045 :method(name),params(param){}
00046
00047 optional<signed_int> id;
00048 optional<signed_int> method_id;
00049 optional<std::string> method;
00050 optional<std::string> params;
00051 optional<std::string> result;
00052 optional<error_object> error;
00053 };
00054
00055
00056 } }
00057
00058 BOOST_REFLECT( boost::rpc::error_object, (code)(message)(data) )
00059 BOOST_REFLECT( boost::rpc::message, (id)(method_id)(method)(params)(result)(error) )
00060
00061 #endif // __BOOST_RPC_MESSAGE_HPP_
00062