LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
JsonHandler Class Reference

A simple wrapper around JSON file reading and writing functionality. More...

#include <jsonhandler.h>

Public Member Functions

 JsonHandler (const std::string file)
 
Json::Value Read () const
 
void Write (const Json::Value &data) const
 
void SetFile (const std::string file)
 Set the filename to file.
 
std::string File () const
 Get the filename.
 

Detailed Description

A simple wrapper around JSON file reading and writing functionality.

Acts to simplify JSON file reading and writing tasks

Constructor & Destructor Documentation

JsonHandler::JsonHandler ( const std::string  file)

Construct the JsonHandler and give it a filename to work with if the filename doesn't end in .json it will be assumed a config json file exists under the same path & name with the .json extension

Parameters
fileThe filename the JsonHandler is to read/write too

Member Function Documentation

Json::Value JsonHandler::Read ( ) const

Read JSON formatted data from mFile and return it

Returns
the Json::Value containing the file data
Exceptions
runtime_errorFile to find if file not found
runtime_errorFailed to parse if file couldn't be parsed as JSON
void JsonHandler::Write ( const Json::Value data) const

Write data from a Json::Value to a JSON formatted file named mFile

Parameters
dataThe Json::Value of data to write

The documentation for this class was generated from the following files: