Kagome
Polkadot Runtime Engine in C++17
stub.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STUB
7 #define KAGOME_STUB
8 
9 #include "common/empty.hpp"
10 #include "common/tagged.hpp"
11 
12 #include <typeinfo>
13 
14 namespace kagome {
15  namespace stub {}
16 
18  template <typename Tag = struct Unknown>
19  struct Stub final : private Tagged<Empty, Tag> {
20  bool operator==(const Stub &) const {
21  return false;
22  }
23  };
24 
25  template <typename Tag>
26  [[noreturn]] scale::ScaleEncoderStream &operator<<(
27  scale::ScaleEncoderStream &s, const Stub<Tag> &data) {
28  throw std::runtime_error(fmt::format(
29  "Can not encode: encoding object is stubbed type tagged by {}",
30  typeid(Tag).name()));
31  }
32 
33  template <typename Tag>
34  [[noreturn]] scale::ScaleDecoderStream &operator>>(
35  scale::ScaleDecoderStream &s, Stub<Tag> &data) {
36  throw std::runtime_error(fmt::format(
37  "Can not decode: decoding object is stubbed type tagged by {}",
38  typeid(Tag).name()));
39  }
40 
41 } // namespace kagome
42 
43 #endif // KAGOME_STUB
Stub-class for unimplemented types.
Definition: stub.hpp:19
Stream & operator>>(Stream &s, Empty &)
Definition: empty.hpp:25
Stream & operator<<(Stream &s, const Empty &)
Definition: empty.hpp:20
bool operator==(const Stub &) const
Definition: stub.hpp:20