/* Copyright 2005 Nicholas Bishop * * This file is part of SharpConstruct. * * SharpConstruct is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * SharpConstruct is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with SharpConstruct; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PREFERENCES_H #define PREFERENCES_H #include #include #include namespace SharpConstruct { class Preferences { public: typedef std::map< std::string, std::string > Map; ~Preferences(); static Preferences& Instance(); template< typename T > T Get( std::string name, T def ) { Map::iterator i = _settings.find( name ); if( i == _settings.end() ) return def; else { std::istringstream tmp( ( *i ).second ); T otmp; tmp >> otmp; return otmp; } } std::string Get( std::string name, std::string def ); void Set( std::string name, std::string value ); void Set( std::string name, int value ); void Set( std::string name, float value ); private: Preferences(); Map _settings; }; } #endif // PREFERENCES_H