dolphin/Source/Core/InputPluginCommon/Src/IniFile.h
Jordan Woyak d8906d2a0c Commited my new wiimote plugin work so far. Some code was copied from the current wiimote plugin. I have cleaned up most of the functions, but there are still a bunch of unused structs and stuff that I need to clean up.
Moved ControllerInterface to InputCommon. Moved GCPadNew GUI/Config code to a new project, InputPluginCommon. It is used by both GCPadNew and WiimoteNew. I hope that I included everyone's fixes to GCPadNew and ControllerInterface.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5355 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-04-13 05:15:38 +00:00

61 lines
1.1 KiB
C++

#ifndef _INIFILE_H_
#define _INIFILE_H_
#include <fstream>
#include <map>
#include <string>
#include <sstream>
//
// IniFile
//
class IniSection : public std::map< std::string, std::string >
{
public:
void Set( const std::string& key, const std::string& val, const std::string& def = "" );
std::string Get( const std::string& key, const std::string& def = "" );
template <typename V, typename D>
void Set( const std::string& key, const V& val, const D& def = 0 )
{
if ( val != def )
{
std::ostringstream ss;
ss << long(val);
operator[](key) = ss.str();
}
else
{
iterator f = find(key);
if ( f != end() )
erase( f );
}
}
template <typename V>
V Get( const std::string& key, const V& def = 0 )
{
const const_iterator f = find(key);
if ( f != end() )
if ( false == f->second.empty() )
{
std::istringstream ss(f->second);
int val;
ss >> val;
return V(val);
}
return def;
}
};
class IniFile : public std::map< std::string, IniSection >
{
public:
typedef IniSection Section;
void Clean();
void Save( std::ostream& file );
void Load( std::istream& file );
};
#endif