mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Merge GCPadNew into Dolphin. This takes place in three segments: Core, InputCommon, and InputUICommon. From now on it can be referred to just as "GCPad".
Switch to Billiard's IniFile implementation throughout Dolphin (it's faster!!). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5579 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,61 +0,0 @@
|
||||
#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
|
Reference in New Issue
Block a user