本文整理汇总了C++中CFileReader类的典型用法代码示例。如果您正苦于以下问题:C++ CFileReader类的具体用法?C++ CFileReader怎么用?C++ CFileReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CFileReader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RestorePlanFromDXLFile
Datum
RestorePlanFromDXLFile(PG_FUNCTION_ARGS)
{
char *szFilename = textToString(PG_GETARG_TEXT_P(0));
CFileReader fr;
fr.Open(szFilename);
ULLONG ullSize = fr.UllSize();
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize + 1);
fr.UlpRead((BYTE*)pcBuf, ullSize);
pcBuf[ullSize] = '\0';
fr.Close();
int iProcessed = executeXMLPlan(pcBuf);
elog(NOTICE, "Processed %d rows.", iProcessed);
gpdb::GPDBFree(pcBuf);
StringInfoData str;
initStringInfo(&str);
appendStringInfo(&str, "Query processed %d rows", iProcessed);
text *ptResult = stringToText(str.data);
PG_RETURN_TEXT_P(ptResult);
}
示例2: RestoreQueryFromFile
Datum
RestoreQueryFromFile(PG_FUNCTION_ARGS)
{
char *szFilename = text_to_cstring(PG_GETARG_TEXT_P(0));
CFileReader fr;
fr.Open(szFilename);
ULLONG ullSize = fr.UllSize();
elog(NOTICE, "(RestoreFromFile) Filesize is " UINT64_FORMAT, (uint64) ullSize);
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize);
fr.UlpRead((BYTE*)pcBuf, ullSize);
fr.Close();
int iBinaryLen;
memcpy(&iBinaryLen, pcBuf, sizeof(int));
Assert(iBinaryLen == ullSize - sizeof(int));
elog(NOTICE, "(RestoreFromFile) BinaryLen is %d", iBinaryLen);
char *pcBinary = pcBuf + sizeof(int);
int iProcessed = extractFrozenQueryPlanAndExecute(pcBinary);
elog(NOTICE, "(RestorePlan) PROCESSED %d", iProcessed);
StringInfoData str;
initStringInfo(&str);
appendStringInfo(&str, "Query processed %d rows", iProcessed);
text *ptResult = cstring_to_text(str.data);
PG_RETURN_TEXT_P(ptResult);
}
示例3: EvalExprFromDXLFile
Datum
EvalExprFromDXLFile(PG_FUNCTION_ARGS)
{
char *szFileName = textToString(PG_GETARG_TEXT_P(0));
CFileReader fr;
fr.Open(szFileName);
ULLONG ullSize = fr.UllSize();
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize + 1);
fr.UlpRead((BYTE*)pcBuf, ullSize);
fr.Close();
pcBuf[ullSize] = '\0';
char *szResultDXL = COptTasks::SzEvalExprFromXML(pcBuf);
gpdb::GPDBFree(pcBuf);
if (NULL != szResultDXL)
{
text *ptResult = stringToText(szResultDXL);
gpdb::GPDBFree(szResultDXL);
PG_RETURN_TEXT_P(ptResult);
}
else
{
// Return a dummy value so the tests can continue
PG_RETURN_NULL();
}
}
示例4: RestorePlanFromFile
Datum
RestorePlanFromFile(PG_FUNCTION_ARGS)
{
char *szFilename = textToString(PG_GETARG_TEXT_P(0));
CFileReader fr;
fr.Open(szFilename);
ULLONG ullSize = fr.UllSize();
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize);
fr.UlpRead((BYTE*)pcBuf, ullSize);
fr.Close();
int iBinaryLen;
memcpy(&iBinaryLen, pcBuf, sizeof(int));
Assert(iBinaryLen == ullSize - sizeof(int));
char *pcBinary = pcBuf + sizeof(int);
int iProcessed = extractFrozenPlanAndExecute(pcBinary);
elog(NOTICE, "Processed %d rows.", iProcessed);
gpdb::GPDBFree(pcBuf);
StringInfoData str;
initStringInfo(&str);
appendStringInfo(&str, "Query processed %d rows", iProcessed);
text *ptResult = stringToText(str.data);
PG_RETURN_TEXT_P(ptResult);
}
示例5: new
// -----------------------------------------------------------------------------
// CFileReader::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CFileReader* CFileReader::NewL(RFile& aFile, TInt aChunkSize, FileConnection* aFileConnection)
{
CFileReader* self = new( ELeave ) CFileReader( aFile, aChunkSize, aFileConnection );
CleanupStack::PushL( self );
self->ConstructL();
CleanupStack::Pop();
return self;
}
示例6:
char *read_file(const char *szFilename)
{
CFileReader fr;
fr.Open(szFilename);
ULLONG ullSize = fr.UllSize();
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize);
fr.UlpRead((BYTE*)pcBuf, ullSize);
pcBuf[ullSize] = '\0';
fr.Close();
return pcBuf;
}
示例7: OnReadJpeg
LRESULT CMainFrame::OnReadJpeg( WPARAM wParam, LPARAM lParam )
{
int nSegmentCount = 0;
CSegmentData *lpSegmentData = NULL;
CSegmentInfo *lpSegmentInfo = NULL;
CFileReader FileReader;
CJpegAnalyzer JpegAnalyzer;
CUserDatas* lpUserDatas = ((CIFuzzMakerDoc*)GetActiveDocument())->GetUserDatas();
lpUserDatas->GetReadBufferArray().RemoveAll();
if( !FileReader.ReadFile( lpUserDatas->GetJpegFileName(), lpUserDatas->GetReadBufferArray() ) )
{
// エラー
return FALSE;
}
// Jpeg解析
lpUserDatas->GetSegmentDataArray().RemoveAllWithDelete();
if( !JpegAnalyzer.Analyze( lpUserDatas->GetReadBufferArray(), m_FixedDatas.GetSegmentInfoMap(), lpUserDatas->GetSegmentDataArray() ) )
return FALSE;
// Exif解析
for(nSegmentCount=0; nSegmentCount<lpUserDatas->GetSegmentDataArray().GetSize(); nSegmentCount++ )
{
lpSegmentData = lpUserDatas->GetSegmentDataArray().GetAt( nSegmentCount );
if( lpSegmentData )
{
lpSegmentInfo = lpSegmentData->GetSegmentInfo();
if( lpSegmentInfo )
{
if( lpSegmentInfo->GetMarker() == _T("FFE1") )
{
CExifAnalyzer ExifAnalyzer;
ExifAnalyzer.Analyze( lpUserDatas->GetReadBufferArray().GetSize(), lpSegmentData, &m_FixedDatas.GetImageFileDirectoryInfoMap(), &m_FixedDatas.GetTagTypeInfoMap() );
}
if( lpSegmentInfo->IsAnalysisSegment() )
{
CSegmentAnalyzer SegmentAnalyzer;
SegmentAnalyzer.Analyze( lpUserDatas->GetReadBufferArray().GetSize(), lpSegmentData );
}
}
}
}
SendMessageToDescendants( WM_APP_EXIF_ANALYZED, NULL, NULL );
return TRUE;
}
示例8: DumpQueryFromFileToDXLFile
Datum
DumpQueryFromFileToDXLFile(PG_FUNCTION_ARGS)
{
char *szSqlFilename = textToString(PG_GETARG_TEXT_P(0));
char *szFilename = textToString(PG_GETARG_TEXT_P(1));
CFileReader fr;
fr.Open(szSqlFilename);
ULLONG ullSize = fr.UllSize();
char *pcBuf = (char*) gpdb::GPDBAlloc(ullSize + 1);
fr.UlpRead((BYTE*)pcBuf, ullSize);
pcBuf[ullSize] = '\0';
fr.Close();
int iLen = translateQueryToFile(pcBuf, szFilename);
gpdb::GPDBFree(pcBuf);
PG_RETURN_INT32(iLen);
}
示例9: CFileReader
//=============================================================================
// 初期化
// ここでsin,cosそれぞれのテーブルを作成
//=============================================================================
void CRadianTable::Init()
{
CFileReader* sinReader = new CFileReader();
CFileReader* cosReader = new CFileReader();
cosReader->FileOpen("data/radianTable/cosTable.txt", "r");
sinReader->FileOpen("data/radianTable/sinTable.txt", "r");
char* sinBuff = new char[256];
char* cosBuff = new char[256];
for (int count = 0; count < TABELE_MAX; count++)
{
sinReader->GetLine(sinBuff);
cosReader->GetLine(cosBuff);
sinTable[count] = (float)atof(sinBuff);
cosTable[count] = (float)atof(cosBuff);
}
SAFE_DELETE(sinBuff);
SAFE_DELETE(cosBuff);
SAFE_DELETE(sinReader);
SAFE_DELETE(cosReader);
}
示例10: GPOS_ASSERT
//---------------------------------------------------------------------------
// @function:
// COstreamFileTest::Unittest_CheckOutputFile
//
// @doc:
// Check the contents of the file used by the output stream
//
//---------------------------------------------------------------------------
void
COstreamFileTest::Unittest_CheckOutputFile
(
const CHAR *szFile
)
{
GPOS_ASSERT(NULL != szFile);
CFileReader fr;
fr.Open(szFile);
const ULONG ulReadBufferSize = 1024;
WCHAR wszReadBuffer[ulReadBufferSize];
#ifdef GPOS_DEBUG
ULONG_PTR ulpRead =
#endif // GPOS_DEBUG
fr.UlpRead((BYTE *) wszReadBuffer, GPOS_ARRAY_SIZE(wszReadBuffer));
CWStringConst strExpected(GPOS_WSZ_LIT("WC102-10some regular stringdeadbeef"));
GPOS_ASSERT(ulpRead == (ULONG_PTR) strExpected.UlLength() * GPOS_SIZEOF(WCHAR));
GPOS_ASSERT(strExpected.FEquals(&strExpected));
}
示例11: Encode
int Encode (CFileReader &p_coFileReader)
{
int iRetVal = 0;
XML_Parser psoParser;
psoParser = XML_ParserCreate ("UTF-8");
if (NULL == psoParser) {
iRetVal = ENOMEM;
return iRetVal;
}
SDoc soDoc;
/* регистрация обработчика данных */
XML_SetElementHandler (psoParser, StartElementHandler, EndElementHandler);
XML_SetXmlDeclHandler (psoParser, XmlDeclHandler);
XML_SetDoctypeDeclHandler (psoParser, StartDoctypeDeclHandler, EndDoctypeDeclHandler);
XML_SetUserData (psoParser, &soDoc);
/* парсинг данных */
char mcBuf[256];
int iDataLen;
int iIsFinal = 0;
do {
iDataLen = sizeof (mcBuf);
if (p_coFileReader.ReadData ((unsigned char*)mcBuf, iDataLen))
iIsFinal = 1;
XML_Parse (psoParser, mcBuf, iDataLen, iIsFinal);
if (iIsFinal)
break;
} while (1);
Tokenize (soDoc);
if (psoParser) {
XML_ParserFree (psoParser);
psoParser = NULL;
}
return iRetVal;
}
示例12: INFO_PRINTF1
TVerdict CSymmetricCipherObjectReuseStep::doTestStepL()
{
INFO_PRINTF1(_L("*** Symmetric Cipher - Object Reuse ***"));
INFO_PRINTF2(_L("HEAP CELLS: %d"), User::CountAllocCells());
if (TestStepResult()==EPass)
{
//Assume failure, unless all is successful
SetTestStepResult(EFail);
TPtrC keyPath;
TPtrC srcPath;
TVariantPtrC algorithm;
TVariantPtrC operationMode;
TVariantPtrC paddingMode;
if( !GetStringFromConfig(ConfigSection(),KConfigEncryptKey, keyPath) ||
!GetStringFromConfig(ConfigSection(),KConfigSourcePath, srcPath) ||
!GetStringFromConfig(ConfigSection(),KConfigAlgorithmUid, algorithm) ||
!GetStringFromConfig(ConfigSection(),KConfigOperationMode, operationMode) ||
!GetStringFromConfig(ConfigSection(),KConfigPaddingMode, paddingMode ))
{
User::Leave(KErrNotFound);
}
else
{
//Create an instance of TKeyProperty
TKeyProperty keyProperty;
//Load the key data using the
CFileReader* keyData = CFileReader::NewLC(keyPath);
CCryptoParams* params = CCryptoParams::NewLC();
params->AddL( *keyData, KSymmetricKeyParameterUid);
CKey* key=CKey::NewL(keyProperty, *params);
CleanupStack::PushL(key);
CCryptoParams* xparams = NULL;
if (TUid(algorithm) == KArc4Uid)
{
//Set the RC4 DiscardBytes to 0
xparams = CCryptoParams::NewL();
xparams->AddL(NULL, KARC4DiscardBytes);
CleanupStack::PushL(xparams);
}
if (TUid(algorithm) == KRc2Uid)
{
TInt keylen = TPtrC8(*keyData).Length() * 8;
xparams = CCryptoParams::NewLC();
//Set the RC2 EffectiveKeyLen according to the input key size
xparams->AddL( keylen, KRC2EffectiveKeyLenBits);
}
INFO_PRINTF1(_L("Creating Symmetric Cipher Object..."));
// Create a Symmetric Cipher with the values from the ini config file
CryptoSpi::CSymmetricCipher * impl = NULL;
TRAPD(err,CSymmetricCipherFactory::CreateSymmetricCipherL
(
impl,
algorithm,
*key,
KCryptoModeEncryptUid,
operationMode,
paddingMode,
xparams));
if(impl && (err == KErrNone))
{
CleanupStack::PushL(impl);
const TInt KObjectReuseItterations = 5; // 5 iterations should be enough to check the object reuse feature
// the no of iteration is reduced, to reduce the time taken for execution
//Boolean to denote the state
TBool testPass = ETrue;
/*************** Encrypt/Decrypt Reuse Loop ****************/
for(TInt index = 0; index < KObjectReuseItterations; index++)
{
INFO_PRINTF3(_L("i=%d : START HEAP CELLS: %d"),index, User::CountAllocCells());
//-----RESET IMPLEMENTATION OBJECT (NORMAL LOGGING)----------
impl->Reset();
TRAP(err,impl->SetKeyL(*key));
if(err != KErrNone)
{
ERR_PRINTF3(_L("*** ERROR:%d - SetKeyL() i=%d ***"),err,index);
User::Leave(err);
}
TRAP(err,impl->SetCryptoModeL(KCryptoModeEncryptUid));
//.........这里部分代码省略.........
示例13: CT2A
//.........这里部分代码省略.........
}else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_32_LITTLE )
{
nDecValueInteger = (unsigned int)strtoul( szValue, NULL, 10 );
nDecValueInteger = CEndianConverter::ConvertToInteger( (unsigned char*)&nDecValueInteger, FALSE );
BinaryDataArray.SetSize( sizeof(nDecValueInteger) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) );
lpBuffer = BinaryDataArray.GetData();
for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ )
{
CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueInteger)], &nDecValueInteger, sizeof(nDecValueInteger) );
}
}else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_DEC_32_BIG )
{
nDecValueInteger = (unsigned int)strtoul( szValue, NULL, 10 );
nDecValueInteger = CEndianConverter::ConvertToInteger( (unsigned char*)&nDecValueInteger, TRUE );
BinaryDataArray.SetSize( sizeof(nDecValueInteger) * (!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()) );
lpBuffer = BinaryDataArray.GetData();
for( int nRepeat=0; nRepeat<(!lpPatternInfo->GetRepeat()?1:lpPatternInfo->GetRepeat()); nRepeat++ )
{
CopyMemory( &lpBuffer[nRepeat*sizeof(nDecValueInteger)], &nDecValueInteger, sizeof(nDecValueInteger) );
}
}else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_HEX )
{
//
BinaryDataArray.SetSize( (int)(szValue.GetLength()/2) );
for( int cCnt=0; cCnt<(int)(szValue.GetLength()/2); cCnt++ )
{
unsigned int nVal = strtol( szValue.Mid( cCnt*2, 2 ),NULL,16 );
BinaryDataArray.SetAt(cCnt, nVal);
}
}else if( lpPatternInfo->GetDataType() == CPatternData::DATATYPE_BIN )
{
//
CFileReader fl;
if( !fl.ReadFile( lpPatternInfo->GetFileName(), BinaryDataArray ) )
continue;
}
lpPatternGroupData->GetPatternDataArray()->AddWithNew( lpPatternData );
lpPatternData->SetCheck( lpPatternInfo->GetSelectFlag() );
lpPatternData->SetDispName( lpPatternInfo->GetDispName() );
lpPatternData->SetDataType( lpPatternInfo->GetDataType() );
lpPatternData->SetValue( lpPatternInfo->GetValue() );
lpPatternData->SetRepeat( lpPatternInfo->GetRepeat() );
lpPatternData->SetWriteMode( lpPatternInfo->GetWriteMode() );
lpPatternData->SetFuzzArea( lpPatternInfo->GetFuzzArea() );
lpPatternData->SetSearchField( lpPatternInfo->GetSearchField() );
lpPatternData->SetFieldKey( lpPatternInfo->GetFieldKey() );
lpPatternData->SetDescription( lpPatternInfo->GetDescription() );
lpPatternData->SetBinaryDataArray( BinaryDataArray );
if( lpPatternInfo->GetFuzzArea() == CPatternData::FUZZAREA_FILE )
{
TCHAR* endptr = NULL;
int nFilePos = _tcstol( lpPatternInfo->GetFieldKey(), &endptr, 10 );
if( _tcslen(endptr) )
continue;
lpPatternData->SetFilePos( nFilePos );
}
if( lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_TAG ||
lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_TYPE ||
lpPatternData->GetSearchField() == CPatternData::SEARCHFIELD_SEGMENT )
{
POSITION pos = NULL;
CString szKey;
示例14: WinMain
//.........这里部分代码省略.........
//fire control transitions
g_pStateFireControl->addTransitionEvent(EVENT_GO_SONAR, g_pStateSonar);
g_pStateFireControl->addTransitionEvent(EVENT_GO_RADAR, g_pStateRadar);
g_pStateFireControl->addTransitionEvent(EVENT_GO_STATUS, g_pStateStatus);
g_pStateFireControl->addTransitionEvent(EVENT_GO_CHART, g_pStateChart);
g_pStateFireControl->addTransitionEvent(EVENT_GO_CONTROL, g_pStateControl);
//status transitions
g_pStateStatus->addTransitionEvent(EVENT_GO_SONAR, g_pStateSonar);
g_pStateStatus->addTransitionEvent(EVENT_GO_RADAR, g_pStateRadar);
g_pStateStatus->addTransitionEvent(EVENT_GO_FIRECONTROL, g_pStateFireControl);
g_pStateStatus->addTransitionEvent(EVENT_GO_CHART, g_pStateChart);
g_pStateStatus->addTransitionEvent(EVENT_GO_CONTROL, g_pStateControl);
//chart transitions
g_pStateChart->addTransitionEvent(EVENT_GO_SONAR, g_pStateSonar);
g_pStateChart->addTransitionEvent(EVENT_GO_RADAR, g_pStateRadar);
g_pStateChart->addTransitionEvent(EVENT_GO_FIRECONTROL, g_pStateFireControl);
g_pStateChart->addTransitionEvent(EVENT_GO_STATUS, g_pStateStatus);
g_pStateChart->addTransitionEvent(EVENT_GO_CONTROL, g_pStateControl);
g_pStateChart->addTransitionEvent(EVENT_GO_WIN, g_pStateWin);
g_pStateChart->addTransitionEvent(EVENT_GO_LOSE, g_pStateLose);
g_Timer.initialize();
g_LoopTimer.initialize();
g_FPS_Timer.initialize();
g_con.InitD3D (g_hWnd, g_Global.g_WindowedMode);
//***********************************************************************
//load textures from graphics file
// G R A P H I C F I L E S . D A T
//***********************************************************************
pLog->Log("************ Graphicfiles.dat ************");
CFileReader* cfr = new CFileReader;
cfr->LoadFile("data\\graphicfiles.dat");
int fileNumber;
std::string fileName;
if(cfr->IsValid()== true){
pLog->Log("Numbers of lines in file",cfr->GetNumberOfLines());
for(int j=0; j< cfr->GetNumberOfLines();j++){
sValue =cfr->GetTerm(cfr->GetLineFromFile(j),1);
fileNumber = atoi(sValue.c_str());
sValue = cfr->GetTerm(cfr->GetLineFromFile(j),2);
fileName = "assets\\artwork\\";
fileName = fileName + sValue;
//pLog->Log("Loaded file",fileName);
pLog->Log(fileName, fileNumber);
g_con.LoadTexture(fileName, fileNumber);
}
}
else{
pLog->Log("ERROR****************** Failure to load textures (graphicfiles.dat)");
delete cfr;
g_con.CloseD3D();
pLog->Log("DirectX closed!");
Shutdown();
return 0;
}
if(g_Sprite.LoadSprites() == true){
pLog->Log("Sprites loaded!");
}
else{
pLog->Log("ERROR****************** Failure to sprite data (sprites.dat)");
}