src/Generic/driver/DocumentDriver.cpp
// Temporary procedure during serifxml development -- this is basically a 
// drop-in replacement for the run() procedure, except that for testing
// purposes it serializes and deserializes after every stage.

Temporary procedure during serifxml development -- this is basically a
drop-in replacement for the run() procedure, except that for testing
purposes it serializes and deserializes after every stage.
Temporary procedure during serifxml development -- this is basically a drop - in replacement for the run () procedure except that for testing purposes it serializes and deserializes after every stage .
void DocumentDriver::serifXMLTest() {
	if (_sessionProgram->getStartStage() < Stage("score")) {
		Stage startStage = _sessionProgram->getStartStage();
		Stage endStage = _sessionProgram->getEndStage();
		for (Stage stage = startStage; stage <= endStage; ++stage) {
			const_cast<SessionProgram*>(_sessionProgram)->setStageRange(stage, stage); 
			const Batch *batch = _sessionProgram->getBatch();
			for (size_t doc_num = 0; doc_num < batch->getNDocuments(); ++doc_num) {	
				const wchar_t *document_path = batch->getDocumentPath(doc_num);
				boost::filesystem::wpath docPathBoost(document_path);
				std::wstring document_filename = UnicodeUtil::toUTF16StdString(BOOST_FILESYSTEM_PATH_GET_FILENAME(docPathBoost));
                if (_localSessionLogger) {
					_localSessionLogger->updateContext(DOCUMENT_CONTEXT, document_filename.c_str());
                }
				Stage loadStage = stage.getPrevStage();
				std::pair<const Document*, DocTheory*> docPair;
				if (stage == Stage::getStartStage()) {
					Document *doc = loadDocument(document_path);
					docPair = std::make_pair(doc, getInitialDocTheory(doc));
				} else {
					std::wstringstream fn;
					fn << _sessionProgram->getOutputDir() 
						<< L"/" << document_filename
						<< "-" << loadStage.getSequenceNumber() 
						<< "-" << loadStage.getName() << L".xml";
					std::wstring fname = fn.str();
					docPair = SerifXML::XMLSerializedDocTheory(fname.c_str()).generateDocTheory();
				}
				DocTheory* docTheory = docPair.second;
				const Document* document = docPair.first;
				runOnDocTheory(docTheory, document_filename.c_str());
				std::wstringstream fn;
				fn << _sessionProgram->getOutputDir() 
					<< L"/" << document_filename 
					<< "-" << stage.getSequenceNumber() 
					<< "-" << stage.getName() << L".xml";
				std::wstring fname = fn.str();
				SerifXML::XMLSerializedDocTheory(docTheory).save(fname.c_str());
				delete docTheory;
				delete document;
			}
			Symbol::discardUnusedSymbols();
		}
	}
	if (_sessionProgram->includeStage(Stage("score"))) {
		invokeScoreScript();
	}
}
void DocumentDriver :: serifXMLTest ( ) { if ( _sessionProgram -> getStartStage ( ) < Stage ( " " ) ) { Stage startStage = _sessionProgram -> getStartStage ( ) ; Stage endStage = _sessionProgram -> getEndStage ( ) ; for ( Stage stage = startStage ; stage <= endStage ; ++ stage ) { const_cast < SessionProgram * > ( _sessionProgram ) -> setStageRange ( stage , stage ) ; const Batch * batch = _sessionProgram -> getBatch ( ) ; for ( size_t doc_num = 0 ; doc_num < batch -> getNDocuments ( ) ; ++ doc_num ) { const wchar_t * document_path = batch -> getDocumentPath ( doc_num ) ; boost :: filesystem :: wpath docPathBoost ( document_path ) ; std :: wstring document_filename = UnicodeUtil :: toUTF16StdString ( BOOST_FILESYSTEM_PATH_GET_FILENAME ( docPathBoost ) ) ; if ( _localSessionLogger ) { _localSessionLogger -> updateContext ( DOCUMENT_CONTEXT , document_filename . c_str ( ) ) ; } Stage loadStage = stage . getPrevStage ( ) ; std :: pair < const Document * , DocTheory * > docPair ; if ( stage == Stage :: getStartStage ( ) ) { Document * doc = loadDocument ( document_path ) ; docPair = std :: make_pair ( doc , getInitialDocTheory ( doc ) ) ; } else { std :: wstringstream fn ; fn << _sessionProgram -> getOutputDir ( ) << L" " << document_filename << " " << loadStage . getSequenceNumber ( ) << " " << loadStage . getName ( ) << L" " ; std :: wstring fname = fn . str ( ) ; docPair = SerifXML :: XMLSerializedDocTheory ( fname . c_str ( ) ) . generateDocTheory ( ) ; } DocTheory * docTheory = docPair . second ; const Document * document = docPair . first ; runOnDocTheory ( docTheory , document_filename . c_str ( ) ) ; std :: wstringstream fn ; fn << _sessionProgram -> getOutputDir ( ) << L" " << document_filename << " " << stage . getSequenceNumber ( ) << " " << stage . getName ( ) << L" " ; std :: wstring fname = fn . str ( ) ; SerifXML :: XMLSerializedDocTheory ( docTheory ) . save ( fname . c_str ( ) ) ; delete docTheory ; delete document ; } Symbol :: discardUnusedSymbols ( ) ; } } if ( _sessionProgram -> includeStage ( Stage ( " " ) ) ) { invokeScoreScript ( ) ; } }
Temporary procedure during serifxml development -- this is basically a
drop-in replacement for the run() procedure, except that for testing
purposes it serializes and deserializes after every stage.
Temporary procedure during serifxml development -- this is basically a drop - in replacement for the run () procedure except that for testing purposes it serializes and deserializes after every stage .
// Do one stage at a time.
 // Save to xml.
 // spawn an exec that scores
