This repository has been archived by the owner on Oct 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 539
/
CfgFile.h
70 lines (58 loc) · 2.58 KB
/
CfgFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CFGFILE_H
#define CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CFGFILE_H
#pragma once
#include "ICfgFile.h" // ICfgFile
enum EConfigPriority;
class Config;
/** Configuration file class.
Uses format similar to windows .ini files.
*/
class CfgFile
: public ICfgFile
{
public:
CfgFile();
virtual ~CfgFile();
//////////////////////////////////////////////////////////////////////////
// interface ICfgFile
virtual void Release();
virtual bool Load(const string& fileName);
virtual bool Save(void);
virtual void UpdateOrCreateEntry(const char* inszSection, const char* inszKey, const char* inszValue);
virtual void RemoveEntry(const char* inszSection, const char* inszKey);
virtual void CopySectionKeysToConfig(EConfigPriority ePri, int sectionIndex, const char* keySuffixes, IConfigSink* config) const;
virtual const char* GetSectionName(int sectionIndex) const;
virtual int FindSection(const char* sectionName) const;
//////////////////////////////////////////////////////////////////////////
private:
void LoadFromBuffer(const char* buf);
private:
// Config file entry structure, filled by readSection method.
struct Entry
{
string key; //!< keys (for comments this is "")
string value; //!< values and comments (with leading ; or //)
bool IsComment() const;
};
struct Section
{
string name; //!< Section name. The first one has the name "" and is used if no section was specified.
std::list<Entry> entries; //!< List of entries.
};
string m_fileName; //!< Configuration file name.
int m_modified; //!< Set to true if config file been modified.
std::vector<Section> m_sections; //!< List of sections in config file. (the first one has the name "" and is used if no section was specified)
};
#endif // CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CFGFILE_H