1. /*!
    2. * \brief IsNumber check whether string is a number.
    3. * \param str input string
    4. * \return result of operation.
    5. */
    6. inline bool IsNumber(const std::string& str) {
    7. return !str.empty() && std::find_if(str.begin(),
    8. str.end(), [](char c) { return !std::isdigit(c); }) == str.end();
    9. }
    10. /*!
    11. * \brief split Split the string based on delimiter
    12. * \param str Input string
    13. * \param delim The delimiter.
    14. * \return vector of strings which are splitted.
    15. */
    16. inline std::vector<std::string> Split(const std::string& str, char delim) {
    17. std::string item;
    18. std::istringstream is(str);
    19. std::vector<std::string> ret;
    20. while (std::getline(is, item, delim)) {
    21. ret.push_back(item);
    22. }
    23. return ret;
    24. }
    25. /*!
    26. * \brief EndsWith check whether the strings ends with
    27. * \param value The full string
    28. * \param end The end substring
    29. * \return bool The result.
    30. */
    31. inline bool EndsWith(std::string const& value, std::string const& end) {
    32. if (end.size() <= value.size()) {
    33. return std::equal(end.rbegin(), end.rend(), value.rbegin());
    34. }
    35. return false;
    36. }