hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
query_error_response_visitor.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_QUERY_ERROR_RESPONSE_VISITOR_HPP
7 #define IROHA_QUERY_ERROR_RESPONSE_VISITOR_HPP
8 
9 #include <boost/variant.hpp>
10 #include "common/visitor.hpp"
12 
13 namespace shared_model {
14  namespace interface {
15  template <typename Error>
16  class QueryErrorResponseChecker : public boost::static_visitor<bool> {
17  public:
18  bool operator()(
19  const shared_model::interface::ErrorQueryResponse &status) const {
20  return iroha::visit_in_place(status.get(),
21  [](const Error &) { return true; },
22  [](const auto &) { return false; });
23  }
24 
25  template <typename T>
26  bool operator()(const T &) const {
27  return false;
28  }
29  };
30 
31  template <typename Error, typename QueryVariant>
32  bool checkForQueryError(QueryVariant &&query) {
33  return boost::apply_visitor(
35  std::forward<QueryVariant>(query));
36  }
37  } // namespace interface
38 } // namespace shared_model
39 
40 #endif // IROHA_QUERY_ERROR_RESPONSE_VISITOR_HPP
virtual const QueryErrorResponseVariantType & get() const =0
Definition: error_query_response.hpp:29
bool operator()(const T &) const
Definition: query_error_response_visitor.hpp:26
Definition: query_error_response_visitor.hpp:16
bool checkForQueryError(QueryVariant &&query)
Definition: query_error_response_visitor.hpp:32
bool operator()(const shared_model::interface::ErrorQueryResponse &status) const
Definition: query_error_response_visitor.hpp:18
Definition: command_executor.hpp:12