Exemplo n.º 1
0
void ValidateCommand :: Report( IOManager & io,
								const ValidationRule::Results & res,
								int errcount ) const {
	if ( res.size() == 0 ) {
		return;
	}
	else {
		if ( errcount == 0 ) {
			io.Out() << io.CurrentFileName() << " (" << io.CurrentLine () << "): ";
			io.Out() << io.CurrentInput() << "\n";
		}
		for ( unsigned int i = 0; i < res.size(); i++ ) {
			if ( res[i].Field() > 0 ) {
				io.Out() << "    field: " << res[i].Field() << " - ";
			}
			else {
				io.Out() << "    ";
			}
			io.Out() << res[i].Msg() << "\n";
		}
	}
}
Exemplo n.º 2
0
void FileSplitCommand :: WriteRow( IOManager & ioman, const CSVRow & row ) {

	string key = MakeKey( row );
	const string * p = mDict.GetPtr( key );
	string fname = (p == 0) ? NewFileName( key ) : * p;

	if ( p == 0 ) {
		mDict.Add( key, fname );
	}

	if ( fname != mCurrentFile ) {
		mOutFile.close();
		mOutFile.clear();	// close does not reset state
		mOutFile.open( fname.c_str(), std::ios::out | std::ios::app );   // append

		if ( ! mOutFile.is_open() ) {
			CSVTHROW( "Could not open file " << fname << " for output" );
		}
		mCurrentFile = fname;
	}

	mOutFile << ioman.CurrentInput() << "\n";
}