LCOV - code coverage report
Current view: top level - libs/parser - parser.hpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 0 7 0.0 %
Date: 2019-03-07 14:46:43 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       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             : 
      19             :   /**
      20             :    * Check if string is actually the integer number
      21             :    * @param s
      22             :    * @return
      23             :    */
      24             :   bool isIntNumber(const std::string &s);
      25             : 
      26             :   /**
      27             :    * Parse the first command in the line
      28             :    * @param line string to parse
      29             :    * @return nullopt if no command found, string otherwise
      30             :    */
      31             :   boost::optional<std::string> parseFirstCommand(std::string line);
      32             : 
      33             :   /**
      34             :    * Split line into words
      35             :    * @param line
      36             :    * @return vector with words
      37             :    */
      38             :   std::vector<std::string> split(std::string line);
      39             : 
      40             :   template <typename T>
      41             :   boost::optional<T> parseValue(std::string word) {
      42           0 :     std::stringstream ss(word);
      43           0 :     if (not isIntNumber(word)) {
      44           0 :       return boost::none;
      45             :     }
      46             :     T val;
      47           0 :     if (ss >> val) {
      48           0 :       return val;
      49             :     } else {
      50           0 :       return boost::none;
      51             :     }
      52           0 :   }
      53             : 
      54             : }  // namespace parser
      55             : 
      56             : #endif  // IROHA_PARSER_HPP

Generated by: LCOV version 1.13