uzuki2
Recovering R lists faithfully from HDF5 or JSON
Loading...
Searching...
No Matches
uzuki2::json Namespace Reference

Parse an R list from a JSON file. More...

Classes

struct  Options
 Options for JSON file parsing. More...
 

Functions

template<class Provisioner_ , class Externals_ >
ParsedList parse (byteme::Reader &reader, Externals_ ext, const Options &options)
 
template<class Provisioner_ , class Externals_ >
ParsedList parse_file (const std::string &file, Externals_ ext, const Options &options)
 
template<class Provisioner_ , class Externals_ >
ParsedList parse_buffer (const unsigned char *buffer, size_t len, Externals_ ext, const Options &options)
 
void validate (byteme::Reader &reader, int num_external, const Options &options)
 
void validate_file (const std::string &file, int num_external, const Options &options)
 
void validate_buffer (const unsigned char *buffer, size_t len, int num_external, const Options &options)
 

Detailed Description

Parse an R list from a JSON file.

JSON provides an alternative to the HDF5 format handled by hdf5::parse() and friends. JSON is simpler to parse and has less formatting-related overhead. However, it does not support random access and discards some precision for floating-point numbers.

Function Documentation

◆ parse()

template<class Provisioner_ , class Externals_ >
ParsedList uzuki2::json::parse ( byteme::Reader & reader,
Externals_ ext,
const Options & options )

Parse JSON file contents using the uzuki2 specification, given an arbitrary input source of bytes.

Template Parameters
Provisioner_A class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
Externals_Class describing how to resolve external references for type EXTERNAL. See hdf5::parse() for more details.
Parameters
readerSource of input bytes representing the contents of the JSON file.
extInstance of an external reference resolver class.
optionsOptions for parsing.
Returns
A ParsedList containing a pointer to the root Base object. Depending on Provisioner_, this may contain references to all nested objects.

Any invalid representations in reader will cause an error to be thrown.

◆ parse_buffer()

template<class Provisioner_ , class Externals_ >
ParsedList uzuki2::json::parse_buffer ( const unsigned char * buffer,
size_t len,
Externals_ ext,
const Options & options )

Parse a buffer containing JSON file contents using the uzuki2 specification.

Template Parameters
Provisioner_A class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
Externals_Class describing how to resolve external references for type EXTERNAL. See hdf5::parse() for more details.
Parameters
[in]bufferPointer to an array containing the JSON file contents (possibly Gzip/Zlib-compressed).
lenLength of the buffer in bytes.
extInstance of an external reference resolver class.
optionsOptions for parsing.
Returns
A ParsedList containing a pointer to the root Base object. Depending on Provisioner_, this may contain references to all nested objects.

Any invalid representations in reader will cause an error to be thrown.

◆ parse_file()

template<class Provisioner_ , class Externals_ >
ParsedList uzuki2::json::parse_file ( const std::string & file,
Externals_ ext,
const Options & options )

Parse JSON file contents using the uzuki2 specification, given the file path.

Template Parameters
Provisioner_A class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
Externals_Class describing how to resolve external references for type EXTERNAL. See hdf5::parse() for more details.
Parameters
filePath to a (possibly Gzip-compressed) JSON file.
extInstance of an external reference resolver class.
optionsOptions for parsing.
Returns
A ParsedList containing a pointer to the root Base object. Depending on Provisioner_, this may contain references to all nested objects.

Any invalid representations in reader will cause an error to be thrown.

◆ validate()

void uzuki2::json::validate ( byteme::Reader & reader,
int num_external,
const Options & options )
inline

Validate JSON file contents against the uzuki2 specification, given a source of bytes. Any invalid representations will cause an error to be thrown.

Parameters
readerInstance of a byteme::Reader providing the contents of the JSON file.
num_externalExpected number of external references.
optionsOptions for parsing.

◆ validate_buffer()

void uzuki2::json::validate_buffer ( const unsigned char * buffer,
size_t len,
int num_external,
const Options & options )
inline

Validate JSON file contents against the uzuki2 specification, given a buffer containing the file contents. Any invalid representations will cause an error to be thrown.

Parameters
[in]bufferPointer to an array containing the JSON file contents (possibly Gzip/Zlib-compressed).
lenLength of the buffer in bytes.
num_externalExpected number of external references.
optionsOptions for parsing.

◆ validate_file()

void uzuki2::json::validate_file ( const std::string & file,
int num_external,
const Options & options )
inline

Validate JSON file contents against the uzuki2 specification, given a path to the file. Any invalid representations will cause an error to be thrown.

Parameters
filePath to a (possible Gzip-compressed) JSON file.
num_externalExpected number of external references.
optionsOptions for parsing.