Extension: Json and NetCDF utilities
#include "dg/file/file.h"
Loading...
Searching...
No Matches
Convert to Json
Collaboration diagram for Convert to Json:

Functions

JsonType dg::file::file2Json (std::string filename, enum comments comm=file::comments::are_discarded, enum error err=file::error::is_throw)
 Convenience wrapper to open a file and parse it into a JsonType.
 
void dg::file::file2Json (std::string filename, JsonType &js, enum comments comm=file::comments::are_discarded, enum error err=file::error::is_throw)
 Same as js = dg::file::file2Json( filename, comm, err)
 
JsonType dg::file::string2Json (std::string input, enum comments comm=file::comments::are_discarded, enum error err=file::error::is_throw)
 Convenience wrapper to parse a string into a JsonType.
 
void dg::file::string2Json (std::string input, JsonType &js, enum comments comm=file::comments::are_discarded, enum error err=file::error::is_throw)
 Same as js = string2Json( input, comm, err)
 
template<class ContainerType >
dg::file::JsonType dg::file::vec2json (const ContainerType &shared)
 convert a vector to a json arrray
 
template<class T >
dg::file::JsonType dg::file::vec2json (std::initializer_list< T > shared)
 Specialization for intitializer list.
 

Detailed Description

Function Documentation

◆ file2Json() [1/2]

JsonType dg::file::file2Json ( std::string filename,
enum comments comm = file::comments::are_discarded,
enum error err = file::error::is_throw )
inline

Convenience wrapper to open a file and parse it into a JsonType.

Note
included in json_utilities.h
Parameters
filenameName of the JSON file to parse (the file path is relative to where the calling program is executed)
commdetermines the handling of comments in the Json file
errdetermines how parser errors are handled by the function error::is_throw: throw a std::runtime_error containing an error message on any error that occurs on parsing; error::is_warning: write the error message to std::cerr and return; error::is_silent: silently return
Returns
js object with all the found variables in filename

◆ file2Json() [2/2]

void dg::file::file2Json ( std::string filename,
JsonType & js,
enum comments comm = file::comments::are_discarded,
enum error err = file::error::is_throw )
inline

Same as js = dg::file::file2Json( filename, comm, err)

Here is the call graph for this function:

◆ string2Json() [1/2]

JsonType dg::file::string2Json ( std::string input,
enum comments comm = file::comments::are_discarded,
enum error err = file::error::is_throw )
inline

Convenience wrapper to parse a string into a JsonType.

Parse a string into a Json Value

Attention
This function will throw a std::runtime_error with the Json error string on any error that occurs on parsing.
Note
included in json_utilities.h
Parameters
inputThe string to interpret as a Json string
commdetermines the handling of comments in the Json string
errdetermines how parser errors are handled by the function error::is_throw: throw a std::runtime_error containing an error message on any error that occurs on parsing; error::is_warning: write the error message to std::cerr and return; error::is_silent: silently return
Returns
json object with all the found Json variables in input

◆ string2Json() [2/2]

void dg::file::string2Json ( std::string input,
JsonType & js,
enum comments comm = file::comments::are_discarded,
enum error err = file::error::is_throw )
inline

Same as js = string2Json( input, comm, err)

Here is the call graph for this function:

◆ vec2json() [1/2]

template<class ContainerType >
dg::file::JsonType dg::file::vec2json ( const ContainerType & shared)

convert a vector to a json arrray

Parameters
sharedAny shared memory container that allows range based for loops

◆ vec2json() [2/2]

template<class T >
dg::file::JsonType dg::file::vec2json ( std::initializer_list< T > shared)

Specialization for intitializer list.

Here is the call graph for this function: