bool CSVwrite::WriteRecord( const vector<string> &fields, bool terminate /* = true */ )
{
    if( _error )
        return false;

    if( !_output_ptr )
    {
        _error = true;
        _error_msg = "A stream is not associated with the object.";
        return false;
    }

    if( !_is_first_field )
    {
        if( !WriteTerminator() )
        {
            return false;
        }
    }

    if( !fields.size() && !(( _flags & CSVwrite::process_empty_records )) )
    {
        return true;
    }

    for( vector<string>::const_iterator it = fields.begin(); it != fields.end(); ++it )
    {
        if( !WriteField( *it ) )
        {
            return false;
        }
    }

    if( terminate )
    {
        if( !WriteTerminator() )
        {
            return false;
        }
    }

    return true;
}
Esempio n. 2
0
ERTFToken RTFformatting::Write (CRtfWriter* f)
{
	if (m_bAddExtraScope)
	{
		f->StartGroup();
		m_bAddExtraScope=false;
	}

	if(m_bNestedTblDef)
	{
		WriteNestedTableDefinitionStartSequence(f);
	}

	bool bWriteApoCtl = true;
	bool bWasImplicit = false;
	//must have \par before pn, otherwise lists get screwed
	if (the_RTFparfmt)
	{
		bWasImplicit = the_RTFparfmt->get_bImplicit();
		if (!bWasImplicit)
		{
			GetParfmtToModify()->MakeImplicit( );
			if (!InHeader())
			{
				if (f->IsHiddenText())
				{
					f->WriteTag("spv");
				}
				f->WriteTag("par");
				if (f->IsHiddenText())
				{
					f->WriteTag("spv", 0);
				}
				f->SetLast(rotParfmt);
			}
		}
	}

	if (the_RTFpn)
		the_RTFpn->Write(f);

	if (f->GetFileContext()->IsWritingRedline() && the_RTFapoctl != NULL)
	{
		// if in a table also and has an apoctl, then can screw the rendering when changes are in the table. (as the table bottom will not be visible off page)
		// so, best to not write the apoctl, but have to set keepn otherwise part of table move to next page! see VE2115 and VE3069
		if (the_RTFparfmt != NULL && the_RTFparfmt->IsInTable())
		{
			GetParfmtToModify()->SetKeepWithNext(true);
			bWriteApoCtl = the_RTFapoctl->MustWritePositionInTable();
		}
	}

	if (the_RTFparfmt)
	{
		the_RTFparfmt->WriteConst(f);

		if (!bWasImplicit)	//restore correct state.
		{
			GetParfmtToModify()->MakeImplicit( false );
			AttachParfmt();
		}
	}

	if (the_RTFtabdef)
		the_RTFtabdef->Write(f);

	if (the_RTFpnprops)
		the_RTFpnprops->Write(f);

	if (the_RTFbrdrdef)
		the_RTFbrdrdef->Write(f);

	if (bWriteApoCtl && the_RTFapoctl)
		the_RTFapoctl->Write(f);

	if (the_RTFtapoctl)
		the_RTFtapoctl->Write(f);

	if (the_RTFshading)
		the_RTFshading->Write(f);

	if (the_RTFchrfmt)
		the_RTFchrfmt->WriteConst(f);

	WriteTerminator(f);

	return rtfec_OK;
}