DAW JSON Link
daw_json_serialize_policy_options.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
12#include "version.h"
13
14namespace daw::json {
15 inline namespace DAW_JSON_VER {
16 /***
17 * Choose whether to produce minified or pretty output
18 */
19 enum class SerializationFormat : unsigned {
20 /* Output JSON without whitespace surrounding members and values */
22 /* Output JSON with indentation and newlines */
23 Pretty
24 }; // 1bit
25
26 namespace json_details {
27 template<>
28 inline constexpr unsigned json_option_bits_width<SerializationFormat> = 1;
29
30 template<>
33 } // namespace json_details
34
35 /***
36 * When Pretty mode is enabled, choose the indentation type. Defaults to 2
37 * spaces.
38 */
39 enum class IndentationType : unsigned {
40 /* Use tabs for indentation */
41 Tab,
42 /* Use 0 spaces for indentation */
43 Space0,
44 /* Use 1 space for indentation */
45 Space1,
46 /* Use 2 spaces for indentation */
47 Space2,
48 /* Use 3 spaces for indentation */
49 Space3,
50 /* Use 4 spaces for indentation */
51 Space4,
52 /* Use 5 spaces for indentation */
53 Space5,
54 /* Use 8 spaces for indentation */
55 Space8,
56 };
57
58 namespace json_details {
59 template<>
60 inline constexpr unsigned json_option_bits_width<IndentationType> = 3;
61
62 template<>
65 } // namespace json_details
66
67 /***
68 * Allow for restricting the output of strings to 7bits
69 */
70 enum class RestrictedStringOutput : unsigned {
71 /* Do not impose any extra restrictions on string output during
72 serialization */
73 None,
74 /* Restrict all string member values and all member names to 7bits. This
75 will result in escaping all values >= 0x7FS. This can affect round
76 trips where the name contains high bits set*/
78 };
79
80 namespace json_details {
81 template<>
83 1;
84
85 template<>
88 } // namespace json_details
89
90 enum class NewLineDelimiter : unsigned { n, rn };
91
92 namespace json_details {
93 template<>
94 inline constexpr unsigned json_option_bits_width<NewLineDelimiter> = 1;
95
96 template<>
99 } // namespace json_details
100
101 enum class OutputTrailingComma : unsigned { No, Yes };
102 namespace json_details {
103 template<>
104 inline constexpr unsigned json_option_bits_width<OutputTrailingComma> = 1;
105
106 template<>
109 } // namespace json_details
110
111 } // namespace DAW_JSON_VER
112} // namespace daw::json
constexpr auto default_json_option_value< SerializationFormat >
Definition: daw_json_serialize_policy_options.h:31
constexpr auto default_json_option_value< NewLineDelimiter >
Definition: daw_json_serialize_policy_options.h:97
constexpr auto default_json_option_value< IndentationType >
Definition: daw_json_serialize_policy_options.h:63
constexpr unsigned json_option_bits_width< NewLineDelimiter >
Definition: daw_json_serialize_policy_options.h:94
constexpr auto default_json_option_value< OutputTrailingComma >
Definition: daw_json_serialize_policy_options.h:107
constexpr unsigned json_option_bits_width< OutputTrailingComma >
Definition: daw_json_serialize_policy_options.h:104
constexpr unsigned json_option_bits_width< SerializationFormat >
Definition: daw_json_serialize_policy_options.h:28
constexpr auto default_json_option_value< RestrictedStringOutput >
Definition: daw_json_serialize_policy_options.h:86
constexpr unsigned json_option_bits_width< RestrictedStringOutput >
Definition: daw_json_serialize_policy_options.h:82
constexpr unsigned json_option_bits_width< IndentationType >
Definition: daw_json_serialize_policy_options.h:60
SerializationFormat
Definition: daw_json_serialize_policy_options.h:19
NewLineDelimiter
Definition: daw_json_serialize_policy_options.h:90
OutputTrailingComma
Definition: daw_json_serialize_policy_options.h:101
IndentationType
Definition: daw_json_serialize_policy_options.h:39
RestrictedStringOutput
Definition: daw_json_serialize_policy_options.h:70
Definition: daw_from_json.h:22
#define DAW_JSON_VER
The version string used in namespace definitions. Must be a valid namespace name.
Definition: version.h:16