1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
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"
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() );
41 fstream
fs( m_path
.c_str(), fstream::in
);
55 section
= line
.substr( 1, line
.size() - 2);
63 // Variable declaration
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
;
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
] );
79 // Register the value in the var manager
80 pVarManager
->registerConst( name
, val
);
87 msg_Err( getIntf(), "Failed to open INI file %s", m_path
.c_str() );