X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FResExporter%2FResourceExporter.cxx;h=597059bded6400c33831c30d10c69b635a644f91;hb=1c889394b028b786898a995d38c07c8f3d564837;hp=29922a2cdb819e4fe17e62053db6e28851def77c;hpb=cec0bd96a4e005a7d4d86e104ca2e37cc447715f;p=modules%2Fgui.git diff --git a/src/ResExporter/ResourceExporter.cxx b/src/ResExporter/ResourceExporter.cxx index 29922a2cd..597059bde 100644 --- a/src/ResExporter/ResourceExporter.cxx +++ b/src/ResExporter/ResourceExporter.cxx @@ -1,38 +1,57 @@ -//====================================================================================================== -// File: ResourceExporter.cxx -// Created: 27/06/05 -// Author: Vadim SANDLER -// Copyright (C) CEA 2005 +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE // -// This tool provides command-line interface allowing to modify user preferences. -// The tool can be used by the compilation procedures in order to set default preferences for the module. +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// Usage: -// ResourceExporter -// Parameters have the following format: -// '
:=' - to set for the user -// preference from the
section; -// '
:+=[|]' - the is appended to the current value -// of the preference from the
section; -// separator is used to concatenate old and new values, -// by default comma (',') symbol is used -// '-
:' - to remove user preference from the
-// section. Note that only use preference file is -// influenced, you may need to use '
:=""' -// option -// The number of parameters is limeted only by maximum possible length of the command line. -//====================================================================================================== +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library 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 +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : ResourceExporter.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// +/* + This tool provides command-line interface allowing to modify user preferences. + The tool can be used by the compilation procedures in order to set default preferences for the module. + + Usage: + ResourceExporter + Parameters have the following format: + '
:=' - to set for the user + preference from the
section; + '
:+=[|]' - the is appended to the current value + of the preference from the
section; + separator is used to concatenate old and new values, + by default comma (',') symbol is used + '-
:' - to remove user preference from the
+ section. Note that only use preference file is + influenced, you may need to use '
:=""' + option + The number of parameters is limeted only by maximum possible length of the command line. +*/ #include "SUIT_ResourceMgr.h" -#include -#include -#include -#include +#include +#include +#include +#include #include -//============================================================ -// salomeVersion(): get the SALOME version number -//============================================================ +/*! + \return the SALOME version number +*/ static QString salomeVersion() { QString path( ::getenv( "GUI_ROOT_DIR" ) ); @@ -41,30 +60,29 @@ static QString salomeVersion() path += QString( "bin/salome/VERSION" ); QFile vf( path ); - if ( !vf.open( IO_ReadOnly ) ) - return QString::null; + if ( !vf.open( QIODevice::ReadOnly ) ) + return QString(); - QString line; - vf.readLine( line, 1024 ); + QString line( vf.readLine( 1024 ) ); vf.close(); if ( line.isEmpty() ) - return QString::null; + return QString(); while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) ) line.remove( line.length() - 1, 1 ); QString ver; - int idx = line.findRev( ":" ); + int idx = line.lastIndexOf( ":" ); if ( idx != -1 ) - ver = line.mid( idx + 1 ).stripWhiteSpace(); + ver = line.mid( idx + 1 ).trimmed(); return ver; } -//============================================================ -// help(): print the help information -//============================================================ +/*! + print the help information +*/ static void help() { std::cout << "" << std::endl; @@ -87,9 +105,9 @@ static void help() std::cout << "" << std::endl; } -//============================================================ -// main(): application main() function -//============================================================ +/*! + application main() function +*/ int main( int argc, char** argv ) { QApplication app( argc, argv ); @@ -99,47 +117,47 @@ int main( int argc, char** argv ) resMgr->setCurrentFormat( QString( "xml" ) ); resMgr->loadLanguage(); for ( int i = 1; i < argc; i ++ ) { - QString anArg = QString( argv[i] ).stripWhiteSpace(); + QString anArg = QString( argv[i] ).trimmed(); if ( anArg.startsWith( "-" ) ) { anArg.remove( 0, 1 ); if ( anArg.contains( ":" ) ) { - QStringList vals = QStringList::split( ":", anArg ); - QString section = vals[ 0 ].stripWhiteSpace(); - QString param = vals[ 1 ].stripWhiteSpace(); + QStringList vals = anArg.split( ":", QString::SkipEmptyParts ); + QString section = vals[ 0 ].trimmed(); + QString param = vals[ 1 ].trimmed(); if ( section.isEmpty() || param.isEmpty() ) continue; resMgr->remove( section, param ); } } else if ( anArg.contains( "+=" ) ) { - QStringList vals = QStringList::split( "+=", anArg ); + QStringList vals = anArg.split( "+=", QString::SkipEmptyParts ); if ( vals[ 0 ].contains( ":" ) ) { - QStringList vals1 = QStringList::split( ":", vals[ 0 ] ); - QString section = vals1[ 0 ].stripWhiteSpace(); - QString param = vals1[ 1 ].stripWhiteSpace(); - QString newValue = vals [ 1 ].stripWhiteSpace(); + QStringList vals1 = vals[ 0 ].split( ":", QString::SkipEmptyParts ); + QString section = vals1[ 0 ].trimmed(); + QString param = vals1[ 1 ].trimmed(); + QString newValue = vals [ 1 ].trimmed(); QString separ = ","; // default separator if ( newValue.contains( "|" ) ) { - QStringList vals2 = QStringList::split( "|", newValue ); - newValue = vals2[ 0 ].stripWhiteSpace(); - separ = vals2[ 1 ].stripWhiteSpace(); + QStringList vals2 = newValue.split( "|", QString::SkipEmptyParts ); + newValue = vals2[ 0 ].trimmed(); + separ = vals2[ 1 ].trimmed(); } if ( section.isEmpty() || param.isEmpty() || newValue.isEmpty() || separ.isEmpty() ) continue; QString value = resMgr->stringValue( section, param ); - QStringList valsOld = QStringList::split( separ, value ); - QStringList valsNew = QStringList::split( separ, newValue ); - for ( int i = 0; i < valsNew.count(); i++ ) + QStringList valsOld = value.split( separ, QString::SkipEmptyParts ); + QStringList valsNew = newValue.split( separ, QString::SkipEmptyParts ); + for ( int i = 0; i < (int)valsNew.count(); i++ ) if ( !valsOld.contains( valsNew[i] ) ) valsOld.append( valsNew[i] ); resMgr->setValue( section, param, valsOld.join( separ ) ); } } else if ( anArg.contains( "=" ) ) { - QStringList vals = QStringList::split( "=", anArg ); + QStringList vals = anArg.split( "=", QString::SkipEmptyParts ); if ( vals[ 0 ].contains( ":" ) ) { - QStringList vals1 = QStringList::split( ":", vals[ 0 ] ); - QString section = vals1[ 0 ].stripWhiteSpace(); - QString param = vals1[ 1 ].stripWhiteSpace(); - QString value = vals [ 1 ].stripWhiteSpace(); + QStringList vals1 = vals[ 0 ].split( ":", QString::SkipEmptyParts ); + QString section = vals1[ 0 ].trimmed(); + QString param = vals1[ 1 ].trimmed(); + QString value = vals [ 1 ].trimmed(); if ( section.isEmpty() || param.isEmpty() ) continue; resMgr->setValue( section, param, value ); }