error.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  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/url
  8. //
  9. #ifndef BOOST_URL_GRAMMAR_ERROR_HPP
  10. #define BOOST_URL_GRAMMAR_ERROR_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. namespace boost {
  14. namespace urls {
  15. namespace grammar {
  16. /** Error codes returned when using rules
  17. @see
  18. @ref condition,
  19. @ref parse.
  20. */
  21. enum class error
  22. {
  23. // VFALCO 3 space indent or
  24. // else Doxygen malfunctions
  25. //
  26. // (informational)
  27. //
  28. /**
  29. * More input is needed to match the rule
  30. *
  31. * A rule reached the end of the input,
  32. * resulting in a partial match. The error
  33. * is recoverable; the caller may obtain
  34. * more input if possible and attempt to
  35. * parse the character buffer again.
  36. * Custom rules should only return this
  37. * error if it is completely unambiguous
  38. * that the rule cannot be matched without
  39. * more input.
  40. */
  41. need_more = 1,
  42. /**
  43. * The rule did not match the input.
  44. *
  45. * This error is returned when a rule fails
  46. * to match the input. The error is recoverable;
  47. * the caller may rewind the input pointer and
  48. * attempt to parse again using a different rule.
  49. */
  50. mismatch,
  51. /**
  52. * A rule reached the end of a range
  53. *
  54. * This indicates that the input was consumed
  55. * when parsing a @ref range. The @ref range_rule
  56. * avoids rewinding the input buffer when
  57. * this error is returned. Thus the consumed
  58. * characters are be considered part of the
  59. * range without contributing additional
  60. * elements.
  61. */
  62. end_of_range,
  63. /**
  64. * Leftover input remaining after match.
  65. */
  66. leftover,
  67. //--------------------------------------------
  68. //
  69. // condition::fatal
  70. //
  71. //--------------------------------------------
  72. /**
  73. * A rule encountered unrecoverable invalid input.
  74. *
  75. * This error is returned when input is matching
  76. * but one of the requirements is violated. For
  77. * example if a percent escape is found, but
  78. * one or both characters that follow are not
  79. * valid hexadecimal digits. This is usually an
  80. * unrecoverable error.
  81. */
  82. invalid,
  83. /** An integer overflowed during parsing.
  84. */
  85. out_of_range,
  86. /**
  87. * An unspecified syntax error was found.
  88. */
  89. syntax
  90. };
  91. //------------------------------------------------
  92. /** Error conditions for errors received from rules
  93. @see
  94. @ref error,
  95. @ref parse.
  96. */
  97. enum class condition
  98. {
  99. /**
  100. * A fatal error in syntax was encountered.
  101. This indicates that parsing cannot continue.
  102. */
  103. fatal = 1
  104. };
  105. } // grammar
  106. } // urls
  107. } // boost
  108. #include <boost/url/grammar/impl/error.hpp>
  109. #endif