DAW JSON Link
daw_json_parse_policy_policy_details.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::parse_policy_details {
14  template<char... keys>
15  [[nodiscard]] DAW_ATTRIBUTE_FLATTEN inline constexpr bool in( char c ) {
16  auto const eq = [c]( char k ) { return c == k; };
17  return ( eq( keys ) | ... );
18  }
19 
20  [[nodiscard]] DAW_ATTRIBUTE_FLATTEN inline constexpr bool
21  at_end_of_item( char c ) {
22  return static_cast<bool>(
23  static_cast<unsigned>( c == ',' ) | static_cast<unsigned>( c == '}' ) |
24  static_cast<unsigned>( c == ']' ) | static_cast<unsigned>( c == ':' ) |
25  static_cast<unsigned>( c <= 0x20 ) );
26  }
27 
28  [[nodiscard]] DAW_ATTRIBUTE_FLATTEN inline constexpr bool
29  is_number( char c ) {
30  return static_cast<unsigned>( static_cast<unsigned char>( c ) -
31  static_cast<unsigned char>( '0' ) ) < 10U;
32  }
33 
34  [[nodiscard]] DAW_ATTRIBUTE_FLATTEN inline constexpr bool
35  is_number_start( char c ) {
36  switch( c ) {
37  case '0':
38  case '1':
39  case '2':
40  case '3':
41  case '4':
42  case '5':
43  case '6':
44  case '7':
45  case '8':
46  case '9':
47  case '-':
48  return true;
49  }
50  return false;
51  }
52 } // namespace daw::json::parse_policy_details
daw::json::parse_utils::is_number
constexpr bool is_number(char c)
Definition: daw_json_parse_iso8601_utils.h:45