DAW JSON Link
daw_json_parse_digit.h
Go to the documentation of this file.
1 // Copyright (c) Darrell Wright
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5 //
6 // Official repository: https://github.com/beached/daw_json_link
7 //
8 
9 #pragma once
10 
11 #include <daw/daw_hide.h>
12 
13 namespace daw::json::json_details {
14 
15  DAW_ATTRIBUTE_FLATTEN [[nodiscard]] static inline constexpr unsigned
16  parse_digit( char c ) {
17  return static_cast<unsigned>( static_cast<unsigned char>(
18  static_cast<unsigned char>( c ) - static_cast<unsigned char>( '0' ) ) );
19  }
20 
21  namespace parsed_constants {
22  static inline constexpr unsigned decimal_char = parse_digit( '.' );
23  static inline constexpr unsigned e_char = parse_digit( 'e' );
24  static inline constexpr unsigned E_char = parse_digit( 'E' );
25  static inline constexpr unsigned plus_char = parse_digit( '+' );
26  static inline constexpr unsigned minus_char = parse_digit( '-' );
27  } // namespace parsed_constants
28 } // namespace daw::json::json_details