Common#

Here shows some common classes and enumerations in this library.

Exceptions#

This library has following exception types:

URIs#

URIs can be processed using msgpack_rpc::addresses::URI.

APIs of Common#

class MsgpackRPCException : public std::runtime_error#

Class of exceptions in cpp-msgpack-rpc library.

Public Functions

MsgpackRPCException(const MsgpackRPCException&) noexcept#

Copy constructor.

MsgpackRPCException(MsgpackRPCException&&) noexcept#

Move constructor.

explicit MsgpackRPCException(Status status)#

Constructor.

Parameters:

status[in] Status.

MsgpackRPCException(StatusCode code, std::string_view message)#

Constructor.

Parameters:
  • code[in] Status code.

  • message[in] Error message.

~MsgpackRPCException() override#

Destructor.

MsgpackRPCException &operator=(const MsgpackRPCException&) noexcept#

Copy assignment operator.

Returns:

This.

MsgpackRPCException &operator=(MsgpackRPCException&&) noexcept#

Move assignment operator.

Returns:

This.

const Status &status() const noexcept#

Get the status.

Returns:

Status.

class Status#

Class of statuses.

Public Functions

Status() noexcept#

Constructor. (Set to success.)

Status(const Status&) noexcept#

Copy constructor.

Status(Status&&) noexcept#

Move constructor.

Status(StatusCode code, std::string_view message)#

Constructor.

Parameters:
  • code[in] Status code.

  • message[in] Error message.

~Status() noexcept#

Destructor.

StatusCode code() const noexcept#

Get the status code.

Returns:

Status code.

std::string_view message() const noexcept#

Get the error message.

Note

This returns empty message when this status is not an error.

Returns:

Error message.

Status &operator=(const Status&) noexcept#

Copy assignment operator.

Returns:

This.

Status &operator=(Status&&) noexcept#

Move assignment operator.

Returns:

This.

struct Data#

Internal data.

Public Members

StatusCode code#

Status code.

std::string message#

Error message.

Public Static Functions

static inline std::shared_ptr<Data> create(StatusCode code, std::string_view message)#

Create data.

Parameters:
  • code[in] Status code.

  • message[in] Error message.

Returns:

Data.

enum class msgpack_rpc::common::StatusCode : std::uint8_t#

Enumeration of status codes.

Values:

enumerator SUCCESS#

Success.

enumerator INVALID_ARGUMENT#

Invalid arguments in functions.

enumerator INVALID_MESSAGE#

Failure in parsing a message.

enumerator TYPE_ERROR#

Invalid types in a message.

enumerator PRECONDITION_NOT_MET#

Pre-condition for a process is not met.

enumerator OPERATION_ABORTED#

Operation was aborted by user.

enumerator OPERATION_FAILURE#

Operation failed. (Mainly for OS calls.)

enumerator HOST_UNRESOLVED#

Failure in resolving a host.

enumerator CONNECTION_FAILURE#

Failure in connecting to an endpoint.

enumerator TIMEOUT#

Timeout.

enumerator SERVER_ERROR#

Error in servers.

enumerator UNEXPECTED_ERROR#

Unexpected errors. (Maybe a bug.)

class URI#

Class of URIs (Uniform Resource Identifiers) to specify endpoints in this library.

Public Functions

URI(std::string_view scheme, std::string_view host_or_path, std::optional<std::uint16_t> port_number = std::optional<std::uint16_t>())#

Constructor.

Note

For protocols without port numbers, port_number can be omitted.

Parameters:
  • scheme[in] Scheme.

  • host_or_path[in] Host name or file path.

  • port_number[in] Port number.

std::string_view host_or_path() const noexcept#

Get the host name or file path.

Returns:

Host name or file path.

bool operator!=(const URI &right) const#

Compare with a URI.

Parameters:

right[in] Right-hand-side address.

Return values:
  • true – Two URIs are different.

  • false – Two URIs are same.

bool operator==(const URI &right) const#

Compare with a URI.

Parameters:

right[in] Right-hand-side address.

Return values:
  • true – Two URIs are same.

  • false – Two URIs are different.

std::optional<std::uint16_t> port_number() const noexcept#

Get the port number.

Returns:

Port number.

std::string_view scheme() const noexcept#

Get the scheme.

Returns:

Scheme.

Public Static Functions

static URI parse(std::string_view uri_string)#

Parse a string to create a URI.

Parameters:

uri_string[in] String to specify a URI.

Returns:

URI.