uzuki2
Recovering R lists faithfully from HDF5 or JSON
Loading...
Searching...
No Matches
Classes | Functions
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, Options options=Options())
 
template<class Provisioner >
ParsedList parse (byteme::Reader &reader, Options options=Options())
 
template<class Provisioner , class Externals >
ParsedList parse_file (const std::string &file, Externals ext, Options options=Options())
 
template<class Provisioner >
ParsedList parse_file (const std::string &file, Options options=Options())
 
template<class Provisioner , class Externals >
ParsedList parse_buffer (const unsigned char *buffer, size_t len, Externals ext, Options options=Options())
 
template<class Provisioner >
ParsedList parse_buffer (const unsigned char *buffer, size_t len, Options options=Options())
 
void validate (byteme::Reader &reader, int num_external=0, Options options=Options())
 
void validate_file (const std::string &file, int num_external=0, Options options=Options())
 
void validate_buffer (const unsigned char *buffer, size_t len, int num_external=0, Options 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() [1/2]

template<class Provisioner , class Externals >
ParsedList uzuki2::json::parse ( byteme::Reader &  reader,
Externals  ext,
Options  options = Options() 
)

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

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
ExternalsClass describing how to resolve external references for type EXTERNAL. See hdf5::parse() for more details.
Parameters
readerInstance of a byteme::Reader providing 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() [2/2]

template<class Provisioner >
ParsedList uzuki2::json::parse ( byteme::Reader &  reader,
Options  options = Options() 
)

Overload of json::parse() assuming that there are no external references.

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
Parameters
readerInstance of a byteme::Reader providing the contents of the JSON file.
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() [1/2]

ParsedList uzuki2::json::parse_buffer ( const unsigned char buffer,
size_t  len,
Externals  ext,
Options  options = Options() 
)

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

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
ExternalsClass 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_buffer() [2/2]

template<class Provisioner >
ParsedList uzuki2::json::parse_buffer ( const unsigned char buffer,
size_t  len,
Options  options = Options() 
)

Overload of json::parse_buffer() assuming that there are no external references.

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. 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.
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() [1/2]

ParsedList uzuki2::json::parse_file ( const std::string &  file,
Externals  ext,
Options  options = Options() 
)

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

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
ExternalsClass 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.

◆ parse_file() [2/2]

template<class Provisioner >
ParsedList uzuki2::json::parse_file ( const std::string &  file,
Options  options = Options() 
)

Overload of json::parse_file() assuming that there are no external references.

Template Parameters
ProvisionerA class namespace defining static methods for creating new Base objects. See hdf5::parse() for more details.
Parameters
filePath to a (possibly Gzip-compressed) JSON file.
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 = 0,
Options  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 = 0,
Options  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 = 0,
Options  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.