本文整理汇总了C++中TPtr8::PtrZ方法的典型用法代码示例。如果您正苦于以下问题:C++ TPtr8::PtrZ方法的具体用法?C++ TPtr8::PtrZ怎么用?C++ TPtr8::PtrZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPtr8
的用法示例。
在下文中一共展示了TPtr8::PtrZ方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// The caller must free the returned buffer. The buffer is guaranteed
// to have a zero terminator.
HBufC8* ConvToUtf8ZL(const TDesC& name16)
{
// Note that there is no non-leaving variant of this function, such
// that the result has no maximum size.
//
// Do not know what happens if any 0 values appear in "name16"; this
// is not documented.
HBufC8* name8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(name16);
// Ensure there is a zero terminator. Quite a lot of work to do this
// efficiently.
TPtr8 ptr = name8->Des();
if (ptr.Length() < ptr.MaxLength()) {
ptr.PtrZ(); // modifies HBufC8 content
} else {
HBufC8* bigger8 = name8->ReAlloc(ptr.Length() + 1);
if (bigger8) {
name8 = bigger8; // name8 already deleted by ReAlloc
name8->Des().PtrZ(); // modifies HBufC8 content
} else {
delete name8;
User::Leave(KErrNoMemory);
}
}
return name8;
}
示例2: al_SetDataFormat
TInt COpenMAXALTestModule::al_SetDataFormat( CStifItemParser& aItem )
{
TInt status(KErrNone);
TInt type;
TInt contType(0);
TPtrC mimetype;
status = aItem.GetNextInt(type);
switch(type)
{
case XA_DATAFORMAT_MIME:
{
status = aItem.GetNextString(mimetype);
if(!status)
{
status = aItem.GetNextInt(contType);
if(!status)
{
if(m_MimeType)
{
delete m_MimeType;
m_MimeType = NULL;
}
m_MimeType = HBufC8::NewL(mimetype.Length()+1);
TPtr8 desc = m_MimeType->Des();
desc.Copy(mimetype);
m_Mime.formatType = XA_DATAFORMAT_MIME;
m_Mime.mimeType = (XAchar*) desc.PtrZ();
m_Mime.containerType = contType;
}
else
{
status = KErrGeneral;
}
}
else
{
status = KErrGeneral;
}
}
break;
case XA_DATAFORMAT_PCM:
case XA_DATAFORMAT_RAWIMAGE:
break;
default:
status = KErrGeneral;
break;
}
return status;
}
示例3: al_SetDataLocator
TInt COpenMAXALTestModule::al_SetDataLocator( CStifItemParser& aItem )
{
TInt status(KErrNone);
TInt type;
status = aItem.GetNextInt(type);
switch(type)
{
case XA_DATALOCATOR_URI:
{
TPtrC uri;
if(m_URIName)
{
delete m_URIName;
m_URIName = NULL;
}
//status = aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing);
status = aItem.GetNextString(uri);
if(!status)
{
m_URIName = HBufC8::NewL(uri.Length()+1);
TPtr8 desc = m_URIName->Des();
desc.Copy(uri);
m_Uri.locatorType = XA_DATALOCATOR_URI;
m_Uri.URI = (XAchar*) desc.PtrZ();
}
else
{
status = KErrGeneral;
}
}
break;
case XA_DATALOCATOR_IODEVICE:
{
TInt devicetype;
TUint deviceId;
status = aItem.GetNextInt(devicetype);
if(!status)
{
status = aItem.GetNextInt(deviceId);
if(!status)
{
TInt srcsinktype(0);
status = aItem.GetNextInt(srcsinktype);
if(!status)
{
if(srcsinktype == 1)
{
m_SrcIODevice.deviceID = deviceId;
m_SrcIODevice.deviceType = devicetype;
m_SrcIODevice.locatorType = XA_DATALOCATOR_IODEVICE;
}
else
{
m_SinkIODevice.deviceID = deviceId;
m_SinkIODevice.deviceType = devicetype;
m_SinkIODevice.locatorType = XA_DATALOCATOR_IODEVICE;
}
}
else
{
status = KErrGeneral;
}
}
else
{
status = KErrGeneral;
}
}
else
{
status = KErrGeneral;
}
}
break;
case XA_DATALOCATOR_OUTPUTMIX:
case XA_DATALOCATOR_NATIVEDISPLAY:
case XA_DATALOCATOR_ADDRESS:
break;
default:
status = KErrGeneral;
break;
}
return status;
}
示例4: GetBackupDataSectionL
//.........这里部分代码省略.........
// enough, if not send as much as we can
TBool enoughRoom = bytesRemaining < available;
aBuffer.Append(
headerPtr8.Ptr() + iHeaderSent,
enoughRoom ? bytesRemaining : available );
if( enoughRoom )
{
iHeaderSent = 0; // ready for next header
iBackupState = EBackupOpenAllHeaderSent;
}
else
{
iHeaderSent += available; // ready to do round again
// state remains as EBackupOpenPartHeaderSent
}
// if the buffer's full we need to return control to the backup engine
// Because the finishedFlag is not set, the BUE will process this
// chunk and then ask for another
if( aBuffer.Size() == aBuffer.MaxSize() )
{
return;
}
break;
}
// need to send some data
case EBackupOpenAllHeaderSent:
{
AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::GetBackupDataSectionL state %d", iBackupState );
// how many bytes can we send
TInt available = aBuffer.MaxSize() - aBuffer.Size();
// create a buffer for this data (plus one for PtrZ)
HBufC8* transferBuffer = HBufC8::NewLC( available + 1 );
TPtr8 bufferToSend = transferBuffer->Des();
// get the data
User::LeaveIfError( iFile.Read( bufferToSend, available ) );
// Check how much did we actually read.
TInt bytesRead = bufferToSend.Size();
// EOF
if( bytesRead == 0 )
{
CleanupStack::PopAndDestroy( transferBuffer );
iBackupState = EBackupEndOfFile;
break;
}
// add it to the aBuffer
aBuffer.Append( bufferToSend.PtrZ(), bytesRead );
// tidy up
CleanupStack::PopAndDestroy( transferBuffer );
// if the buffer's full we need to return control to the backup engine
if( aBuffer.Size() == aBuffer.MaxSize() )
{
return;
}
break;
}
// At the end of the current file.
case EBackupEndOfFile:
{
AKNS_TRACE_DEBUG1("CAknsSrvActiveBackupDataClient::GetBackupDataSectionL state %d", iBackupState );
// how many bytes can we send
if ( aBuffer.Size() != 0 )
{
TInt available = aBuffer.MaxSize() - aBuffer.Size();
// pad the end of the buffer with NULL.
HBufC8* transferBuffer = HBufC8::NewLC( available + 1 );
TPtr8 bufferToSend = transferBuffer->Des();
bufferToSend.FillZ();
aBuffer.Append( bufferToSend.PtrZ(), available );
CleanupStack::PopAndDestroy( transferBuffer );
if( aBuffer.Size() != aBuffer.MaxSize() )
{
// Sanity check
User::Leave( KErrGeneral );
}
}
// Close file and move on to next file.
iFile.Close();
++iFileIndex;
// Start all over again.
iBackupState = EBackupNoFileOpen;
break;
}
default:
{
// not reachable
return;
}
}
}
}
示例5: nameDesC
SYSCALL(MAHandle, maOpenStore(const char* name, int flags))
{
const char* path;
int len;
#ifdef _WIN32_WCE
char temp[256];
TCHAR wtemp[256];
getWorkingDirectory(temp, 256);
strcat(temp, "\\");
strcat(temp, STORE_PATH);
convertAsciiToUnicode(wtemp, 256, temp);
CreateDirectory(wtemp, NULL);
#elif defined(SYMBIAN)
MyRFs myrfs;
myrfs.Connect();
#ifdef DEBUGGING_MODE
int res =
#endif
FSS.MkDir(KMAStorePath16);
LOGD("MkDir %i\n", res);
#elif defined(__IPHONE__)
#else
_mkdir(STORE_PATH);
#endif //_WIN32_WCE
#ifdef SYMBIAN
TPtrC8 nameDesC(CBP name);
TCleaner<HBufC8> hbuf(HBufC8::NewLC(KMAStorePath8().Length() + nameDesC.Length() + 1));
TPtr8 des = hbuf->Des();
des.Append(KMAStorePath8);
des.Append(nameDesC);
path = CCP des.PtrZ();
len = des.Length();
#elif defined(__IPHONE__)
std::string newPath = getWriteablePath(STORE_PATH);
std::string newFile = newPath + "/" + std::string(name);
path = newFile.c_str();
len = newFile.length();
_mkdir(newPath.c_str());
#else
std::string newPath = STORE_PATH + std::string(name);
path = newPath.c_str();
len = newPath.length();
#endif
FileStream readFile(path);
if(!readFile.isOpen())
{
if(flags & MAS_CREATE_IF_NECESSARY)
{
WriteFileStream writeFile(path);
if(!writeFile.isOpen())
return STERR_GENERIC;
}
else
{
return STERR_NONEXISTENT;
}
}
SYSCALL_THIS->gStores.insert(SYSCALL_THIS->gStoreNextId, path, len);
return SYSCALL_THIS->gStoreNextId++;
}