Extension: Json and NetCDF utilities
#include "dg/file/file.h"
Loading...
Searching...
No Matches
json_wrapper.h File Reference
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <stdexcept>
#include "json/json.h"
Include dependency graph for json_wrapper.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dg::file::WrappedJsonValue
 Wrapped Access to Json values with error handling. More...
 

Namespaces

namespace  dg
 
namespace  dg::file
 Namespace for Json and NetCDF I/O related classes and functions.
 

Typedefs

using dg::file::JsonType = Json::Value
 Json Type to use in dg::file functions and classes.
 

Enumerations

enum class  dg::file::error { dg::file::error::is_throw , dg::file::error::is_warning , dg::file::error::is_silent }
 Switch between how to handle errors in a Json utitlity functions. More...
 
enum class  dg::file::comments { dg::file::comments::are_kept , dg::file::comments::are_discarded , dg::file::comments::are_forbidden }
 Switch how comments are treated in a json string or file. More...
 

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.