本文整理汇总了C++中TMem类的典型用法代码示例。如果您正苦于以下问题:C++ TMem类的具体用法?C++ TMem怎么用?C++ TMem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TMem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Header
bool TRf24Radio::Send(const uint16& NodeAddr, const uchar& Command, const TMem& Buff) {
bool ReceivedAck = false;
try {
Notify->OnNotifyFmt(ntInfo, "Sending message to node %d ...", NodeAddr);
RF24NetworkHeader Header(NodeAddr, Command);
TRpiUtil::SetMaxPriority();
uint16 From;
uchar Type;
TMem Payload; Payload.Gen(PAYLOAD_LEN);
TLock Lock(CriticalSection);
int RetryN = 0;
while (!ReceivedAck && RetryN < RETRY_COUNT) {
if (RetryN > 0) {
Notify->OnNotifyFmt(ntInfo, "Re-sending message, count %d", RetryN);
}
// write the message
_Send(Header, Buff);
// wait for an ACK
const uint64 StartTm = TTm::GetCurUniMSecs();
while (!ReceivedAck && TTm::GetCurUniMSecs() - StartTm < ACK_TIMEOUT) {
UpdateNetwork();
while (Read(From, Type, Payload)) {
if (Type == REQUEST_ACK) {
if (From != NodeAddr) {
Notify->OnNotifyFmt(ntWarn, "WTF!? received ACK from incorrect node, expected: %u, got: %u", NodeAddr, From);
} else {
Notify->OnNotifyFmt(ntInfo, "Received ack from node %u", NodeAddr);
ReceivedAck = true;
}
} else {
ReadThread.AddToQueue(TMsgInfo(From, Type, Payload));
}
}
}
RetryN++;
}
TRpiUtil::SetDefaultPriority();
} catch (const PExcept& Except) {
Notify->OnNotifyFmt(TNotifyType::ntErr, "Exception when sending!");
TRpiUtil::SetDefaultPriority();
return false;
}
if (!ReceivedAck) {
Notify->OnNotifyFmt(ntInfo, "Failed to send message!");
}
return ReceivedAck;
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:60,代码来源:rpi.cpp
示例2: strlen
BOOL CMime::ReplaceCid(LPCTSTR pCid, LPCTSTR pReplace, LPCTSTR buf, DWORD size, LPSTR dest)
{_STT();
DWORD i = 0, x = 0;
DWORD cidlen = strlen( pCid );
TMem< char > cid;
if ( !cid.allocate( cidlen + 32 ) ) return FALSE;
// Fix up cid
strcpy( cid, "cid:" );
strcat( cid, pCid );
cidlen = strlen( cid );
// Simple replace routine
while( i < size )
{
if ( strnicmp( cid, &buf[ i ], cidlen ) ) dest[ x++ ] = buf[ i++ ];
else
{ strcpy( &dest[ x ], pReplace );
x += strlen( pReplace );
i += cidlen;
} // end else
} // end while
dest[ x ] = 0;
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:28,代码来源:Mime.cpp
示例3: Destroy
BOOL CMime::Load(LPCTSTR pFile)
{_STT();
// Out with the old
Destroy();
CWinFile file;
// Open the file
if ( !file.OpenExisting( pFile, GENERIC_READ ) )
return FALSE;
// Get file size
DWORD size = file.Size();
if ( size == 0 ) return FALSE;
// Allocate memory
TMem< BYTE > buf;
if ( !buf.allocate( size + 1 ) ) return FALSE;
// Read in the data into ram
DWORD read;
if ( !file.Read( buf, size, &read ) || read != size )
return FALSE;
buf[ size ] = 0;
// Load the file
if ( !LoadFromMemory( buf, size ) )
return FALSE;
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:31,代码来源:Mime.cpp
示例4: IAssert
void TWebNetClt::SendHttpRq(const PHttpRq& HttpRq){
// push fetch-id & create time to waiting-list
int FetchId=HttpRq->GetFldVal(THttp::FetchIdFldNm).GetInt(-1);
IAssert(FetchId!=-1);
TMem Mem; HttpRq->GetAsMem(Mem);
IAssert("Screwed NetMem"&&!memchr(Mem(),0,Mem.Len()));
PNetObj NetObj=PNetObj(new TNetMem(Mem));
SendNetObj(NetObj);
PushToSentQ(FetchId);
}
开发者ID:AlertProject,项目名称:Text-processing-bundle,代码行数:10,代码来源:webnetobj.cpp
示例5: Lock
///////////////////////////////////////////
//// RF24 Radio transmitter
void TRf24Radio::TReadThread::Run() {
Notify->OnNotifyFmt(TNotifyType::ntInfo, "Starting read thread ...");
uint16 FromNode;
uchar Type;
TMem Payload;
Payload.Gen(PAYLOAD_LEN);
TMsgInfoV QueuedMsgV;
while (true) {
try {
// process queued messages
{
TLock Lock(Radio->CriticalSection);
// process new messages
Radio->UpdateNetwork();
while (Radio->Read(FromNode, Type, Payload)) {
Notify->OnNotifyFmt(ntInfo, "Read message, adding to queue ...");
AddToQueue(TMsgInfo(FromNode, Type, Payload));
}
if (!MsgQ.Empty()) {
Notify->OnNotifyFmt(ntInfo, "Adding %d messages to queue ...", MsgQ.Len());
QueuedMsgV.AddV(MsgQ);
MsgQ.Clr();
}
}
if (!QueuedMsgV.Empty()) {
Notify->OnNotifyFmt(ntInfo, "Processing %d messages ...", QueuedMsgV.Len());
for (int MsgN = 0; MsgN < QueuedMsgV.Len(); MsgN++) {
const TMsgInfo& Msg = QueuedMsgV[MsgN];
ProcessMsg(Msg.Val1, Msg.Val2, Msg.Val3);
}
Notify->OnNotify(ntInfo, "Queued messages processed!");
QueuedMsgV.Clr();
}
delayMicroseconds(500);
} catch (const PExcept& Except) {
Notify->OnNotifyFmt(TNotifyType::ntErr, "Error on the read thread: %s", Except->GetMsgStr().CStr());
}
}
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:49,代码来源:rpi.cpp
示例6: GetSafeHwnd
void CPgPubExtra::OnSettings()
{
CReg *pReg = (CReg*)CDlgTabFrame::GetData( GetSafeHwnd() );
if ( pReg == NULL ) return;
CRKey *pRk = pReg->FindKey( "PUBINFO" );
if ( pRk == NULL ) return;
int sel = m_comboCodec.GetCurSel();
if ( sel == CB_ERR ) return;
// Get data pointer
LPCODECINFO pci = (LPCODECINFO)m_comboCodec.GetItemData( sel );
if ( pci == NULL || !m_codecs.VerifyPointer( pci ) ) return;
// Attempt to open settings dialog
HIC hIc = ICOpen( ICTYPE_VIDEO, pci->fourCC, ICMODE_QUERY );
if ( hIc != NULL )
{
DWORD size = pRk->GetValueSize( "CodecData" );
LPBYTE buf = (LPBYTE)pRk->GetValuePtr( "CodecData" );
// Restore settings
if ( size > 0 && buf != NULL )
ICSetState( hIc, buf, size );
// Configure the compressor
if ( ICConfigure( hIc, GetSafeHwnd() ) != ICERR_OK )
return;
size = ICGetStateSize( hIc );
if ( size > 0 )
{
TMem< BYTE > mem;
if ( mem.allocate( size ) )
if ( ICGetState( hIc, mem.ptr(), size ) == ICERR_OK )
pRk->Set( "CodecData", mem.ptr(), size );
} // end if
ICClose( hIc );
} // end if
}
开发者ID:sanyaade-webdev,项目名称:wpub,代码行数:44,代码来源:PgPubExtra.cpp
示例7: GetParams
BOOL CNetCom::GetParams(CReg *pParams, GUID *pGuid)
{_STT();
if ( pParams == NULL ) return FALSE;
// See if there are any params
DWORD dwParams = 0; pParams->Destroy();
if ( m_prx->ReadPacketData( 0, NETMSGDT_PARAMS, NULL, 0, &dwParams ) && dwParams )
{ TMem< BYTE > buf;
if ( buf.allocate( dwParams ) &&
m_prx->ReadPacketData( 0, NETMSGDT_PARAMS, buf.ptr(), buf.size() ) )
pParams->LoadRegFromMem( buf, buf.size() );
} // end if
// Get the hash for these params
if ( pGuid ) GetParamsHash( pGuid );
return TRUE;
}
开发者ID:wheresjames,项目名称:rulib,代码行数:19,代码来源:NetCom.cpp
示例8: VerifyEmailList
BOOL CMime::VerifyEmailList(LPSTR pDst, LPCTSTR pSrc, LPCTSTR pSep)
{_STT();
// Sanity check
if ( pDst == NULL || pSrc == NULL ) return FALSE;
DWORD i = 0, skip = 0;
LPSTR pCopy = pDst;
TMem< char > buf;
// Are the destination and source the same?
if ( pDst == pSrc )
{ if ( !buf.allocate( ( strlen( pSrc ) * 2 ) + 1 ) ) return FALSE;
pCopy = buf.ptr();
} // end if
// Empty email list
*pCopy = 0;
char name[ MIME_STRSIZE ];
char user[ MIME_STRSIZE ];
char domain[ MIME_STRSIZE ];
// Pick apart the list then rebuild it
while( GetEmailComponents( &pSrc[ i ], name, user, domain, &skip ) )
{
// Skip to next address
i += skip;
// Add separator
if ( *pCopy != 0 ) strcat( pCopy, pSep );
// Append email address
BuildEmail( &pCopy[ strlen( pCopy ) ], name, user, domain );
} // end while
// Copy if dest and src are the same
if ( pDst == pSrc ) strcpy( pDst, pCopy );
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:41,代码来源:Mime.cpp
示例9: EncodeUrl
BOOL CReg::EncodeUrl(CPipe *pPipe, char chSepNameVal, char chSepValues )
{
// Ensure valid pipe
if ( NULL == pPipe ) return FALSE;
TMem< char > buf;
LPREGKEY prk = NULL;
while( ( prk = (LPREGKEY)GetNext( prk ) ) != NULL )
{
// Write separator if needed
if ( pPipe->GetBufferSize() ) pPipe->Write( &chSepValues, 1 );
LPCTSTR pName = prk->key->GetName();
CRKey *pRk = GetKey( pName );
if ( pRk )
{
// Write the name
if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( strlen( pName ) ) ) )
{ buf.Zero();
CCfgFile::CanonicalizeBuffer( buf, (LPBYTE)pName, strlen( pName ) );
pPipe->Write( buf );
} // end if
// Separator
pPipe->Write( &chSepNameVal, 1 );
// Save the key value
CPipe tpipe;
prk->key->EncodeUrl( &tpipe, 1, chSepNameVal, chSepValues );
if ( buf.grow( CCfgFile::GetMinCanonicalizeBufferSize( tpipe.GetBufferSize() ) ) )
{ buf.Zero();
CCfgFile::CanonicalizeBuffer( buf, (LPBYTE)tpipe.GetBuffer(), tpipe.GetBufferSize() );
pPipe->Write( buf );
} // end if
} // end if
} // end while
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:41,代码来源:Reg.cpp
示例10: Replace
BOOL CRKey::Replace(LPCTSTR pSrc, LPCTSTR pDst)
{_STTEX();
// Open files
CWinFile src, dst;
if ( !src.OpenExisting( pSrc, GENERIC_READ ) ) return FALSE;
if ( !dst.OpenNew( pDst, GENERIC_WRITE ) ) return FALSE;
// Read in data
TMem< BYTE > in;
if ( !in.allocate( src.Size() ) ) return FALSE;
if ( !src.Read( in.ptr(), in.size() ) ) return FALSE;
src.Close();
// Run replace function
CPipe outpipe;
DWORD op = 0, i = 0;
char token[ 256 ];
while ( Replace( &outpipe, &op, in.str(), in.size(),
NULL, NULL, token, NULL, &i ) )
{
} // end while
// Write out the data
return dst.Write( outpipe.GetBuffer(), outpipe.GetBufferSize() );
}
开发者ID:aminsyed,项目名称:rulib,代码行数:26,代码来源:RKey.cpp
示例11: Load
BOOL CCfgFile::Load(LPCTSTR pFile, BOOL bMerge)
{_STTEX();
if ( pFile == NULL ) return FALSE;
// Lose old record
if ( !bMerge ) Destroy();
if ( !bMerge ) strcpy( m_szFileName, pFile );
CWinFile file;
// Set crypto key
if ( *m_szKey ) file.CryptoSetKey( m_szKey );
// Open the file
if ( !file.OpenExisting( pFile, GENERIC_READ ) )
return FALSE;
// Get file size
DWORD size = file.Size();
if ( size == 0 ) return FALSE;
// Allocate memory
TMem< BYTE > buf;
if ( !buf.allocate( size + 1 ) ) return FALSE;
// Read in the data into ram
DWORD read;
if ( !file.Read( buf, size, &read ) || read != size )
return FALSE;
buf[ size ] = 0;
// Load the file
if ( !LoadFromMem( buf, size, bMerge ) )
return FALSE;
if ( !bMerge ) strcpy( m_szFileName, pFile );
return TRUE;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:39,代码来源:CfgFile.cpp
示例12: SaveToMem
BOOL CMime::Save(LPCTSTR pFile)
{_STT();
CWinFile f;
// Attempt to open the new file
if ( !f.OpenNew( pFile ) ) return FALSE;
// How much data
DWORD size = SaveToMem( NULL, 0 );
if ( size == 0 ) return TRUE;
// Allocate memory
TMem< BYTE > buf;
if ( !buf.allocate( size + 1 ) ) return FALSE;
// Write MIME to buffer
DWORD bytes = SaveToMem( buf, size );
// Write out the data to disk file
f.Write( buf, bytes );
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:23,代码来源:Mime.cpp
示例13: defined
CStr CTrace::GetBacktrace( oexUINT x_uSkip, oexUINT x_uMax )
{
#if defined( OEX_NOEXECINFO )
return CStr();
#else
// Allocate space for pointers
TMem< void* > memPtrs;
if ( !memPtrs.OexNew( x_uMax ).Ptr() )
return CStr();
// Get backtrace
oexINT nPtrs = backtrace( memPtrs.Ptr(), x_uMax );
if ( !nPtrs )
return CStr();
// Get function symbols
char ** sStrings = backtrace_symbols( memPtrs.Ptr(), nPtrs );
// Build stack
CStr str;
for ( oexUINT i = x_uSkip; (oexINT)i < nPtrs; i++ )
{
if ( sStrings && sStrings[ i ] && oexCHECK_PTR( memPtrs.Ptr( i ) ) )
str += CStr().Fmt( oexT( "[0x%.8X] %s" oexNL8 ), (oexUINT)*(oexUINT*)memPtrs.Ptr( i ), sStrings[ i ] );
else if ( oexCHECK_PTR( memPtrs.Ptr( i ) ) )
str += CStr().Fmt( oexT( "[0x%.8X] ???" oexNL8 ), (oexUINT)*(oexUINT*)memPtrs.Ptr( i ) );
else
str += oexT( "[0x????????] ???" oexNL8 );
} // end if
memPtrs.Zero();
// Release the memory
if ( sStrings )
free( sStrings );
return str;
#endif
}
开发者ID:sanyaade-webdev,项目名称:winglib,代码行数:41,代码来源:trace.cpp
示例14: Send
void TWebFetchSendBatchJson::Send() {
TStr BodyStr = TJsonVal::GetStrFromVal(JsonArray);
TMem BodyMem; BodyMem.AddBf(BodyStr.CStr(), BodyStr.Len());
PHttpRq HttpRq = THttpRq::New(hrmPost, TUrl::New(UrlStr), THttp::AppJSonFldVal, BodyMem);
FetchHttpRq(HttpRq);
}
开发者ID:Zala,项目名称:qminer,代码行数:6,代码来源:webpgfetch.cpp
示例15: getUsed
oexUINT CBin::GroupAvg( oexINT nType, oexUINT uOffset, oexUINT uInterval, oexUINT uGroups, CBin &bin, oexINT nFlags )
{
// Sanity check
if ( 0 >= uGroups || !getUsed() )
return 0;
// Get skip value
oexUINT uSkip = nFlags & 0x0f;
if ( uSkip >= uGroups )
uSkip = 0;
// Get element size
oexUINT uESize = obj::StaticSize( nType );
if ( !uESize )
return 0;
// Total samples
oexUINT uSamples = getUsed() / uESize;
if ( uSamples < uInterval )
return 0;
// How many samples per group
oexUINT nSamplesPerGroup = ( uInterval - uSkip ) / ( uGroups - uSkip );
if ( !nSamplesPerGroup )
return 0;
// Allocate memory
oexUINT uBytes = uGroups * uESize;
if ( bin.Size() < uBytes )
if ( !bin.Allocate( uBytes ) )
return oexFALSE;
// Allocate an array to hold the counts
TMem< oexUINT > aCnts;
if ( !aCnts.OexNew( uGroups ).Ptr() )
return oexFALSE;
// Memory to hold acc
TMem< oexLONGDOUBLE > aAcc;
if ( !aAcc.OexNew( uGroups ).Ptr() )
return oexFALSE;
// Initialize group averages
for ( oexUINT i = 0; i < uGroups; i++ )
aAcc[ i ] = 0, aCnts[ i ] = 0;
// Accumulate all samples
while( ( uOffset + uInterval ) < uSamples )
{
// Accumulate samples in this interval
for ( oexUINT s = 0; s < uInterval; s++ )
{
// Get the value
oexLONGDOUBLE dV;
switch( nType )
{ case obj::tInt : dV = getINT( uOffset + s ); break;
case obj::tFloat : dV = getFLOAT( uOffset + s ); break;
case obj::tDouble : dV = getDOUBLE( uOffset + s ); break;
default : dV = 0;
} // end switch
// Range check and add
// if ( 1000000 > oex::cmn::Abs( dV ) && .0000001 < oex::cmn::Abs( dV ) )
if ( s < uSkip )
aAcc[ s ] = dV, aCnts[ s ]++;
else
{ oexUINT o = uSkip + s / nSamplesPerGroup;
if ( o >= uGroups ) o = uGroups - 1;
aAcc[ o ] += dV; aCnts[ o ]++;
} // end else
} // end for
uOffset += uInterval;
} // end while
// Calculate averages
switch( nType )
{
case obj::tInt :
for ( oexUINT g = 0; g < uGroups; g++ )
bin.setINT( g, aCnts[ g ] ? oexINT( aAcc[ g ] / aCnts[ g ] ) : 0 );
break;
case obj::tFloat :
for ( oexUINT g = 0; g < uGroups; g++ )
bin.setFLOAT( g, aCnts[ g ] ? oexFLOAT( aAcc[ g ] / aCnts[ g ] ) : 0 );
break;
case obj::tDouble :
for ( oexUINT g = 0; g < uGroups; g++ )
bin.setDOUBLE( g, aCnts[ g ] ? oexDOUBLE( aAcc[ g ] / aCnts[ g ] ) : 0 );
break;
default :
return 0;
} // end switch
//.........这里部分代码省略.........
开发者ID:MangoCats,项目名称:winglib,代码行数:101,代码来源:bin_share.cpp
示例16: FTPSERVERS
BOOL CPubThread::Ftp( LPPUBINFO ppi )
{
if ( ppi == NULL ) return FALSE;
// Ensure ftp server
HGROUP hGroup = FTPSERVERS().FindGroup( ppi->str );
if ( hGroup == NULL )
{ _Log( MB_ICONERROR, ppi->str, "FTP Server information not found" );
return FALSE;
} // end if
BOOL bPublished = FALSE;
LPBYTE buf = NULL;
DWORD size = 0;
TMem< BYTE > temp;
CWinImg img;
// Is it an avi file
if ( *ppi->avicachefile != 0 )
{
CWinFile wf;
if ( wf.OpenExisting( ppi->avicachefile ) )
{ size = wf.Size();
if ( size && temp.allocate( size ) && wf.Read( temp.ptr(), temp.size() ) )
buf = (LPBYTE)temp.ptr();
} // end if
} // end if
else
{
// Get the image
if ( !IMGLIST().GetImage( ppi->img, &img ) )
{ _Log( MB_ICONERROR, ppi->img, "Image not found" );
return FALSE;
} // end if
// Set jpeg quality
FRAME()->SetQuality( &img );
// Encode the file
if ( !img.Encode( &buf, &size, ppi->pub_fname ) )
{ _Log( MB_ICONERROR, ppi->img, img.GetLastError() );
return FALSE;
} // end if
} // end else
// Want Win32 interface?
if ( FTPSERVERS().GetDword( hGroup, "Rename", FALSE ) )
{
// Create FTP object if needed
if ( ppi->pftp == NULL ) ppi->pftp = new CFtp();
if ( ppi->pftp == NULL )
{ _Log( MB_ICONERROR, "Ftp()", "Out of memory" );
return FALSE;
} // end if
// Is the FTP already working?
if ( !ppi->pftp->IsConnecting() && !ppi->pftp->IsConnected() )
{
// Copy the memory
if ( ppi->mem == NULL || !ppi->mem->put( buf, size ) )
{ _Log( MB_ICONERROR, "Ftp()", "Memory error" );
return FALSE;
} // end if
// Upload the data
bPublished = FtpImage( ppi->str, ppi->pftp, *ppi->mem, ppi->mem->size(), ppi->pub_fname );
} // end if
} // end if
else
{
// Create FTP object if needed
if ( ppi->pw32ftp == NULL ) ppi->pw32ftp = new CNetFile();
if ( ppi->pw32ftp == NULL )
{ _Log( MB_ICONERROR, "Ftp()", "Out of memory" );
return FALSE;
} // end if
// Use Windows interface
bPublished = FtpImage( ppi->str, ppi->pw32ftp, buf, size, ppi->pub_fname );
} // end else
// Punt if no thumbnail
if ( ( ppi->f1 & PUBF1_THUMBNAIL ) == 0 ) return bPublished;
// Load image if we haven't already
if ( !img.IsValid() )
{
// Get the image
if ( !IMGLIST().GetImage( ppi->img, &img ) )
{ _Log( MB_ICONERROR, ppi->img, "Image not found" );
return FALSE;
} // end if
// Set jpeg quality
//.........这里部分代码省略.........
开发者ID:sanyaade-webdev,项目名称:wpub,代码行数:101,代码来源:PubThread.cpp
示例17: while
BOOL CRKey::ReadInline(LPBYTE buf, DWORD size, char sep, BOOL bDeCanonicalize)
{_STTEX();
// Sanity checks
if ( buf == NULL || size == 0 ) return FALSE;
DWORD i = 0;
char token[ CWF_STRSIZE ];
while ( i < size && buf[ i ] != 0 )
{
DWORD t = 0;
// Skip white space
while ( i < size && ( buf[ i ] <= ' ' || buf[ i ] > '~' ) && buf[ i ] != 0 ) i++;
if ( i >= size || buf[ i ] == 0 ) return TRUE;
// Read in first token
while ( i < size && t < ( CWF_STRSIZE - 1 ) &&
buf[ i ] > ' ' && buf[ i ] <= '~' &&
buf[ i ] != '=' )
token[ t++ ] = buf[ i++ ];
token[ t ] = 0;
{ // DeCanonicalize token
DWORD dwMin = CCfgFile::GetMinDeCanonicalizeBufferSize( strlen( token ) );
TMem< BYTE > mem; DWORD dwSize = 0;
if ( mem.allocate( dwMin + 1 ) )
{ if ( CCfgFile::DeCanonicalizeBuffer( token, (LPBYTE)mem.ptr(), strlen( token ), &dwSize ) )
{ memcpy( token, mem.ptr(), dwSize ); token[ dwSize ] = 0; }
} // end if
} // end decanoicalize token
// Check for '='
if ( buf[ i ] == '=' )
{ i++;
// Skip starting spaces
while ( i < size && buf[ i ] == ' ' ) i++;
DWORD s = i;
BOOL quoted = FALSE;
// Find the end of the data
while ( i < size &&
( ( quoted && buf[ i ] >= ' ' ) || buf[ i ] > ' ' ) &&
buf[ i ] <= '~' && buf[ i ] != sep )
{
// Toggle quote mode
if ( buf[ i ] == '"' ) quoted = !quoted;
// Next char
i++;
} // end if
if ( i > s )
{
if ( bDeCanonicalize )
{
// DeCanonicalize data
DWORD dwMin = CCfgFile::GetMinDeCanonicalizeBufferSize( i - s );
TMem< BYTE > mem;
if ( mem.allocate( dwMin + 1 ) )
{
// Do it
DWORD dwSize = 0;
if ( CCfgFile::DeCanonicalizeBuffer( (LPCTSTR)&buf[ s ], (LPBYTE)mem.ptr(), i - s, &dwSize ) )
// Add this variable
Add( REG_SZ, token, mem.ptr(), dwMin );
} // end if
} // end if
// Add variable if any
else Add( REG_SZ, token, &buf[ s ], i - s );
} // end if
// Skip separator
if ( buf[ i ] == sep ) i++;
} // end if
// Add null
else Add( REG_DWORD, token, NULL, sizeof( DWORD ) );
} // end while
return TRUE;
}
开发者ID:aminsyed,项目名称:rulib,代码行数:95,代码来源:RKey.cpp
示例18: Buff
void TRf24Radio::_Send(RF24NetworkHeader& Header, const TMem& Buff) {
Network->write(Header, Buff(), Buff.Len());
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:3,代码来源:rpi.cpp
示例19: ll
CCircBuf::t_size CCircBuf::Resize(t_size x_uNewSize)
{
// Lock the buffer
oexAutoLock ll( &m_lock );
if ( !ll.IsLocked() )
return oexFALSE;
// Ensure we actually have a buffer
if ( !m_pBi )
return oexFALSE;
// Can't resize a memory mapping
if ( m_memBuffer.IsMapped() )
return oexFALSE;
// Ensure we don't go over the maximum
if ( x_uNewSize > m_uMaxSize )
return oexFALSE;
// Punt if we're already there
if ( x_uNewSize == m_uSize )
return oexFALSE;
// Create new buffer
TMem< oexUCHAR > temp;
if ( !temp.OexNew( x_uNewSize, oexFALSE, oexTRUE ).Ptr() )
return oexFALSE;
// How much memory did we actually get
x_uNewSize = temp.Size() - sizeof( SBufferInfo );
t_size uWritten = GetMaxRead( m_pBi->uReadPtr, m_pBi->uWritePtr, m_uSize );
t_size uPoked = GetMaxRead( m_pBi->uReadPtr, m_uPokePtr, m_uSize );
t_size uUsed = cmn::Max( uPoked, uWritten );
// How many will we copy over?
if ( uUsed > m_uSize )
uUsed = m_uSize;
if ( uUsed > x_uNewSize )
uUsed = x_uNewSize;
if ( uUsed )
{
oexUCHAR *pView;
t_size i = 0, uRead = 0, uView;
// Read all the blocks into the buffer
while ( GetView( i++, m_pBi->uReadPtr, uUsed, m_pBuf, m_uSize, &pView, &uView ) )
os::CSys::MemCpy( &( (oexUCHAR*)temp.Ptr( sizeof( SBufferInfo ) ) )[ uRead ], pView, uView ), uRead += uView;
} // end if
// Copy the buffer info data
os::CSys::MemCpy( temp.Ptr(), m_memBuffer.Ptr(), sizeof( SBufferInfo ) );
// Swap over the buffer pointer
m_memBuffer.Assume( temp );
// Get the buffer info pointer
m_pBi = (SBufferInfo*)m_memBuffer.Ptr();
// The actual buffer
m_pBuf = m_memBuffer.Ptr( sizeof( SBufferInfo ) );
// Save the new buffer size
m_uSize = x_uNewSize;
// Adjust write pointers
m_pBi->uReadPtr = 0;
m_pBi->uWritePtr = uWritten;
m_uPokePtr = uPoked;
// Return the new buffer size
return x_uNewSize;
}
开发者ID:MangoCats,项目名称:winglib,代码行数:75,代码来源:circ_buf.cpp
示例20: WRITESZ
DWORD CCfgFile::SaveToMem(LPBYTE ptr, DWORD len)
{_STTEX();
DWORD i = 0;
CWinFile file;
// Set crypto key
if ( *m_szKey ) file.CryptoSetKey( m_szKey );
// Write out header
WRITESZ( "; Configuration File\r\n;\r\n" );
LPCFGGROUPINFO pcgi = NULL;
while ( ( pcgi = GetNext( pcgi ) ) != NULL )
{
// Write out the name
if ( *pcgi->name != NULL )
{ WRITESZ( "\r\n;-----------------------------------------------------------------" );
WRITESZ( "\r\n[" );
WRITESZ( pcgi->name );
WRITESZ( "]" );
WRITESZ( "\r\n;-----------------------------------------------------------------" );
WRITESZ( "\r\n;\r\n" );
} // end if
// Write out file data
TMem< char > buf;
DWORD size;
char msg[ CFG_STRSIZE ];
LPCFGELEMENTINFO pcei = NULL;
while ( ( pcei = GetNextElement( pcgi, pcei ) ) != NULL )
{
// Write out type
if ( pcei->type != 0 )
{
wsprintf( msg, "%lu:", pcei->type );
WRITESZ( msg );
} // end if
// Write out the name
size = GetMinCanonicalizeBufferSize( strlen( pcei->name ) );
if ( buf.allocate( size + 1 ) )
{
// Write string
if ( CanonicalizeBuffer( buf, (LPBYTE)pcei->name, strlen( pcei->name ) ) )
WRITE( buf, strlen( buf ) );
buf.destroy();
} // end if
if ( pcei->size != 0 || pcei->value != NULL || pcei->type != 0 )
{
// Write out the equator
if ( pcei->type == CFG_DWORD )
WRITESZ( "=#" );
else WRITESZ( "=>" );
// Write out DWORD value
if ( pcei->type == CFG_DWORD )
{
wsprintf( msg, "%lu:", pcei->value );
WRITESZ( msg );
} // end if
else if ( size > 0 )
{
// Write out the data
size = GetMinCanonicalizeBufferSize( pcei->size );
if ( buf.allocate( size + 1 ) )
{
// Write string
if ( CanonicalizeBuffer( buf, (LPBYTE)pcei->value, pcei->size ) )
WRITE( buf, strlen( buf ) );
buf.destroy();
} // end if
} // end else
} // end if
WRITESZ( "\r\n" );
} // end while
} // end while
return i;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:89,代码来源:CfgFile.cpp
注:本文中的TMem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论