skins2: fix RadialSlider
[vlc/asuraparaju-public.git] / modules / gui / skins2 / src / ini_file.cpp
blob7fe8282eb67ea4c417051f6ce7f1cb580b218f52
1 /*****************************************************************************
2 * ini_file.cpp
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * $Id$
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "ini_file.hpp"
25 #include "var_manager.hpp"
26 #include <fstream>
29 IniFile::IniFile( intf_thread_t *pIntf, const string &rName,
30 const string &rPath ):
31 SkinObject( pIntf ), m_name( rName ), m_path( rPath )
36 void IniFile::parseFile()
38 VarManager *pVarManager = VarManager::instance( getIntf() );
40 // Open the file
41 fstream fs( m_path.c_str(), fstream::in );
42 if( fs.is_open() )
44 string section;
45 string line;
46 while( !fs.eof() )
48 // Read the next line
49 fs >> line;
51 switch( line[0] )
53 // "[section]" line ?
54 case '[':
55 section = line.substr( 1, line.size() - 2);
56 break;
58 // Comment
59 case ';':
60 case '#':
61 break;
63 // Variable declaration
64 default:
65 size_t eqPos = line.find( '=' );
66 string var = line.substr( 0, eqPos );
67 string val = line.substr( eqPos + 1, line.size() - eqPos - 1);
69 string name = m_name + "." + section + "." + var;
71 #ifdef WIN32
72 // Convert to lower case because of some buggy winamp2 skins
73 for( size_t i=0; i< name.size(); i++)
75 name[i] = tolower( name[i] );
77 #endif
79 // Register the value in the var manager
80 pVarManager->registerConst( name, val );
83 fs.close();
85 else
87 msg_Err( getIntf(), "Failed to open INI file %s", m_path.c_str() );