lexing.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef CRASHPAD_UTIL_MISC_LEXING_H_
  15. #define CRASHPAD_UTIL_MISC_LEXING_H_
  16. namespace crashpad {
  17. //! \brief Match a pattern at the start of a char string.
  18. //!
  19. //! \param[in,out] input A pointer to the char string to match against. \a input
  20. //! is advanced past the matched pattern if it is found.
  21. //! \param[in] pattern The pattern to match at the start of \a input.
  22. //! \return `true` if the pattern is matched exactly and \a input is advanced,
  23. //! otherwise `false`.
  24. bool AdvancePastPrefix(const char** input, const char* pattern);
  25. //! \brief Convert a prefix of a char string to a numeric value.
  26. //!
  27. //! Valid values are positive or negative decimal numbers, matching the regular
  28. //! expression "-?\d+", and within the limits of T.
  29. //!
  30. //! \param[in,out] input A pointer to the char string to match against. \a input
  31. //! is advanced past the number if one is found.
  32. //! \param[out] value The converted number, if one is found.
  33. //! \return `true` if a number is found at the start of \a input and \a input is
  34. //! advanced, otherwise `false`.
  35. template <typename T>
  36. bool AdvancePastNumber(const char** input, T* value);
  37. } // namespace crashpad
  38. #endif // CRASHPAD_UTIL_MISC_LEXING_H