nomlib
Loading...
Searching...
No Matches
JsonConfigFile.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_SERIALIZERS_JSON_CONFIG_FILE_HPP
30#define NOMLIB_SERIALIZERS_JSON_CONFIG_FILE_HPP
31
32#include <memory>
33
34#include "nomlib/config.hpp"
35#include "nomlib/serializers/IConfigFile.hpp"
36
37namespace nom {
38
39// Forward declarations
42
45{
46 public:
47 typedef JsonConfigFile self_type;
48
49 typedef self_type* raw_ptr;
50 typedef std::unique_ptr<self_type> unique_ptr;
51 typedef std::shared_ptr<self_type> shared_ptr;
52
56
59
61 bool flush( void );
62
65
68
70 bool load( void );
71
75 bool save( void );
76
77 private:
79 bool initialize( void );
80
88
96
98 std::unique_ptr<IValueDeserializer> deserializer_;
99
101 std::unique_ptr<IValueSerializer> serializer_;
102};
103
104} // namespace nom
105
106#endif // include guard defined
IConfigFile(void)
Default constructor.
Abstract interface for loading nom::Value objects.
Abstract interface for saving nom::Value objects.
bool load(void)
Re-implements IConfigFile::load.
~JsonConfigFile(void)
Destructor.
std::unique_ptr< IValueSerializer > serializer_
Object pointer to an object deriving from nom::IValueSerializer.
IValueDeserializer * deserializer(void) const
Re-implements IConfigFile::deserializer.
void set_deserializer(IValueDeserializer *fp)
Set the configuration loader.
void set_serializer(IValueSerializer *fp)
Set the configuration saver.
bool save(void)
Re-implements IConfigFile::save.
std::unique_ptr< IValueDeserializer > deserializer_
Object pointer to an object deriving from nom::IValueDeserializer.
bool initialize(void)
Internal helper method for initializing the object state.
bool flush(void)
Re-implements IConfigFile::flush.
JsonConfigFile(void)
Default constructor; initialize the loader and saver interfaces necessary for JSON I/O.
IValueSerializer * serializer(void) const
Re-implements IConfigFile::serializer.