本文整理汇总了C++中TStringList::LoadFromStream方法的典型用法代码示例。如果您正苦于以下问题:C++ TStringList::LoadFromStream方法的具体用法?C++ TStringList::LoadFromStream怎么用?C++ TStringList::LoadFromStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStringList
的用法示例。
在下文中一共展示了TStringList::LoadFromStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
Synchronize(&PostConfirmMessageForm);
goto LabelError;
}
//-----------------------------------
// 復号の準備
//-----------------------------------
bf = new CBlowFish;
bf->Initialize( KeyString.c_str(), KeyString.Length() ); //初期化
//-----------------------------------
// 暗号部ヘッダの復号(ECBモード)
//-----------------------------------
pms = new TMemoryStream;
len = 0;
while (len < EncryptHeaderSize) {
// 読み出しバッファ
for (c = 0; c < BUF_SIZE; c++) {
source_buffer[c] = 0;
}
// 暗号化されたデータブロックの読み出し
len += fsIn->Read(source_buffer, BUF_SIZE);
// 復号処理
bf->Decode( source_buffer, buffer, BUF_SIZE);
pms->Write(buffer, BUF_SIZE);
}
pms->Seek((__int64)0, TSeekOrigin::soBeginning); //ポインタを先頭へ戻す
DataList = new TStringList;
DataList->LoadFromStream(pms, TEncoding::GetEncoding(932)); // shift-jis
//-----------------------------------
// 復号正否(復号できたか)
//-----------------------------------
if (DataList->Count == 0 || DataList->Strings[0].Pos("AttacheCase") == 0) {
fPasswordOk = false;
}
else{
fPasswordOk = true; //パスワード合致
}
if ( fPasswordOk == false ) {
//'パスワードがちがいます。復号できません。'+#13+
//'場合によってはファイルが壊れている可能性もあります。';
MsgText = LoadResourceString(&Msgdecrypt::_MSG_ERROR_PASSWORD_WRONG);
MsgType = mtError;
MsgButtons = TMsgDlgButtons() << mbOK;
MsgDefaultButton = mbOK;
Synchronize(&PostConfirmMessageForm);
delete DataList;
goto LabelTypeMiss;
}
//-----------------------------------
// 復号時のエンコーディング判定
//-----------------------------------
pms->Position = 0;
DataList->LoadFromStream(pms, TEncoding::GetEncoding(932)); // shift-jis
//===================================
示例2: THandleStream
//====================================================================
bool reg1test::importReg1test()
{
//Create and Open File Stream
try
{
THandleStream * hs = new THandleStream( ( int ) regContestFile );
TStringList *sl = new TStringList;
sl->LoadFromStream( hs );
if ( !sl->Count )
{
return false;
}
enum reg1Stage {sStart, sHeader, sRemarks, sQSOs} stage = sStart;
int nq = 0;
int qcount = 0;
// and here wade our way through
for ( int lineno = 0; lineno < sl->Count; lineno++ )
{
String line = sl->Strings[ lineno ].Trim();
if ( line.Length() == 0 )
{
continue;
}
if ( stage == sStart && line == "[REG1TEST;1]" )
{
stage = sHeader;
continue;
}
if ( stage == sHeader && line == "[Remarks]" )
{
stage = sRemarks;
continue;
}
if ( stage == sRemarks && line.SubString( 1, 12 ) == "[QSORecords;" )
{
for ( int i = remarks.size(); i < 4; i++ )
{
remarks.push_back( "" );
}
ct->entCondx1.setValue( remarks[ 0 ] );
ct->entCondx2.setValue( remarks[ 1 ] );
ct->entCondx3.setValue( remarks[ 2 ] );
ct->entCondx4.setValue( remarks[ 3 ] );
stage = sQSOs;
nextBlock = 0;
int endq = line.Pos( "]" );
if ( endq == 0 )
{
return false;
}
String snq = line.SubString( 13, endq - 13 );
nq = snq.ToIntDef( 0 );
if ( !nq )
{
return false;
}
continue;
}
switch ( stage )
{
case sStart:
{
// wait for the start - in case we have an email lead in
}
break;
case sHeader:
{
// parse out the header line and fill in the contest details
if ( !parseHeader( line ) )
return false;
}
break;
case sRemarks:
{
// read the remarks lines while they still come...
if ( !parseRemark( line ) )
return false;
}
break;
case sQSOs:
{
// parse out the QSO
if ( !parseQSO( line ) )
{
return false;
}
qcount++;
if ( nq == qcount )
{
return true;
}
//.........这里部分代码省略.........
示例3: LoadHexToRAM
bool __fastcall TMainForm::LoadHexToRAM(String fName, bool bLow)
{
// Load all the text lines from the .hex file into a String List for easy
// manipulation
TStringList *sList = new TStringList;
if (fName.Pos("VendAX")) {
GetVendAX(sList);
} else {
TFileStream *srcStream = new TFileStream(fName,fmOpenRead | fmShareDenyWrite);
if (srcStream == NULL) return false;
sList->LoadFromStream(srcStream);
delete srcStream;
}
String tmp;
int v;
// Delete non-data records
for (int i=sList->Count - 1; i>=0; i--) {
if (sList->Strings[i].Length()) {
tmp = sList->Strings[i].SubString(8,2); // Get the Record Type into v
v = 0; HexToBin(tmp.c_str(),(char *)&v,1); v *= 2;
if (v) sList->Delete(i); // Data records are type == 0
}
}
// Re-construct the strings to only contain the offset followed by the data
for (int i=0; i<sList->Count; i++) {
// Remove comments
v = sList->Strings[i].Pos("//");
if (v) sList->Strings[i].SetLength(v-1);
// Build string that just contains the offset followed by the data bytes
if (sList->Strings[i].Length()) {
// Get the offset
String sOffset = sList->Strings[i].SubString(4,4);
// Get the string of data chars
tmp = sList->Strings[i].SubString(2,2);
v = 0; HexToBin(tmp.c_str(),(char *)&v,1); v *= 2;
String s = sList->Strings[i].SubString(10,v);
// Replace the string in the list
sList->Strings[i] = sOffset + s;
}
}
if (bLow) ResetFX2(1); // Stop the processor
FX2Device->ControlEndPt->ReqCode = bLow ? 0xA0 : 0xA3;
FX2Device->ControlEndPt->Index = 0;
FX2Device->ControlEndPt->Value = 0;
// Go through the list, loading data into RAM
String DataString = "";
WORD nxtoffset = 0;
LONG xferLen = 0;
WORD offset;
int RamSize = 0x2000; // 8KB
UCHAR buf[MAX_CTLXFER_SIZE];
char c;
PCHAR pc;
for (int i=0; i<sList->Count; i++) {
// Get the offset
tmp = sList->Strings[i].SubString(1,4);
HexToBin(tmp.c_str(),(char *)&offset,2);
pc = (char *) &offset; c = pc[0]; pc[0]=pc[1]; pc[1]=c; // Swap the bytes
int sLen = sList->Strings[i].Length();
// Handle a line that straddles the 8KB boundary
int bytes = (sLen - 4)/2;
LONG lastAddr = offset + bytes;
// This case is the last segment to be sent to low memory
if (bLow && (offset < RamSize) && (lastAddr > RamSize))
bytes = RamSize - offset;
// In this case, we found the first segment to be sent to the high memory
if (!bLow && (offset < RamSize) && (lastAddr > RamSize)) {
bytes = lastAddr - RamSize;
String s = "xxxx"+sList->Strings[i].SubString(sLen - (bytes*2)+1,bytes*2);
sList->Strings[i] = s;
offset = RamSize;
}
if ((bLow && (offset < RamSize)) || // Below 8KB - internal RAM
(!bLow && (offset >= RamSize)) ) {
xferLen += bytes;
if ((offset == nxtoffset) && (xferLen < MAX_CTLXFER_SIZE)) {
//.........这里部分代码省略.........
示例4: if
//.........这里部分代码省略.........
fsIn->Read(chain_buffer, BUF_SIZE);
len = 0;
while (len < EncryptHeaderSize) {
// 読み出しバッファ
for (c = 0; c < BUF_SIZE; c++) {
source_buffer[c] = 0;
}
// 暗号化されたデータブロックの読み出し
len += fsIn->Read(source_buffer, BUF_SIZE);
for (c = 0; c < BUF_SIZE; c++) {
// あとのxorのためによけておく
temp_buffer[c] = source_buffer[c];
}
// 復号処理
rijndael_decrypt(source_buffer);
// xor
for (c = 0; c < BUF_SIZE; c++) {
source_buffer[c] ^= chain_buffer[c];
chain_buffer[c] = temp_buffer[c]; // CBC
}
pms->Write(source_buffer, BUF_SIZE);
}
pms->Seek((__int64)0, TSeekOrigin::soBeginning); //ポインタを先頭へ戻す
DataList = new TStringList;
DataList->LoadFromStream(pms, TEncoding::GetEncoding(932)); // shift-jis
//-----------------------------------
// 復号正否(復号できたか)
//-----------------------------------
//MsgText = DataList->Strings[0];
//MsgType = mtError;
//MsgButtons = TMsgDlgButtons() << mbOK;
//MsgDefaultButton = mbOK;
//Synchronize(&PostConfirmMessageForm);
if (DataList->Count == 0 || DataList->Strings[0].Pos("AttacheCase") == 0) {
fPasswordOk = false;
}
else{
fPasswordOk = true; //パスワード合致
}
if ( fPasswordOk == false ) {
//'パスワードがちがいます。復号できません。'+#13+
//'場合によってはファイルが壊れている可能性もあります。';
MsgText = LoadResourceString(&Msgdecrypt::_MSG_ERROR_PASSWORD_WRONG);
if ( fCompare == true ) {
//メッセージに'コンペアに失敗しました。'を追加
MsgText += "\n" + LoadResourceString(&Msgdecrypt::_MSG_ERROR_COMPARE_FILE);
}
MsgType = mtError;
MsgButtons = TMsgDlgButtons() << mbOK;
MsgDefaultButton = mbOK;
Synchronize(&PostConfirmMessageForm);
delete DataList;
goto LabelTypeMiss;
示例5: importLOG
bool LoggerContestLog::importLOG( HANDLE hLogFile )
{
THandleStream * hs = new THandleStream( ( int ) hLogFile );
TStringList *ls = new TStringList();
ls->LoadFromStream( hs );
TEMPBUFF( temp, 100 );
// Import from LOG format
// Needs modification for "new" log format
locValid = false;
// save();
// read remainder of lines; write each line as we go
long next_block = 1;
bool started = false;
DisplayContestContact *ct = 0;
int lineNo = -1;
while ( ++lineNo < ls->Count )
{
// skip new format header information, until we can cope
// properly with it
std::string stemp = trimr( ls->Strings[ lineNo ].c_str() );
if ( stemp.length() == 0 || ( !started && !isdigit( ls->Strings[ lineNo ][ 1 ] ) ) )
{
// GJV.LOG
/*
Contest Title : VHFNFD
Band in MHz : 432
Section Entered : Multi Operator
Name of Entrant/Club/Contest Group : Bracknell Amateur Radio Club
Band in MHz : %band%
Section Entered : %section%
Callsign Used : %call%
QRH Locator Sent : %locator%
Location as sent(District or QTH) : %QTH%
Brief Details of Transmitter Used : %Transmitter%
Brief Details of Receiver Used : %Receiver%
Power Output (Watts) : %power%
Antenna Type : %Antenna%
Antenna Height AGL(metres) : %AGL%
QTH Height ASL(metres) : %ASL%
Difficult ones:
Name and Callsign of all Operators :
G0GJV G4AUC G0FCT G0HVS
Name, Callsign, Telephone Number, Address for Correspondence :
: M. J. Goodey
: G0GJV
: 62, Rose Hill
: Binfield
: Berkshire
: RG42 5LG
Phone : 01344 428614
Email : [email protected]
*/
unsigned int spos = stemp.find( ":" );
if ( spos != std::string::npos )
{
std::string text = trim( stemp.substr( spos + 1, stemp.size() ) );
if ( strupr( stemp ).find( "CONTEST TITLE" ) == 0 )
{
name.setValue( text );
}
else
if ( strupr( stemp ).find( "BAND IN MHZ" ) == 0 )
{
band.setValue( text );
}
else
if ( strupr( stemp ).find( "SECTION ENTERED" ) == 0 )
{
entSect.setValue( text );
}
else
if ( strupr( stemp ).find( "NAME OF ENTRANT/CLUB/CONTEST GROUP" ) == 0 )
{
entrant.setValue( text );
}
else
if ( strupr( stemp ).find( "CALLSIGN USED" ) == 0 )
{
// we need to tail clip the callsign - or we end up with things like
// M1DUD/QRP CLASS : SO / 50MHZ FIXED
unsigned int spos = text.find( " " );
if ( spos != std::string::npos )
{
text = trim( text.substr( 0, spos ) );
}
mycall.fullCall.setValue( strupr( text ) );
mycall.valRes = CS_NOT_VALIDATED;
mycall.validate();
}
else
//.........这里部分代码省略.........