Skip to content

Commit c9f6355

Browse files
authored
Merge pull request #1 from soramitsu/fix/kagome-compatibility
Fix kagome compatibility
2 parents b966252 + 2d02507 commit c9f6355

11 files changed

Lines changed: 563 additions & 548 deletions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ It allows encoding and decoding following data types:
99
* bool values
1010
* pairs of types represented by ```std::pair<T1, T2>```
1111
* compact integers represented by CompactInteger type
12-
* optional values represented by ```boost::optional<T>```
13-
* as special case of optional values ```boost::optional<bool>``` is encoded using one byte following specification.
12+
* optional values represented by ```std::optional<T>```
13+
* as special case of optional values ```std::optional<bool>``` is encoded using one byte following specification.
1414
* collections of items represented by ```std::vector<T>```
1515
* variants represented by ```boost::variant<T...>```
1616

@@ -26,8 +26,8 @@ auto * raw_str = "zxczxczx";
2626
bool b = true;
2727
CompactInteger ci = 123456789;
2828
boost::variant<uint8_t, uint32_t, CompactInteger> vint = CompactInteger(12345);
29-
boost::optional<std::string> opt_str = "asdfghjkl";
30-
boost::optional<bool> opt_bool = false;
29+
std::optional<std::string> opt_str = "asdfghjkl";
30+
std::optional<bool> opt_bool = false;
3131
std::pair<uint8_t, uint32_t> pair{1u, 2u};
3232
std::vector<uint32_t> coll_ui32 = {1u, 2u, 3u, 4u};
3333
std::vector<std::string> coll_str = {"asd", "fgh", "jkl"};
@@ -58,8 +58,8 @@ std::string str;
5858
bool b = true;
5959
CompactInteger ci;
6060
boost::variant<uint8_t, uint32_t, CompactInteger> vint;
61-
boost::optional<std::string> opt_str;
62-
boost::optional<bool> opt_bool;
61+
std::optional<std::string> opt_str;
62+
std::optional<bool> opt_bool;
6363
std::pair<uint8_t, uint32_t> pair{};
6464
std::vector<uint32_t> coll_ui32;
6565
std::vector<std::string> coll_str;
File renamed without changes.

include/scale/outcome/outcome-register.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#define OUTCOME_USE_STD_IN_PLACE_TYPE 1
2323

24-
namespace __outcome_detail {
24+
namespace scale::__outcome_detail {
2525

2626
template <typename T> class Category : public std::error_category {
2727
public:
@@ -52,11 +52,11 @@ template <typename T> class Category : public std::error_category {
5252
Category() = default;
5353
}; /* end of class */
5454

55-
} // namespace __outcome_detail
55+
} // namespace scale::__outcome_detail
5656

5757
#define __OUTCOME_DEFINE_MAKE_ERROR_CODE(Enum) \
5858
extern std::error_code make_error_code(Enum e) { \
59-
return {static_cast<int>(e), __outcome_detail::Category<Enum>::get()}; \
59+
return {static_cast<int>(e), scale::__outcome_detail::Category<Enum>::get()}; \
6060
}
6161

6262
#define __OUTCOME_DECLARE_MAKE_ERROR_CODE(Enum) \
@@ -87,14 +87,14 @@ template <typename T> class Category : public std::error_category {
8787
__OUTCOME_DEFINE_MAKE_ERROR_CODE(Enum) \
8888
}; \
8989
template <> \
90-
std::string __outcome_detail::Category<ns::Enum>::toString(ns::Enum Name)
90+
std::string scale::__outcome_detail::Category<ns::Enum>::toString(ns::Enum Name)
9191

9292
/// MUST BE EXECUTED AT FILE LEVEL(global namespace) IN CPP
9393
// Enum - enum name. Example: EncodeError
9494
// Name - variable name. Example: e
9595
#define OUTCOME_CPP_DEFINE_CATEGORY_2(Enum, Name) \
9696
__OUTCOME_DEFINE_MAKE_ERROR_CODE(Enum) \
97-
template <> std::string __outcome_detail::Category<Enum>::toString(Enum Name)
97+
template <> std::string scale::__outcome_detail::Category<Enum>::toString(Enum Name)
9898

9999
// kind of "macro overloading"
100100
#define __GET_MACRO_3(_1, _2, _3, NAME, ...) NAME

include/scale/outcome/outcome.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
#include "outcome-register.hpp"
1717

18-
namespace outcome {
18+
namespace scale::outcome {
1919

2020
using namespace BOOST_OUTCOME_V2_NAMESPACE;
2121

2222
template <class R, class S = std::error_code,
2323
class NoValuePolicy = policy::default_policy<R, S, void>>
2424
using result = basic_result<R, S, NoValuePolicy>;
2525

26-
} // namespace outcome
26+
} // namespace scale::outcome
2727

2828
#define OUTCOME_TRY(...) BOOST_OUTCOME_TRY(__VA_ARGS__)
2929

include/scale/outcome/outcome_throw.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace scale {
1616
* @param t error value
1717
*/
1818
template <typename T, typename = std::enable_if_t<std::is_enum_v<T>>>
19-
[[noreturn]] void raise (T t) {
19+
[[noreturn]] void raise(T t) {
2020
std::error_code ec = make_error_code(t);
2121
boost::throw_exception(std::system_error(ec));
2222
}

0 commit comments

Comments
 (0)