token_rule.hpp 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/http_proto
  8. //
  9. #ifndef BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
  10. #define BOOST_URL_IMPL_GRAMMAR_TOKEN_RULE_HPP
  11. #include <boost/url/grammar/error.hpp>
  12. namespace boost {
  13. namespace urls {
  14. namespace grammar {
  15. template<class CharSet>
  16. auto
  17. token_rule_t<CharSet>::
  18. parse(
  19. char const*& it,
  20. char const* end
  21. ) const noexcept ->
  22. system::result<value_type>
  23. {
  24. auto const it0 = it;
  25. if(it == end)
  26. {
  27. BOOST_URL_RETURN_EC(
  28. error::need_more);
  29. }
  30. it = (find_if_not)(it, end, cs_);
  31. if(it != it0)
  32. return core::string_view(it0, it - it0);
  33. BOOST_URL_RETURN_EC(
  34. error::mismatch);
  35. }
  36. } // grammar
  37. } // urls
  38. } // boost
  39. #endif