TrueReality  v0.1.1912
File.h
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 3.0 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * @author Maxim Serebrennik
20 */
21 
22 #pragma once
23 
24 #include <trUtil/Export.h>
25 
26 #include <trUtil/JSON/Base.h>
27 #include <trUtil/JSON/Value.h>
28 
29 #include <string>
30 
36 namespace trUtil::JSON
37 {
46  {
47  public:
48 
50  const static std::string DEFAULT_JSON_FILE_NAME;
51 
57  File();
58 
67  File(std::string fileName);
68 
74  ~File();
75 
85  virtual bool ReadFromFile(std::string fileName);
86 
95  virtual bool ReadFromFile();
96 
106  virtual bool WriteToFile(std::string fileName);
107 
116  virtual bool WriteToFile();
117 
125  virtual void SetFileName(std::string fileName);
126 
134  virtual std::string GetFileName() const;
135 
144  virtual void SetFilePath(std::string newPath);
145 
153  virtual std::string GetFilePath() const;
154 
162  virtual bool FileExists();
163 
169  void Clear() override;
170 
178  virtual Value& GetJSONRoot() override;
179 
185  virtual void PrintJSONRoot() override;
186 
196  virtual bool KeyPresent(const std::string &key) const override;
197 
207  virtual bool IsNull(const std::string &key) const override;
208 
216  virtual void SetNull(const std::string &key) override;
217 
227  virtual bool IsBool(const std::string &key) const override;
228 
238  virtual bool GetBool(const std::string &key) const override;
239 
248  virtual void SetBool(const std::string &key, const bool &value) override;
249 
259  virtual bool IsTrue(const std::string &key) const override;
260 
270  virtual bool IsFalse(const std::string &key) const override;
271 
281  virtual bool IsNumber(const std::string &key) const override;
282 
292  virtual bool IsInt(const std::string &key) const override;
293 
303  virtual int GetInt(const std::string &key) const override;
304 
313  virtual void SetInt(const std::string &key, const int &value) override;
314 
324  virtual bool IsDouble(const std::string &key) const override;
325 
335  virtual double GetDouble(const std::string &key) const override;
336 
345  virtual void SetDouble(const std::string &key, const double &value) override;
346 
356  virtual bool IsUInt(const std::string &key) const override;
357 
367  virtual unsigned int GetUInt(const std::string &key) const override;
368 
377  virtual void SetUInt(const std::string &key, const unsigned int &value) override;
378 
388  virtual bool IsInt64(const std::string &key) const override;
389 
399  virtual Int64 GetInt64(const std::string &key) const override;
400 
409  virtual void SetInt64(const std::string &key, const Int64 &value) override;
410 
420  virtual bool IsUInt64(const std::string &key) const override;
421 
431  virtual UInt64 GetUInt64(const std::string &key) const override;
432 
441  virtual void SetUInt64(const std::string &key, const UInt64 &value) override;
442 
452  virtual bool IsFloat(const std::string &key) const override;
453 
463  virtual float GetFloat(const std::string &key) const override;
464 
473  virtual void SetFloat(const std::string &key, const float &value) override;
474 
484  virtual bool IsString(const std::string &key) const override;
485 
495  virtual const std::string GetString(const std::string &key) const override;
496 
505  virtual void SetString(const std::string &key, const std::string &value) override;
506 
516  virtual bool IsArray(const std::string &key) const override;
517 
527  virtual Array GetArray(const std::string &key) const override;
528 
537  virtual void SetArray(const std::string &key, Array &value) override;
538 
548  virtual bool IsObject(const std::string &key) const override;
549 
559  virtual Object GetObject(const std::string &key) const override;
560 
569  virtual void SetObject(const std::string &key, Object &value) override;
570 
571  private:
573  std::string mFileName;
575  std::string mFilePath;
576 
579  };
580 }
A file.
Definition: File.h:45
A JSON array.
Definition: Array.h:46
std::string mFileName
Filename of the file.
Definition: File.h:573
Represents a JSON value.
Definition: Value.h:139
The Base class for all the JSON classes.
int64_t Int64
The fourth int 6.
Definition: Value.h:72
Forward declaration.
Definition: Object.h:46
static const std::string DEFAULT_JSON_FILE_NAME
The default JSON file name.
Definition: File.h:50
Value mRoot
The root.
Definition: File.h:578
A class that represents date time utility.
std::string mFilePath
Full pathname of the file.
Definition: File.h:575
uint64_t UInt64
The fourth u int 6.
Definition: Value.h:74