PConfigurationFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2018 Digital Barriers plc. All rights reserved.
3  * Contact: http://www.digitalbarriers.com/
4  *
5  * This file is part of the Papillon SDK.
6  *
7  * You can't use, modify or distribute any part of this file without
8  * the explicit written agreements of Digital Barriers.
9  */
10 
15 #pragma once
16 #include <PObject.h>
17 #include <PString.h>
18 
19 PAPILLON_BEGIN_NAMESPACE
20 
21 class PProperties;
22 class PStringList;
23 
30 class PAPILLON_API_CORE PConfigurationFile : public PObject
31 {
32 public:
40 
45 
49  virtual ~PConfigurationFile();
50 
55 
67  PStringList GetSectionList(const PString& section = PString::Empty()) const;
68 
72  PResult RemoveSection(const PString& section);
73 
86  PResult SetProperty(const PString& path, const PString& value);
87 
100  PResult SetProperty(const PString& path, papillon::int32 value);
101 
114  PResult SetProperty(const PString& path, double value);
115 
127  PResult SetProperties(const PProperties& properties);
128 
138  PString GetProperty(const PString& path, const PString& defaultValue = PString::Empty()) const;
139 
143  bool HasProperty(const PString& path) const;
144 
153  PResult RemoveProperty(const PString& path);
154 
160  PResult Load(const PString& filename);
161 
165  PResult Reload();
166 
172  PResult Save(const PString& filename, bool bEncryptFile = false);
173 
178  static bool IsEncrypted(const PString& filename);
179  static PResult EncryptFile(const PString& fileIn, const PString& fileOut);
180  static PResult DecryptFile(const PString& fileIn, const PString& fileOut);
181 
185  PString GetFilename() const;
186 
200  PProperties ToProperties() const;
201 
205  PResult FromString(const PString& content);
206 };
207 
208 PAPILLON_END_NAMESPACE
209 
The PString class provides an Unicode character strings.
Definition: PString.h:37
The PConfigurationFile class provides a friendly interface for handling .ini configuration files...
The PResult class represents the result returned by most of Papillon functions; this class is used to...
Definition: PResult.h:159
PResult FromString(const PString &s)
Builds a PObject from a string (destringify).
The PProperties class represents a container of properties; each property has a name (PString) and a ...
Definition: PProperties.h:38
The PObject class is the root class of all Papillon classes; all PObject behaves like shared referenc...
Definition: PObject.h:27
Class PString: an unicode character strings (use copy-on-write idiom).
The PStringList class represents a list of PString; NOT thread-safe.
Definition: PStringList.h:26
static const PString & Empty()
Returns the constant holding the empty string "".
Definition: PString.h:64
Class PObject: the root class of all Papillon classes.
PObject & operator=(const PObject &obj)
Performs a shared copy of other to this object.
Definition: PObject.h:45