libsidplayfp  1.0.3
iniParser.h
00001 /*
00002  *  Copyright (C) 2010-2011 Leandro Nini
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 #ifndef INIPARSER_H
00020 #define INIPARSER_H
00021 
00022 #include <string>
00023 #include <iostream>
00024 #include <fstream>
00025 #include <map>
00026 
00027 class iniParser
00028 {
00029 private:
00030     typedef std::map<std::string, std::string> keys_t;
00031 
00032     class emptyPair {};
00033 
00034 private:
00035     std::map<std::string, keys_t> sections;
00036 
00037     std::map<std::string, keys_t>::const_iterator curSection;
00038 
00039 private:
00040     std::string parseSection(const char *buffer);
00041 
00042     std::pair<std::string, std::string> parseKey(const char *buffer);
00043 
00044 public:
00045     iniParser() {}
00046     ~iniParser() {}
00047 
00048     bool open(const char *fName);
00049     void close();
00050 
00051     bool setSection(const char *section);
00052     const char *getValue(const char *key);
00053 };
00054 
00055 #endif // INIPARSER_H