Json utilities

One can easily import (resp. export) a data model from (resp. to) using the following methods, provided that the context T is described using the macro MAKE_DTO_STRUCT (see Data Model Description).

namespace json

Functions

template<typename T>
void import_from_stream(std::istream &istream, T &context)

Load a context from a stream.

Template Parameters:

T – the type of context

Parameters:
  • istream – the input stream

  • context – the context to fill

Pre:

T has been declared using MAKE_DTO_STRUCT

template<typename T>
void import_from_file(std::string const &filePath, T &context)

Load a context from a file.

Template Parameters:

T – the type of context

Parameters:
  • filePath – path to the file

  • context – the context to fill

Pre:

T has been declared using MAKE_DTO_STRUCT

template<typename T>
void export_to_stream(std::ostream &ostream, T const &context)

Export a context to a stream.

Template Parameters:

T – the type of context

Parameters:
  • ostream – the output stream

  • context – the context to export

Pre:

T has been declared using MAKE_DTO_STRUCT

template<typename T>
void export_to_file(std::string const &filePath, T const &context)

Export a context to a file.

Template Parameters:

T – the type of context

Parameters:
  • filePath – path to the file

  • context – the context to export

Pre:

T has been declared using MAKE_DTO_STRUCT