hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
executor_common.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_AMETSUCHI_EXECUTOR_COMMON_HPP
7 #define IROHA_AMETSUCHI_EXECUTOR_COMMON_HPP
8 
10 
11 #include <algorithm>
12 #include <array>
13 
14 namespace iroha::ametsuchi {
15 
16  extern const std::string kRootRolePermStr;
17 
18  std::string_view getDomainFromName(std::string_view account_id);
19 
20  std::vector<std::string_view> splitId(std::string_view id);
21 
22  std::vector<std::string_view> split(std::string_view str,
23  std::string_view delims);
24 
25  template <size_t C>
26  std::array<std::string_view, C> staticSplitId(
27  std::string_view const str, std::string_view const delims = "@#") {
28  std::array<std::string_view, C> output;
29 
30  auto it_first = str.data();
31  auto it_second = str.data();
32  auto it_end = str.data() + str.size();
33  size_t counter = 0;
34 
35  while (it_first != it_end && counter < C) {
36  it_second = std::find_first_of(
37  it_first, it_end, std::cbegin(delims), std::cend(delims));
38 
39  output[counter++] = std::string_view(it_first, it_second - it_first);
40  it_first = it_second != it_end ? it_second + 1ull : it_end;
41  }
42  return output;
43  }
44 
45 } // namespace iroha::ametsuchi
46 
47 #endif // IROHA_AMETSUCHI_EXECUTOR_COMMON_HPP
Definition: block_query.hpp:17
std::array< std::string_view, C > staticSplitId(std::string_view const str, std::string_view const delims="@#")
Definition: executor_common.hpp:26
std::string_view getDomainFromName(std::string_view account_id)
Definition: executor_common.cpp:20
std::vector< std::string_view > splitId(std::string_view id)
Definition: executor_common.cpp:25
std::vector< std::string_view > split(std::string_view str, std::string_view delims)
Definition: executor_common.cpp:29
const std::string kRootRolePermStr
Definition: executor_common.cpp:15