File indexing completed on 2024-03-24 04:04:46
0001 /*************************************************************************** 0002 * KBlocks, a falling blocks game by KDE * 0003 * SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * 0004 * * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 ***************************************************************************/ 0007 #ifndef KBLOCKSCONFIGMANAGER_H_INCLUDED 0008 #define KBLOCKSCONFIGMANAGER_H_INCLUDED 0009 0010 #include <stdio.h> 0011 #include <string> 0012 #include <map> 0013 0014 using namespace std; 0015 class KBlocksConfigManager 0016 { 0017 private: 0018 map< int, string > stConfigSectionList; 0019 map< string, map< int, string > > stConfigKeyNameList; 0020 map< string, map< string, string > > stConfigDataTable; 0021 0022 bool isDebug; 0023 0024 public: 0025 KBlocksConfigManager(); 0026 ~KBlocksConfigManager(); 0027 0028 int SetDebugOutput(bool flag); 0029 0030 int LoadConfigFile(const string &filename); 0031 int SaveConfigFile(const string &filename); 0032 0033 int GetSectionCount(); 0034 int GetKeyCount(const string &SectionName); 0035 0036 int GetKeyString(const string &SectionName, const string &KeyName, string *KeyString, const string &Default); 0037 int GetKeyInt(const string &SectionName, const string &KeyName, int *KeyInt, const int Default); 0038 int GetKeyBool(const string &SectionName, const string &KeyName, bool *KeyBool, const bool Default); 0039 0040 int SetKeyString(string SectionName, string KeyName, string KeyString); 0041 int SetKeyInt(string SectionName, string KeyName, int KeyInt); 0042 int SetKeyBool(const string &SectionName, const string &KeyName, bool KeyBool); 0043 0044 private: 0045 int ParseConfigFile(FILE *fp); 0046 int ConstructConfigFile(FILE *fp); 0047 0048 string int16tostring(int input); 0049 }; 0050 0051 #endif // KBLOCKSCONFIGMANAGER_H_INCLUDED 0052