//===-- String to integer conversion utils ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H #define LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H #include "src/__support/CPP/limits.h" #include "src/__support/CPP/type_traits.h" #include "src/__support/common.h" #include "src/__support/ctype_utils.h" #include "src/__support/macros/config.h" #include "src/__support/str_to_num_result.h" #include "src/__support/uint128.h" #include "src/errno/libc_errno.h" // For ERANGE namespace LIBC_NAMESPACE_DECL { namespace internal { // Returns a pointer to the first character in src that is not a whitespace // character (as determined by isspace()) // TODO: Change from returning a pointer to returning a length. LIBC_INLINE const char * first_non_whitespace(const char *__restrict src, size_t src_len = cpp::numeric_limits<size_t>::max()) { … } LIBC_INLINE int b36_char_to_int(char input) { … } // checks if the next 3 characters of the string pointer are the start of a // hexadecimal number. Does not advance the string pointer. LIBC_INLINE bool is_hex_start(const char *__restrict src, size_t src_len = cpp::numeric_limits<size_t>::max()) { … } // Takes the address of the string pointer and parses the base from the start of // it. LIBC_INLINE int infer_base(const char *__restrict src, size_t src_len) { … } // Takes a pointer to a string and the base to convert to. This function is used // as the backend for all of the string to int functions. template <class T> LIBC_INLINE StrToNumResult<T> strtointeger(const char *__restrict src, int base, const size_t src_len = cpp::numeric_limits<size_t>::max()) { … } } // namespace internal } // namespace LIBC_NAMESPACE_DECL #endif // LLVM_LIBC_SRC___SUPPORT_STR_TO_INTEGER_H