Skip to content

Commit

Permalink
Sync with Cefeika
Browse files Browse the repository at this point in the history
Expose some functions to API

to_literal(Client_errc), to_literal(Server_errc) are now exposed.
  • Loading branch information
dmitigr committed Oct 17, 2019
1 parent 9a6205e commit dc50212
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
10 changes: 2 additions & 8 deletions lib/dmitigr/pgfe/errc.cpp
Expand Up @@ -7,11 +7,8 @@

#include <dmitigr/util/debug.hpp>

namespace dmitigr::pgfe::detail {
namespace dmitigr::pgfe {

/**
* @returns The literal representation of the `errc`.
*/
DMITIGR_PGFE_INLINE const char* to_literal(const Client_errc errc)
{
switch (errc) {
Expand All @@ -31,9 +28,6 @@ DMITIGR_PGFE_INLINE const char* to_literal(const Client_errc errc)
DMITIGR_ASSERT_ALWAYS(!true);
}

/**
* @returns The literal representation of the `errc`.
*/
DMITIGR_PGFE_INLINE const char* to_literal(const Server_errc errc)
{
switch (errc) {
Expand Down Expand Up @@ -555,6 +549,6 @@ DMITIGR_PGFE_INLINE const char* to_literal(const Server_errc errc)
DMITIGR_ASSERT_ALWAYS(!true);
}

} // namespace dmitigr::pgfe::detail
} // namespace dmitigr::pgfe

#include "dmitigr/pgfe/implementation_footer.hpp"
12 changes: 12 additions & 0 deletions lib/dmitigr/pgfe/errc.hpp
Expand Up @@ -5,6 +5,8 @@
#ifndef DMITIGR_PGFE_ERRC_HPP
#define DMITIGR_PGFE_ERRC_HPP

#include "dmitigr/pgfe/dll.hpp"

namespace dmitigr::pgfe {

/**
Expand Down Expand Up @@ -32,6 +34,11 @@ enum class Client_errc {
timed_out = 500
};

/**
* @returns The literal representation of the `errc`.
*/
DMITIGR_PGFE_API const char* to_literal(Client_errc errc);

/**
* @ingroup errors
*
Expand Down Expand Up @@ -982,6 +989,11 @@ enum class Server_errc {
cxx_index_corrupted = 56966978
};

/**
* @returns The literal representation of the `errc`.
*/
DMITIGR_PGFE_API const char* to_literal(Server_errc errc);

} // namespace dmitigr::pgfe

#ifdef DMITIGR_PGFE_HEADER_ONLY
Expand Down
5 changes: 2 additions & 3 deletions lib/dmitigr/pgfe/std_system_error.cpp
Expand Up @@ -2,7 +2,6 @@
// Copyright (C) Dmitry Igrishin
// For conditions of distribution and use, see files LICENSE.txt or pgfe.hpp

#include "dmitigr/pgfe/errc.hpp"
#include "dmitigr/pgfe/std_system_error.hpp"
#include "dmitigr/pgfe/implementation_header.hpp"

Expand All @@ -21,7 +20,7 @@ DMITIGR_PGFE_INLINE std::string Client_error_category::message(const int ev) con
result += ' ';
result += std::to_string(ev);
result += ' ';
result += detail::to_literal(Client_errc(ev));
result += to_literal(Client_errc(ev));
return result;
}

Expand All @@ -38,7 +37,7 @@ DMITIGR_PGFE_INLINE std::string Server_error_category::message(const int ev) con
result += ' ';
result += string::to_string(ev, 36);
result += ' ';
result += detail::to_literal(Server_errc(ev));
result += to_literal(Server_errc(ev));
return result;
}

Expand Down

0 comments on commit dc50212

Please sign in to comment.