forked from qdrvm/kagome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstub.hpp
43 lines (34 loc) · 1.07 KB
/
stub.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef KAGOME_STUB
#define KAGOME_STUB
#include "common/empty.hpp"
#include "common/tagged.hpp"
#include <typeinfo>
namespace kagome {
namespace stub {}
/// Stub-class for unimplemented types
template <typename Tag = struct Unknown>
struct Stub final : private Tagged<Empty, Tag> {
bool operator==(const Stub &) const {
return false;
}
};
template <typename Tag>
[[noreturn]] scale::ScaleEncoderStream &operator<<(
scale::ScaleEncoderStream &s, const Stub<Tag> &data) {
throw std::runtime_error(fmt::format(
"Can not encode: encoding object is stubbed type tagged by {}",
typeid(Tag).name()));
}
template <typename Tag>
[[noreturn]] scale::ScaleDecoderStream &operator>>(
scale::ScaleDecoderStream &s, Stub<Tag> &data) {
throw std::runtime_error(fmt::format(
"Can not decode: decoding object is stubbed type tagged by {}",
typeid(Tag).name()));
}
} // namespace kagome
#endif // KAGOME_STUB