+// ================================================================
+/*!
+ * ::isBoolAttributeSet [ static ]
+ * Returns true if the attribute stores boolean value and
+ * corresponds to True value
+ */
+// ================================================================
+static bool isBoolAttributeSet( const QString& attr ) {
+ return ( attr.lower() == "true" ||
+ attr.lower() == "yes" ||
+ attr.lower() == "ok" ||
+ ( !attr.stripWhiteSpace().isEmpty() && attr.toInt() != 0 ) );
+}
+// ================================================================
+/*!
+ * ::environmentVariable [ static ]
+ * Seraches for the environment variable and returns it's
+ * position on the given string
+ */
+// ================================================================
+QString environmentVariable( const QString& str, int& start, int& len ) {
+ QString varName = QString::null;
+ len = 0;
+
+ // Environment variable can be given in the form:
+ // - ${VARIABLE} or
+ // - $(VARIABLE) or
+ // - $VARIABLE or
+ // - %VARIABLE%
+ // The first symbol should be the letter.
+ QRegExp rx( "\\$\\{([a-zA-Z]+[a-zA-Z0-9_]*)\\}|\\$\\(([a-zA-Z]+[a-zA-Z0-9_]*)\\)|\\$([a-zA-Z]+[a-zA-Z0-9_]*)|\\%([a-zA-Z]+[a-zA-Z0-9_]*)\\%" );
+
+ int pos = rx.search( str, start );
+ if ( pos != -1 )
+ {
+ start = pos;
+ len = rx.matchedLength();
+ QStringList caps = rx.capturedTexts();
+ for ( uint i = 1; i <= caps.count() && varName.isEmpty(); i++ )
+ varName = *caps.at( i );
+ }
+ return varName;
+}
+// ================================================================
+/*!
+ * ::substituteVars [ static ]
+ * Substitutes environment variables in the given string
+ * by their values
+ */
+// ================================================================
+static QString substituteVars( const QString& str ) {
+ QString res = str;
+
+ int start( 0 ), len( 0 );
+ while ( true ) {
+ QString envName = environmentVariable( res, start, len );
+ if ( envName.isNull() )
+ break;
+
+ QString newStr = QString::null;
+ if ( ::getenv( envName ) )
+ newStr = QString( ::getenv( envName ) );
+
+ res.replace( start, len, newStr );
+ }
+
+ return res;