Back to index

salome-gui  6.5.0
Functions
ResourceExporter.cxx File Reference
#include "GUI_version.h"
#include "SUIT_ResourceMgr.h"
#include <QFile>
#include <QDir>
#include <QStringList>
#include <QApplication>
#include <iostream>

Go to the source code of this file.

Functions

static QString salomeVersion ()
static void help ()
 print the help information
int main (int argc, char **argv)
 application main() function

Function Documentation

static void help ( ) [static]

print the help information

Definition at line 65 of file ResourceExporter.cxx.

{
  std::cout << ""                                                                                                     << std::endl;
  std::cout << "ResourceExporter: provides command-line interface to modify user preferences."                        << std::endl;
  std::cout << ""                                                                                                     << std::endl;
  std::cout << "Usage:"                                                                                               << std::endl;
  std::cout << "   ResourceExporter <parameters-list>"                                                                << std::endl;
  std::cout << "Parameters have the following format:"                                                                << std::endl;
  std::cout << "   '<section>:<name>=<new_value>'            - to set <new_value> for the user "                      << std::endl;
  std::cout << "                                               preference <name> from the <section> section;"         << std::endl;
  std::cout << "   '<section>:<name>+=<value>[|<separator>]' - the <value> is appended to the current value "         << std::endl;
  std::cout << "                                               of the preference <name> from the <section> section;"  << std::endl;
  std::cout << "                                               separator is used to concatenate old and new values,"  << std::endl;
  std::cout << "                                               by default comma (',') symbol is used"                 << std::endl;
  std::cout << "   '-<section>:<name>'                       - to remove user preference <name> from the <section>"   << std::endl;
  std::cout << "                                               section. Note that only use preference file is "       << std::endl;
  std::cout << "                                               influenced, you may need to use '<section>:<name>=""'" << std::endl;
  std::cout << "                                               option"                                                << std::endl;
  std::cout << "The number of parameters is limeted only by maximum possible length of the command line."             << std::endl;
  std::cout << ""                                                                                                     << std::endl;
}

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

application main() function

Definition at line 90 of file ResourceExporter.cxx.

{
  QApplication app( argc, argv );
  if ( argc > 1 ) {
    SUIT_ResourceMgr* resMgr = new SUIT_ResourceMgr( QString( "SalomeApp" ), QString( "%1Config" ) );
    resMgr->setVersion( salomeVersion() );
    resMgr->setCurrentFormat( QString( "xml" ) );
    resMgr->loadLanguage();
    for ( int i = 1; i < argc; i ++ ) {
      QString anArg = QString( argv[i] ).trimmed();
      if ( anArg.startsWith( "-" ) ) {
        anArg.remove( 0, 1 );
        if ( anArg.contains( ":" ) ) {
          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 = anArg.split( "+=", QString::SkipEmptyParts );
        if ( vals[ 0 ].contains( ":" ) ) {
          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 = 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 = 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 = anArg.split( "=", QString::SkipEmptyParts );
        if ( vals[ 0 ].contains( ":" ) ) {
          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 );
        }
      }
    }
    resMgr->save();
    delete resMgr;
  }
  else {
    help();
  }
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static QString salomeVersion ( ) [static]
Returns:
the SALOME version number

Definition at line 57 of file ResourceExporter.cxx.

{
  return GUI_VERSION_STR;
}

Here is the caller graph for this function: