JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
jsonv::extract_options Class Referencefinal

Configuration for various extraction options. This becomes part of the extraction_context. More...

#include <jsonv/serialization.hpp>

Public Types

enum class  on_error { fail_immediately , collect_all }
 When an error is encountered during extraction, what should happen? More...
 
enum class  duplicate_key_action { replace , ignore , exception }
 When an object key has the same value as a previously-seen key, what should happen? More...
 
using size_type = extraction_error::problem_list::size_type
 

Public Member Functions

 extract_options () noexcept
 Create an instance with the default options.
 
on_error failure_mode () const noexcept
 
extract_optionsfailure_mode (on_error mode)
 
size_type max_failures () const
 
extract_optionsmax_failures (size_type limit)
 
duplicate_key_action on_duplicate_key () const
 
extract_optionson_duplicate_key (duplicate_key_action action)
 

Static Public Member Functions

static extract_options create_default ()
 Create a default set of options.
 

Detailed Description

Configuration for various extraction options. This becomes part of the extraction_context.

Definition at line 201 of file serialization.hpp.

Member Typedef Documentation

◆ size_type

using jsonv::extract_options::size_type = extraction_error::problem_list::size_type

Definition at line 204 of file serialization.hpp.

Member Enumeration Documentation

◆ duplicate_key_action

When an object key has the same value as a previously-seen key, what should happen?

Enumerator
replace 

Replace the previous value with the new one.

The final value of the key in the object will be the last-encountered one.

For example: { "a": 1, "a": 2, "a": 3 } will end with { "a": 3 }.

ignore 

Ignore the new values.

The final value of the key in the object will be the first-encountered one.

    For example: `{ "a": 1, "a": 2, "a": 3 }` will end with `{ "a": 1 }`. 
exception 

Repeated keys should raise an extraction_error.

Definition at line 216 of file serialization.hpp.

◆ on_error

When an error is encountered during extraction, what should happen?

Enumerator
fail_immediately 

Immediately throw an extraction_error – do not attempt to continue.

collect_all 

Attempt to continue extraction, collecting all errors and throwing at the end.

Definition at line 207 of file serialization.hpp.

Member Function Documentation

◆ failure_mode()

on_error jsonv::extract_options::failure_mode ( ) const
inlinenoexcept

See on_error. The default failure mode is fail_immediately.

Definition at line 242 of file serialization.hpp.

◆ max_failures()

size_type jsonv::extract_options::max_failures ( ) const
inline

The maximum allowed extractor failures the parser can encounter before throwing an error. This is only applicable if the failure_mode is not on_error::fail_immediately. By default, this value is 10.

You should probably not set this value to an unreasonably high number, as each error encountered must be stored in memory for some period of time.

Definition at line 252 of file serialization.hpp.

◆ on_duplicate_key()

duplicate_key_action jsonv::extract_options::on_duplicate_key ( ) const
inline

See duplicate_key_action. The default action is replace.

Definition at line 258 of file serialization.hpp.


The documentation for this class was generated from the following file: