コード例 #1
0
ファイル: main.cpp プロジェクト: lgosha/ssd
int main(int argc, char *argv[])
{
	QString sFile;
	for(int i=1;i<argc;i++) {
		if( QString(argv[i]) == "--file" ) {
			if( ++i < argc ) { sFile = argv[i]; continue; }
		}
	}

	XMLInit();
	int iRes = 0;
	
	iRes = create_configuration( sFile );
	
	const DOMNode *pNode = pXMLConfig->first(XMLConfig::find(pXMLConfig->root(), "", ""));
	QString sComment;
	
	QFile file( sFile + ".comment" );
	file.open( QIODevice::WriteOnly ); 

	QFile filer( sFile + ".reserve" );
	filer.open( QIODevice::WriteOnly ); 

	int iReverse = -1;
	while(pNode) {
		if(pNode->getNodeType() == DOMNode::COMMENT_NODE) {
				
			sComment = XMLConfig::toQString( pNode->getNodeValue() );
			sComment.replace( QRegExp("\\d{9}\\s+"), "" );

			iReverse = -1;
			iReverse = sComment.indexOf("(r)");
		}
		if(pNode->getNodeType() == DOMNode::ELEMENT_NODE) {
		
		    if( !pXMLConfig->isAttr( pNode, "send" ) || pXMLConfig->attr( pNode, "send" ) != "no" ) {
		    
				file.write( QString( "%1 - <!-- %2 -->\n").arg(pXMLConfig->attr(pNode, "id")).arg(sComment).toAscii() );

				QString str = pXMLConfig->attr(pNode, "id").right(3);
				if( str.toInt() > 1 && str.toInt() < 100 ) {
					filer.write( QString("%1 - %2\n").arg(pXMLConfig->attr(pNode, "id")).arg( iReverse ).toAscii() );
				}
		    
				if( pXMLConfig->attr( pNode, "vtype" ) != "int" )
					printf( "\t\t%s <!-- %s -->\n", QString("<through id=\"%1\" serv=\"%SERV\" vtype=\"%2\"\t/>").arg(pXMLConfig->attr(pNode, "id")).arg(pXMLConfig->attr(pNode, "vtype")).toAscii().constData(), sComment.toAscii().constData() );
				else
					printf( "\t\t%s <!-- %s -->\n", QString("<through id=\"%1\" serv=\"%SERV\" vtype=\"%2\"\t\t/>").arg(pXMLConfig->attr(pNode, "id")).arg(pXMLConfig->attr(pNode, "vtype")).toAscii().constData(), sComment.toAscii().constData() );
				}
		}

		pNode = pXMLConfig->next();
	}
	
	file.close();
	filer.close();

	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: lgosha/ssd
int main( int argc, char **argv ) {

	int iResult = 0;
	// создание файла отчета программы
	aptrMainLog = auto_ptr<ULog>( new ULog( "../ddv.txt", "cp1251") );
	// первое сообщение
	aptrMainLog->add("start report file");

	// инициализация XML библиотеки
	iResult = XMLInit();
	// проверка выполнения предыдущего действия
	if(!iResult) {
		// чтение конфигурационных файлов
		iResult = create_configuration();
		// конфигурационные файлы прочитаны
		if(!iResult) {
			// создание объектов приложения и главного окна
			QApplication app( argc, argv );
			try {
				CMainWnd wnd( pXMLConfig );
				wnd.show();
				iResult = app.exec();
			}
			catch(const ex_base &ex) {
				// исключение
				aptrMainLog->add(
						QStringList("failed") + QStringList(QString("%1: %2").arg(ex.get_where()).arg(ex.get_what())),
						ULog::eMT_Error
						);
				iResult = 6;
			}
		}
	}

	// удаление объектов файлов конфигурации
	aptrMainLog->add("destroy configuration objects");
	delete pXMLConfig;
	aptrMainLog->add("success", ULog::eMT_Success);

	// деинициализация XML библиотеки
	aptrMainLog->add("deinitialize XML library");
	XMLPlatformUtils::Terminate();
	aptrMainLog->add("success", ULog::eMT_Success);

	// последнее сообщение
	aptrMainLog->add("stop  report file");

	return iResult;
}
コード例 #3
0
CPLErr GDALPamDataset::TryLoadXML()

{
    CPLXMLNode *psTree = NULL;

    PamInitialize();

/* -------------------------------------------------------------------- */
/*      Clear dirty flag.  Generally when we get to this point is       */
/*      from a call at the end of the Open() method, and some calls     */
/*      may have already marked the PAM info as dirty (for instance     */
/*      setting metadata), but really everything to this point is       */
/*      reproducable, and so the PAM info shouldn't really be           */
/*      thought of as dirty.                                            */
/* -------------------------------------------------------------------- */
    nPamFlags &= ~GPF_DIRTY;

/* -------------------------------------------------------------------- */
/*      Try reading the file.                                           */
/* -------------------------------------------------------------------- */
    if( !BuildPamFilename() )
        return CE_None;

    VSIStatBufL sStatBuf;

    if( VSIStatL( psPam->pszPamFilename, &sStatBuf ) == 0 
        && VSI_ISREG( sStatBuf.st_mode ) )
    {
        CPLErrorReset();
        CPLPushErrorHandler( CPLQuietErrorHandler );
        psTree = CPLParseXMLFile( psPam->pszPamFilename );
        CPLPopErrorHandler();
    }

/* -------------------------------------------------------------------- */
/*      If we are looking for a subdataset, search for it's subtree     */
/*      now.                                                            */
/* -------------------------------------------------------------------- */
    if( psTree && psPam->osSubdatasetName.size() )
    {
        CPLXMLNode *psSubTree;
        
        for( psSubTree = psTree->psChild; 
             psSubTree != NULL;
             psSubTree = psSubTree->psNext )
        {
            if( psSubTree->eType != CXT_Element
                || !EQUAL(psSubTree->pszValue,"Subdataset") )
                continue;

            if( !EQUAL(CPLGetXMLValue( psSubTree, "name", "" ),
                       psPam->osSubdatasetName) )
                continue;

            psSubTree = CPLGetXMLNode( psSubTree, "PAMDataset" );
            break;
        }
        
        if( psSubTree != NULL )
            psSubTree = CPLCloneXMLTree( psSubTree );

        CPLDestroyXMLNode( psTree );
        psTree = psSubTree;
    }

/* -------------------------------------------------------------------- */
/*      If we fail, try .aux.                                           */
/* -------------------------------------------------------------------- */
    if( psTree == NULL )
        return TryLoadAux();

/* -------------------------------------------------------------------- */
/*      Initialize ourselves from this XML tree.                        */
/* -------------------------------------------------------------------- */
    CPLErr eErr;

    CPLString osVRTPath(CPLGetPath(psPam->pszPamFilename));
    eErr = XMLInit( psTree, osVRTPath );

    CPLDestroyXMLNode( psTree );

    if( eErr != CE_None )
        PamClear();

    return eErr;
}