hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
parser.hpp
Go to the documentation of this file.
1 
6 #include <algorithm>
7 #include <iterator>
8 #include <sstream>
9 #include <string>
10 #include <vector>
11 
12 #include <boost/optional.hpp>
13 
14 #ifndef IROHA_PARSER_HPP
15 #define IROHA_PARSER_HPP
16 
17 namespace parser {
18 
24  bool isIntNumber(const std::string &s);
25 
31  boost::optional<std::string> parseFirstCommand(std::string line);
32 
38  std::vector<std::string> split(std::string line);
39 
40  template <typename T>
41  boost::optional<T> parseValue(std::string word) {
42  std::stringstream ss(word);
43  if (not isIntNumber(word)) {
44  return boost::none;
45  }
46  T val;
47  if (ss >> val) {
48  return val;
49  } else {
50  return boost::none;
51  }
52  }
53 
54 } // namespace parser
55 
56 #endif // IROHA_PARSER_HPP
std::vector< std::string > split(std::string line)
Definition: parser.cpp:28
bool isIntNumber(const std::string &s)
Definition: parser.cpp:13
boost::optional< T > parseValue(std::string word)
Definition: parser.hpp:41
boost::optional< std::string > parseFirstCommand(std::string line)
Definition: parser.cpp:20
Definition: interactive_common_cli.hpp:19