Exemple #1
0
void TestPageStream()
{
	CommonLib::simple_alloc_t alloc;
	embDB::CStorage storage(&alloc, 1000);
	storage.AddRef();
	storage.open(L"d:\\db\\pagestorage.data", false, false, true, false);
	embDB::FilePagePtr pPage = storage.getNewPage(PAGE_SIZE_8K);
	storage.initStorage(pPage->getAddr());
 	storage.saveStorageInfo();
	bool bCheckCRC = false;
	short nType1 = 1;
	short nType2 = 2;
	int64 nAddr = storage.getNewPageAddr(PAGE_SIZE_8K);
	{
		embDB::TWriteStreamPage<embDB::IDBStorage> writeStream(&storage, PAGE_SIZE_8K, bCheckCRC, nType1, nType2);
	

		writeStream.open(nAddr, 0);


		for (int64 i = 0; i < 10000; ++i)
		{
			writeStream.write(i);
		}
		writeStream.Save();
	}
		
	{

		embDB::TWriteStreamPage<embDB::IDBStorage> writeStream(&storage, PAGE_SIZE_8K, bCheckCRC, nType1, nType2);

		writeStream.open(nAddr, 0, true);
		for (int64 i = 0; i <100000; ++i)
		{
			writeStream.write(i);
		}
		writeStream.Save();

	}


	{
		embDB::TReadStreamPage<embDB::IDBStorage> readStream(&storage, PAGE_SIZE_8K, bCheckCRC, nType1, nType2);
		readStream.open(nAddr, 0);
		for (int64 i = 0; i < 20000; ++i)
		{
			int64 d = readStream.readInt64();
			if (d != i)
			{
				d++;
				assert(false);
			}
		}

	}

}
void SettingsSerializer::writePackedVariant(QDataStream& stream, const QVariant& v)
{
    assert(v.canConvert(QVariant::String));
    QString str = v.toString();
    if (str == "true")
        writeStream(stream, QString("1"));
    else if (str == "false")
        writeStream(stream, QString("0"));
    else
        writeStream(stream, str.toUtf8());
}
Exemple #3
0
void PdfExport::writeGzStream(Stream* str, GList* replacementList)
{
    XOJ_CHECK_TYPE(PdfExport);

    Object obj1;
    str->getDict()->lookup("Length", &obj1);
    if (!obj1.isInt())
    {
        g_error("PDFDoc::writeGzStream, no Length in stream dict");
        return;
    }

    const int length = obj1.getInt();
    obj1.free();

    char* buffer = new char[length];

    str->unfilteredReset();
    for (int i = 0; i < length; i++)
    {
        int c = str->getUnfilteredChar();
        buffer[i] = c;
    }
    GString* text = GzHelper::gzuncompress(buffer, length);
    writeStream(text->str, text->len, replacementList);

    g_string_free(text, true);

    delete buffer;

    str->reset();
}
Exemple #4
0
void PdfExport::writePlainStream(Stream* str, GList* replacementList)
{
    XOJ_CHECK_TYPE(PdfExport);

    Object obj1;
    str->getDict()->lookup("Length", &obj1);
    if (!obj1.isInt())
    {
        g_error("PDFDoc::writePlainStream, no Length in stream dict");
        return;
    }

    const int length = obj1.getInt();
    obj1.free();

    str->unfilteredReset();

    GString* buffer = g_string_sized_new(10240);

    for (int i = 0; i < length; i++)
    {
        int c = str->getUnfilteredChar();
        buffer = g_string_append_c(buffer, c);
    }

    writeStream(buffer->str, buffer->len, replacementList);

    g_string_free(buffer, true);

    str->reset();
}
// -----------------------------------------------------------------------------
// CCommonTestClass::ExternalizeMPXCollectionTypeL()
// Returns: Symbian OS errors.
// -----------------------------------------------------------------------------
TInt CCommonTestClass::ExternalizeMPXCollectionTypeL()
    {
	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin")));
    iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL begin"));
    TInt err = KErrNone;
    if ( iType != NULL )
        {
    	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize")));
        iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL started Externalize"));
        CBufBase* buffer = CBufFlat::NewL( 50 );
        CleanupStack::PushL( buffer );
        RBufWriteStream writeStream( *buffer );
        CleanupClosePushL( writeStream );
        iType->ExternalizeL( writeStream );
        writeStream.CommitL();
        buffer->Compress();
        CleanupStack::PopAndDestroy( &writeStream );
        CleanupStack::PopAndDestroy( buffer ); 
        }
    else
        {
        err = KErrBadTestParameter;
    	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong.")));
        iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL Stif test script is wrong."));
        }
	FTRACE(FPrint(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err));
    iLog->Log(_L("CCommonTestClass::ExternalizeMPXCollectionTypeL testing CMPXCollectionType::ExternalizeMPXCollectionTypeL end err=%d"), err);
	return err;
    }
void CCmdTestList::AddMultipleWaitCommandL(TInt32 aTimeout)
	{
	RDebug::Printf("CCmdTestList::AddMultipleWaitCommandL");
	SSMLOGLEAVEIFNULL(iCommandList);
	//
	const TInt KTempDataLength = 1024;
	CBufFlat* inputBuffer = CBufFlat::NewL(KTempDataLength);
	CleanupStack::PushL(inputBuffer);
	RBufWriteStream writeStream(*inputBuffer);
	CleanupClosePushL(writeStream);
	writeStream.WriteInt32L(aTimeout);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.WriteUint16L(KDefaultCommandPriority);
#endif //SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.CommitL();
	RDesReadStream readStream(inputBuffer->Ptr(0));
	CleanupClosePushL(readStream);
	TArray<MSsmCommand*> deferredList = iDeferredList.Array();
	CSsmCommandBase* cmd = CCmdMultipleWait::NewL(readStream, deferredList);
	CleanupStack::PushL(cmd);
	static_cast<MSsmCommandList&>(*iCommandList).AppendL(cmd);
	iDeferredList.Reset();
	CleanupStack::Pop(cmd);

	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(inputBuffer);
	}
Exemple #7
0
void
Console::output()
{
  // Print Non-linear Residual
  if (onNonlinearResidual())
  {
    if (_write_screen)
      Moose::out << std::setw(2) << _nonlinear_iter << " Nonlinear |R| = " << outputNorm(_old_nonlinear_norm, _norm) << std::endl;

    if (_write_file)
      _file_output_stream << std::setw(2) << _nonlinear_iter << " Nonlinear |R| = " << std::scientific << _norm << std::endl;
  }

  // Print Linear Residual
  else if (onLinearResidual())
  {
    if (_write_screen)
      Moose::out << std::setw(7) << _linear_iter << " Linear |R| = " << std::scientific << outputNorm(_old_linear_norm, _norm) << std::endl;

    if (_write_file)
      _file_output_stream << std::setw(7) << _linear_iter << std::scientific << " Linear |R| = " << std::scientific << _norm << std::endl;
  }

  // Call the base class output function
  else
  {
    writeVariableNorms();
    TableOutputter::output();
  }

  // Write the file
  if (_write_file)
    writeStream();
}
Exemple #8
0
/** 
Write matching contacts back to client.

@param aMessage.Ptr0() Descriptor to write array of matching contacts.
*/
void CViewSubSessionBase::GetContactMatchingCriteriaL(const RMessage2& aMessage)
	{
	// Compute contacts externalized size.
	const TInt contactsCount = iContacts.Count();
	TInt contactsExternalizedSize=0;
	contactsExternalizedSize+=sizeof(TInt32);
	for (TInt jj=0;jj<contactsCount;++jj)
		{
		contactsExternalizedSize+=(iContacts)[jj]->ExternalizedSize();
		}

	HBufC8* buf=HBufC8::NewLC(contactsExternalizedSize);
	TPtr8 bufPtr(buf->Des());
	RDesWriteStream writeStream(bufPtr);
	CleanupClosePushL(writeStream);

	writeStream.WriteUint32L(contactsCount);
	for (TInt ii=0;ii<contactsCount;++ii)
		{
		CViewContact* thisContact = (iContacts)[ii];
		writeStream << *thisContact;
		}

	bufPtr.SetLength(contactsExternalizedSize);
	aMessage.WriteL(0,*buf);

	CleanupStack::PopAndDestroy(2, buf); //writeStream.Close(), buf

	DeleteFindContacts();
	}
/**
Helper function to compare the data of the command.
*/
void CCmdTestWaitForApparcInit::CompareCommandsDataL(CCmdWaitForApparcInit* aTestCmd, TCmdErrorSeverity aSeverity, const TUint16 aPriority)
	{
	// create output buffer and stream
 	CBufFlat* outputBuffer = CBufFlat::NewL(KTempDataLength);
	CleanupStack::PushL(outputBuffer);
	RBufWriteStream writeStream(*outputBuffer);
	CleanupClosePushL(writeStream);

	// externalise the data
	aTestCmd->ExternalizeL(writeStream);
	RDesReadStream readStream(outputBuffer->Ptr(0));
	CleanupClosePushL(readStream);
	TCmdErrorSeverity severity = static_cast<TCmdErrorSeverity>(readStream.ReadInt16L());
	TEST(aSeverity == severity);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	TUint16 priority = readStream.ReadUint16L();
	TEST(aPriority == priority);
#else
	TEST(aPriority == KDefaultPriority);
#endif

	CleanupStack::PopAndDestroy(&readStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(outputBuffer);
	}
Exemple #10
0
GTEST_TEST_F(ConfigManager, newSave) {
	ConfigMan.create();

	ConfigMan.setInt("width", 640);
	ConfigMan.setInt("height", 480);

	const Common::UString game1 = ConfigMan.createGame("/path/to/game1/");

	ConfigMan.setGame(game1);

	ConfigMan.setString("path", "/path/to/game1/");
	ConfigMan.setInt("width", 800);
	ConfigMan.setInt("height", 600);
	ConfigMan.setBool("fullscreen", true);

	const Common::UString game2 = ConfigMan.createGame("/path/to/game2/");

	ConfigMan.setGame(game2);

	ConfigMan.setString("path", "/path/to/game2");

	Common::MemoryWriteStreamDynamic writeStream(true);
	ConfigMan.save(writeStream);

	compareStream(writeStream, kConfigFile);
}
Exemple #11
0
Console::~Console()
{
  // Write the libMesh performance log header
  if (_perf_header)
  {
    if (_write_screen && !_timing)
      Moose::out << Moose::perf_log.get_info_header();

    if (_write_file)
      _file_output_stream << Moose::perf_log.get_info_header();
  }

  // Write the solve log (Moose Test Performance)
  if (_solve_log)
  {
    if (_write_screen && !_timing)
      Moose::out << Moose::perf_log.get_perf_info();
    if (_write_file)
      _file_output_stream << Moose::perf_log.get_perf_info();
  }

  // Write the setup log (Setup Performance)
  if (_setup_log)
  {
    if (_write_screen && !_timing)
      Moose::out << Moose::setup_perf_log.get_perf_info();
    if (_write_file)
      _file_output_stream << Moose::setup_perf_log.get_perf_info();
  }

  // Write the libMesh log
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
  if (_libmesh_log)
  {
    if (_write_screen && !_timing)
      Moose::out << libMesh::perflog.get_perf_info();
    if (_write_file)
      _file_output_stream << libMesh::perflog.get_perf_info();
  }
#endif

  // Write the file output stream
  if (_write_file)
    writeStream();

  /* If --timing was not used disable the logging b/c the destructor of these
   * object does the output, if --timing was used do nothing because all other
   * screen related output was disabled above */
  if (!_timing)
  {
    /* Disable the logs, without this the logs will be printed
       during the destructors of the logs themselves */
    Moose::perf_log.disable_logging();
    Moose::setup_perf_log.disable_logging();
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
    libMesh::perflog.disable_logging();
#endif
  }
}
Exemple #12
0
GTEST_TEST_F(ConfigManager, save) {
	loadConfigMan();

	Common::MemoryWriteStreamDynamic writeStream(true);
	ConfigMan.save(writeStream);

	compareStream(writeStream, kConfigFile);
}
bool SkBBoxHierarchyRecord::shouldRewind(void* data) {
    // SkBBoxHierarchy::rewindInserts is called by SkPicture after the
    // SkPicture has rewound its command stream.  To match that rewind in the
    // BBH, we rewind all draws that reference commands that were recorded
    // past the point to which the SkPicture has rewound, which is given by
    // writeStream().bytesWritten().
    SkPictureStateTree::Draw* draw = static_cast<SkPictureStateTree::Draw*>(data);
    return draw->fOffset >= writeStream().bytesWritten();
}
Exemple #14
0
Console::Console(const std::string & name, InputParameters parameters) :
    TableOutputter(name, parameters),
    _max_rows(getParam<unsigned int>("max_rows")),
    _fit_mode(getParam<MooseEnum>("fit_mode")),
    _use_color(false),
    _scientific_time(getParam<bool>("scientific_time")),
    _write_file(getParam<bool>("output_file")),
    _write_screen(getParam<bool>("output_screen")),
    _verbose(getParam<bool>("verbose")),
    _old_linear_norm(std::numeric_limits<Real>::max()),
    _old_nonlinear_norm(std::numeric_limits<Real>::max()),
    _perf_log(getParam<bool>("perf_log")),
    _solve_log(isParamValid("solve_log") ? getParam<bool>("solve_log") : _perf_log),
    _setup_log(isParamValid("setup_log") ? getParam<bool>("setup_log") : _perf_log),
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
    _libmesh_log(getParam<bool>("libmesh_log")),
#endif
    _setup_log_early(getParam<bool>("setup_log_early")),
    _perf_header(isParamValid("perf_header") ? getParam<bool>("perf_header") : _perf_log),
    _all_variable_norms(getParam<bool>("all_variable_norms")),
    _outlier_variable_norms(getParam<bool>("outlier_variable_norms")),
    _outlier_multiplier(getParam<std::vector<Real> >("outlier_multiplier")),
    _timing(_app.getParam<bool>("timing"))
{
  // If --timing was used from the command-line, do nothing, all logs are enabled
  if (!_timing)
  {
    // Disable performance logging (all log input options must be false)
    if (!_perf_log && !_setup_log && !_solve_log && !_perf_header && !_setup_log_early)
    {
      Moose::perf_log.disable_logging();
      Moose::setup_perf_log.disable_logging();
    }

    // Disable libMesh log
#ifdef LIBMESH_ENABLE_PERFORMANCE_LOGGING
    if (!_libmesh_log)
      libMesh::perflog.disable_logging();
#endif
  }

  // Set output coloring
  if (getParam<bool>("use_color"))
  {
    char * term_env = getenv("TERM");
    if (term_env)
    {
      std::string term(term_env);
      if (term == "xterm-256color" || term == "xterm")
        _use_color = true;
    }
  }

  // If file output is desired, wipe out the existing file if not recovering
  if (_write_file && !_app.isRecovering())
    writeStream(false);
}
Exemple #15
0
void CViewSubSessionBase::ContactAtL(const RMessage2& aMessage) const
	{
	const TInt externalizedSize=iContact->ExternalizedSize();
	HBufC8* buf=HBufC8::NewLC(externalizedSize);
	TPtr8 bufPtr(buf->Des());
	RDesWriteStream writeStream(bufPtr);
	CleanupClosePushL(writeStream);
	writeStream << *iContact;
	bufPtr.SetLength(externalizedSize);
	aMessage.WriteL(0,*buf);
	CleanupStack::PopAndDestroy(2); // writeStream, buf.
	}
HBufC8* RContactRemoteView::PackageSortOrderLC(const RContactViewSortOrder& aSortOrder,TContactViewPreferences aContactTypes) const
    {
    TInt bufLength=aSortOrder.ExternalizedSize();
    bufLength+=sizeof(TContactViewPreferences);//
    HBufC8* buf=HBufC8::NewLC(bufLength);
    TPtr8 bufPtr(buf->Des());
    RDesWriteStream writeStream(bufPtr);
    writeStream << (TInt32&)aContactTypes;
    writeStream << aSortOrder;
    bufPtr.SetLength(bufLength);
    return buf;
    }
void CNSmlDummyDataProvider_Test::DoStoreFormatLL()
    {
    const CSmlDataStoreFormat& storeFormat = iCNSmlDummyDataProvider->DoStoreFormatL();
    EUNIT_PRINT( storeFormat.DisplayName() );
    EUNIT_PRINT( _L("Property count %d"), storeFormat.FolderPropertyCount() );
    CBufFlat* store = CBufFlat::NewL( 512 );
    CleanupStack::PushL( store );
    RBufWriteStream writeStream(*store, 0);
    CleanupClosePushL( writeStream );
    storeFormat.ExternalizeL( writeStream );
    CleanupStack::PopAndDestroy( 2, store );
    }
/**
Searches all contact items in the view for fields that contain the search
strings specified. 

@capability ReadUserData
@param aFindWords A descriptor array containing one or more search strings
@param aMatchedContacts On return, an array of matching contact items
@param find behaviour configuration uid to be passed to the server.
 */
void RContactRemoteView::ContactsMatchingCriteriaL(const MDesCArray& aFindWords, RPointerArray<CViewContact>& aMatchedContacts, TBool aPrefixSearch,TUid aUid)
    {
    if(aUid != KNullUid)
        {
        TIpcArgs args(aUid.iUid);
        User::LeaveIfError(SendReceive(ECntSendPluginUidToServer,args));
        }
    CBufBase* buffer = CBufFlat::NewL(32);
    CleanupStack::PushL(buffer);
    RBufWriteStream writeStream(*buffer);
    CleanupClosePushL(writeStream);

    writeStream.WriteUint32L(aPrefixSearch);
    const TInt count = aFindWords.MdcaCount();
    writeStream.WriteUint32L(count);
    for (TInt i=0; i<count; ++i)
        {
        TPtrC ptr = aFindWords.MdcaPoint(i);
        writeStream.WriteUint32L(ptr.Length());
        writeStream << ptr;
        }
    
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()

    TPtr8 ptr(buffer->Ptr(0));
    const TInt bufferSize = buffer->Size();
    TPckg<TInt> size(bufferSize);

    TPckgBuf<TInt> pckg;
    TIpcArgs args(&pckg,&size,&ptr);
    User::LeaveIfError(SendReceive(ECntContactMatchingCriteriaExternalizedSize,args));
    CleanupStack::PopAndDestroy(buffer);

    //Internalize Contacts
    HBufC8* buf=HBufC8::NewLC(pckg());
    TPtr8 contactsbufPtr(buf->Des());
    TIpcArgs args2(&contactsbufPtr);
    User::LeaveIfError(SendReceive(ECntGetContactMatchingCriteria,args2));

    RDesReadStream readStream(contactsbufPtr);
    CleanupClosePushL(readStream);
    const TInt findCount = readStream.ReadUint32L();
    for (TInt zz=0;zz<findCount;++zz)
        {
        CViewContact* thisContact = CViewContact::NewLC(KNullContactId);
        readStream >> *thisContact;
        aMatchedContacts.AppendL(thisContact);
        CleanupStack::Pop(thisContact);
        }
    CleanupStack::PopAndDestroy(2, buf);
    }
bool ossimOpjJp2Writer::writeFile()
{
   // This method is called from ossimImageFileWriter::execute().

   bool result = false;
   
   if( theInputConnection.valid() &&
       (getErrorStatus() == ossimErrorCodes::OSSIM_OK) )
   {

      // Make sure Area of Interest is an even multiple of tiles
      ossimIrect areaOfInterest = theInputConnection->getAreaOfInterest();
      ossimIpt imageSize(areaOfInterest.size());
      ossimIpt imageLr(areaOfInterest.lr());
      ossim_uint32 xBoundaryAdjustFactor = DEFAULT_TILE_SIZE.x - (imageSize.x % DEFAULT_TILE_SIZE.x);
      ossim_uint32 yBoundaryAdjustFactor = DEFAULT_TILE_SIZE.y - (imageSize.y % DEFAULT_TILE_SIZE.y);
      imageLr.x += xBoundaryAdjustFactor;
      imageLr.y += yBoundaryAdjustFactor;
      areaOfInterest.set_lr(imageLr); 
      theInputConnection->setAreaOfInterest(areaOfInterest);

      // Set the tile size for all processes.
      theInputConnection->setTileSize( DEFAULT_TILE_SIZE );
      theInputConnection->setToStartOfSequence();
      
      //---
      // Note only the master process used for writing...
      //---
      if(theInputConnection->isMaster())
      {
         if (!isOpen())
         {
            open();
         }
         
         if ( isOpen() )
         {
            result = writeStream();
         }
      }
      else // Slave process.
      {
         // This will return after all tiles for this node have been processed.
         theInputConnection->slaveProcessTiles();

         result = true;
      }
   }
      
   return result;
   
} // End: ossimOpjJp2Writer::writeFile()
Exemple #20
0
void CViewSubSession::GetSortOrderL(const RMessage2& aMessage) const
	{
	const RContactViewSortOrder& sortOrder=View().SortOrder();
	const TInt externalizedSize=sortOrder.ExternalizedSize();
	HBufC8* buf=HBufC8::NewLC(externalizedSize);
	TPtr8 bufPtr(buf->Des());
	RDesWriteStream writeStream(bufPtr);
	CleanupClosePushL(writeStream);
	writeStream << sortOrder;
	bufPtr.SetLength(externalizedSize);
	aMessage.WriteL(0,*buf);
	CleanupStack::PopAndDestroy(2); // writeStream, buf.
	}
Exemple #21
0
fbtBinTables* fbtBuilder::write(void)
{
	fbtMemoryStream ms;
	ms.open(fbtStream::SM_WRITE);
	m_writeMode = -1;

	writeStream(&ms);

	void* buffer = fbtMalloc(ms.size() + 1);
	fbtMemcpy(buffer, ms.ptr(), ms.size());

	return new fbtBinTables(buffer, ms.size());
}
/**
 Construct and delete a command using Internalise
*/ 
void CCmdTestLoadSup::CallInternalizeDataTestL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, TInt16 aRetries, const TSsmSupInfo& aInfo, const TUint16 aPriority)
	{
	// create a set of data and put it into a buffer
 	CBufFlat* bufferin = CBufFlat::NewL(1024);
	CleanupStack::PushL(bufferin);	
	
	// create write stream on buffer and put the data in
	RBufWriteStream writeStream(*bufferin);
	CleanupClosePushL(writeStream);		
	writeStream.WriteInt16L(aSeverity);
	writeStream.WriteInt8L(aExecutionBehaviour);
	aInfo.ExternalizeL(writeStream);
	writeStream.WriteInt16L(aRetries);
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	writeStream.WriteUint16L(aPriority);
#else
	TEST(aPriority == KDefaultPriority);
#endif
	writeStream.CommitL();

	// create a readstream on the data and put the data into the command
	RDesReadStream aReadStream(bufferin->Ptr(0));
	CleanupClosePushL(aReadStream);
	CCmdLoadSup* loadSupCmd = CCmdLoadSup::NewL(aReadStream);
	CleanupStack::PushL(loadSupCmd);

	TEST(loadSupCmd->Type() == ESsmCmdLoadSup);
		
	// create output buffer and stream
 	CBufFlat* bufferout = CBufFlat::NewL(1024);
	CleanupStack::PushL(bufferout);	
	RBufWriteStream writeStream2(*bufferout);
	CleanupClosePushL(writeStream2);		

	// externalise the data
	loadSupCmd->ExternalizeL(writeStream2);
	
	// check the data is correct
#ifdef SYMBIAN_SSM_FLEXIBLE_MERGE
	CompareInputAndOutputL(aSeverity, aExecutionBehaviour, aRetries, aInfo, bufferout, aPriority);
#else
	CompareInputAndOutputL(aSeverity, aExecutionBehaviour, aRetries, aInfo, bufferout);
#endif
	
	CleanupStack::PopAndDestroy(&writeStream2);
	CleanupStack::PopAndDestroy(bufferout);	
	CleanupStack::PopAndDestroy(loadSupCmd);
	CleanupStack::PopAndDestroy(&aReadStream);
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(bufferin);	
	}
Exemple #23
0
bool SGFParser::exportSGFtoClipB(QString *str, Tree *tree)
{
	CHECK_PTR(tree);
	
	if (stream != NULL)
		delete stream;
	stream = new QTextStream(str, IO_WriteOnly);
	
	bool res = writeStream(tree);
	
	delete stream;
	stream = NULL;
	return res;
}
Exemple #24
0
/*
 * takes a game tree, and puts it in SGF format
 */
bool SGFParser::exportSGFtoClipB(QString *str, Tree *tree, GameData *gd)
{
	Q_CHECK_PTR(tree);
	
	if (stream != NULL)
		delete stream;
	stream = new QTextStream(str, QIODevice::WriteOnly);
	
	bool res = writeStream(tree,gd);
	
	delete stream;
	stream = NULL;
	return res;
}
void tst_QWidgetsVariant::writeToReadFromDataStream()
{
    QFETCH( QVariant, writeVariant );
    QFETCH( bool, isNull );
    QByteArray data;

    QDataStream writeStream( &data, QIODevice::WriteOnly );
    writeStream << writeVariant;

    QVariant readVariant;
    QDataStream readStream( &data, QIODevice::ReadOnly );
    readStream >> readVariant;
    QVERIFY( readVariant.isNull() == isNull );
}
void CCmdTestLoadSup::doTestResourceReaderWithGoodDataL()
	{
	TInt err = KErrNone;
	TInt expectedErr = KErrNone;
	// these values must match what is in the resource file
	TCmdErrorSeverity severity = ECmdCriticalSeverity;
	TSsmExecutionBehaviour executionBehaviour = ESsmWaitForSignal;

	TUid uid;
	uid.iUid = 0;
	TInt32 ordinal = 1;
	TInt16 retries = 5;
		
	TSsmSupInfo info;
	info.SetL(KFileName, ordinal, uid);

	INFO_PRINTF1(_L("Test:doTestResourceReaderWithGoodDataL:01 Test: ExternalizeL"));

	// open reader on contents
	RResourceReader& reader = LoadResourcesL(KRscFileBuffer, R_COMMAND_LOAD_SUP1);  
	
	// construct command
	TSsmCommandParameters params(reader, NULL, 0);
	CCmdLoadSup* loadSupCmd = CCmdLoadSup::NewL(params);
	CleanupStack::PushL(loadSupCmd);

	TEST(loadSupCmd->Type() == ESsmCmdLoadSup);
		
	// create output buffer
 	CBufFlat* writebuf = CBufFlat::NewL(1024);
	CleanupStack::PushL(writebuf);	
	
	// create output stream on buffer
	RBufWriteStream writeStream(*writebuf);
	CleanupClosePushL(writeStream);	

	// externalise the data
	TRAP(err, loadSupCmd->ExternalizeL(writeStream));
	INFO_PRINTF3(_L("ExternalizeL completed with err : %d. expected err : %d"), err, expectedErr);
	TEST(err == expectedErr);

	// check the data is correct
	CompareInputAndOutputL(severity, executionBehaviour, retries, info, writebuf);
	
	CleanupStack::PopAndDestroy(&writeStream);
	CleanupStack::PopAndDestroy(writebuf);	
	CleanupStack::PopAndDestroy(loadSupCmd);
	FreeResources();	
	}
void CMultiThreadTestApp::SynchEntryL(CCalEntryView& aView)
	{
	FetchEntryL(aView, iEntries);
	if(iEntries.Count()>0)
		{
		_LIT(KExportFile,"Multithread_export");
		RFile outFile;
		TestRegister().CreateTempFileLC(outFile, KExportFile);
		RFileWriteStream writeStream(outFile);
		CleanupClosePushL(writeStream);
		DataExchangeL().ExportAsyncL(KUidVCalendar, writeStream, iEntries, *this);
		CActiveScheduler::Start();
		CleanupStack::PopAndDestroy(2, &outFile); // outFile.Close(), writeStream.Close()
		}
	}
Exemple #28
0
void fbtBuilder::writeFile(const fbtId& id, fbtStream* fp)
{
	if (!fp)
		return;

	fp->writef("unsigned char %sFBT[]={\n", id.c_str());

	m_writeMode = 0;
	writeStream(fp);


	fp->writef("\n};\n");
	fp->writef("int %sLen=sizeof(%sFBT);\n", id.c_str(), id.c_str());

}
Exemple #29
0
/** Export contact items specified by aIds to aFileName */
void CAgentTest::ExportContactsL(const TDesC& aFileName)
	{
	RFile outfile;
	outfile.Replace(iTest.Fs(),aFileName,EFileWrite);
	CleanupClosePushL(outfile);
	RFileWriteStream writeStream(outfile);
	CleanupClosePushL(writeStream);
	
	TUid uid;
	uid.iUid=KUidVCardConvDefaultImpl;
	iDb->ExportSelectedContactsL(uid,*iIdArray,writeStream,CContactDatabase::EDefault);

	writeStream.CommitL();
	CleanupStack::PopAndDestroy(2); //writeStream.Close(), outfile.Close()
	}
Exemple #30
0
bool SaveConverter::createStream(SaveWriter &writer) {
    // Allocate memory for the internal new save data
    uint32 contSize = writer.getSize();
    _data = new byte[contSize];

    // Save the newly created new save data
    Common::MemoryWriteStream writeStream(_data, contSize);
    if (!writer.save(writeStream))
        return false;

    // Create a reading stream upon that new save data
    _stream = new Common::MemoryReadStream(_data, contSize);

    return true;
}