本文整理汇总了C++中TDes8::MaxLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TDes8::MaxLength方法的具体用法?C++ TDes8::MaxLength怎么用?C++ TDes8::MaxLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TDes8
的用法示例。
在下文中一共展示了TDes8::MaxLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadString
TUint TInputManager::ReadString(TDes8& aStr)
{
TKeyCode key;
aStr.Zero();
while( (key = iConsole.Getch()) != EKeyEnter)
{
if (aStr.Length() == aStr.MaxLength())
return aStr.MaxLength();
if (key == EKeyBackspace)
{
if (aStr.Length() > 0)
{
aStr.Delete(aStr.Length()-1, 1);
ConsoleBackspace(1);
}
}
else
{
TUint8 keyChar(key);
aStr.Append(keyChar);
iConsole.Printf(_L("%c"), keyChar);
}
}
iConsole.Printf(_L("\n"));
return aStr.Length();
}
示例2:
TInt CWsGceCscBase::DebugInfo(TWsDebugInfoFunc aFunction,
TInt aParam,
TDes8& aHostBuffer,
const void*&aReturnedObject,
TInt aObjectSize)const
{
TInt reqSize=iSession.DebugInfo(aFunction,aHostBuffer,aParam);
aReturnedObject=NULL;
if (reqSize<0)
{
if ((reqSize%aObjectSize)!=0)
{
return KErrCorrupt;
}
else
{
return reqSize;
}
}
if (reqSize>aHostBuffer.MaxLength())
{
return reqSize/aObjectSize;
}
if (reqSize==0)
{
reqSize=aHostBuffer.MaxLength();
}
if ((reqSize%aObjectSize)!=0)
{
return KErrCorrupt;
}
aReturnedObject=(const void*)aHostBuffer.Ptr();
reqSize/=aObjectSize;
return reqSize;
}
示例3: ColumnBinary
/**
Copies the content of a binary column, identified by aColumnIndex, to the place refered by aDest parameter.
If the destination buffer is not big enough, the function will copy as much data as possible and will
return KErrOverflow.
@param aColumnIndex Column index
@param aDest Refers to the place where the column data will be copied.
@return KErrNone, if the function completes successfully,
otherwise one of the other system-wide error codes.
@panic SqlDb 5 Column index out of bounds.
@panic SqlDb 11 Statement cursor not positioned on a row
*/
TInt CSqlStatementImpl::ColumnBinary(TInt aColumnIndex, TDes8& aDest)
{
__ASSERT_ALWAYS((TUint)aColumnIndex < (TUint)iColumnCnt, __SQLPANIC(ESqlPanicBadColumnIndex));
__ASSERT_ALWAYS(iState == CSqlStatementImpl::EAtRow, __SQLPANIC(ESqlPanicInvalidRow));
iColumnValBufIt.MoveTo(aColumnIndex);
TInt err = KErrNone;
//The binary column value has not been transferred to the client side if its length is >= KSqlMaxDesLen bytes.
//In this case an additional call to the server is made to get the column value.
if(!iColumnValBufIt.IsPresent())
{
if(iColumnValBufIt.Type() != ESqlBinary)
{
aDest.Zero();
return err;
}
err = iSqlStmtSession.ReadColumnValue(aColumnIndex, aDest);
}
else
{
TPtrC8 src = iColumnValBufIt.Binary();
TInt len = src.Length();
if(len > aDest.MaxLength())
{
len = aDest.MaxLength();
err = KErrOverflow;
}
aDest.Copy(src.Ptr(), len);
}
return err;
}
示例4: Caps
void DMediaDriverTest::Caps(TDes8& aCapsBuf)
//
// Return the capabilities of the media
{
TLocalDriveCapsV2 caps;
caps.iType=EMediaRam;
caps.iConnectionBusType=EConnectionBusInternal;
caps.iDriveAtt=KDriveAttLocal|KDriveAttRemovable;
caps.iMediaAtt=KMediaAttFormattable;
caps.iFileSystemId=KDriveFileSysFAT;
caps.iHiddenSectors=0;
aCapsBuf.FillZ(aCapsBuf.MaxLength());
aCapsBuf.Copy((TUint8 *)&caps,Min(aCapsBuf.MaxLength(),sizeof(caps)));
}
示例5: Read
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
{
if (aLength <= aData.Length())
{
// Can read it from this buffer
TPtrC8 res(aData.Left(aLength));
aData.Set(aData.Mid(aLength));
return res;
}
else /*if (aLength > aData.Length())*/
{
// Descriptor spans wrap point, so need to copy into temp buf
aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
TInt overflowLen = aLength - aData.Length();
aData.Set(aOverflowData); // Wrap aData
aOverflowData.Set(TPtrC8());
if (overflowLen > aData.Length())
{
ASSERT(EFalse); // Shouldn't happen
// in urel, return everything we've got
return aData;
}
aTempBuf.Append(aData.Left(overflowLen));
aData.Set(aData.Mid(overflowLen));
return TPtrC8(aTempBuf);
}
}
示例6: GetCust
TInt RCdlSession::GetCust(TDes8& aCust, TInt& aNewSize) const
{
TPckg<TInt> pckg(aNewSize);
TIpcArgs p(&aCust, aCust.MaxLength(), &pckg);
return SendReceive(ECdlServCmdGetCust,p);
}
示例7: Read
// -----------------------------------------------------------------------------
// CRedirDesc::Read
// Implementation for Read
// -----------------------------------------------------------------------------
//
void CRedirDesc::Read(TDes8& aDes, TRequestStatus& aStatus)
{
if( ENotConnected == iStatus )
{
iLock.Wait();
if( ENotConnected == iStatus )
{
Configure();
}
iLock.Signal();
}
if( EConnected == iStatus && !iReadNone )
{
iSession.Read(aStatus, aDes, aDes.MaxLength());
}
else
{
// If no session is there i.e. no server in production code or in the
// config.ini file for the stdioserver the both media type is NONE then
// just complete the request with EOF so that libc can handle it.
TRequestStatus* status = &aStatus;
User::RequestComplete(status, KErrEof);
}
}
示例8: Retrieve
// -----------------------------------------------------------------------------
// CWimOMAProv::Retrieve()
// Fetches the whole data of provisioning information string.
// -----------------------------------------------------------------------------
//
EXPORT_C void CWimOMAProv::Retrieve( const TOMAType& aOMAType,
TDes8& aOMAData,
TRequestStatus& aStatus )
{
_WIMTRACE ( _L( "CWimOMAProv::Retrieve" ) );
aStatus = KRequestPending;
iClientStatus = &aStatus;
if ( !iClientSession || !iConnectionHandle )
{
User::RequestComplete( iClientStatus, KErrGeneral );
return;
}
if ( aOMAData.MaxLength() )
{
iOMAType = aOMAType;
iData = &aOMAData;
iPhase = ERetrieve;
SignalOwnStatusAndComplete();
}
else
{
User::RequestComplete( iClientStatus, KErrGeneral );
}
}
示例9: TranslateCrLf
LOCAL_C TInt TranslateCrLf(TDes8 &aDes)
//
// Search for CR/LF characters in a string and replace them with
// '\r' '\n' format. Also replaces unprintable characters with "?"
//
{
TText8 buf[KBlockSize];
TText8 *pS=(TText8*)aDes.Ptr();
TText8 *pSE=pS+aDes.Size();
TText8 *pT=&buf[0];
TText8 *pTMax=pT+(KBlockSize-1);
for (; pS<pSE; pS++,pT++)
{
if (pT>=pTMax)
return(KErrTooBig);
if (*pS=='\xD'||*pS=='\xA')
{
*pT++='\\';
*pT=(*pS=='\xD')?'r':'n';
}
else if (((TChar)*pS).IsPrint())
*pT=*pS;
else
*pT='\?';
}
*pT=0;
if ((pT-&buf[0])>aDes.MaxLength())
return(KErrTooBig);
aDes.Copy(&buf[0]);
return(KErrNone);
}
示例10: FillBuffer
/** Fills a buffer with character aC
@param aBuffer Buffer to be filled, output
@param aLength Length to be filled
@param aC Character to be used to fill the buffer
*/
void FillBuffer(TDes8& aBuffer, TInt aLength, TChar aC)
{
test (aBuffer.MaxLength() >= aLength);
for(TInt i=0; i<aLength; i++)
{
aBuffer.Append(aC);
}
}
示例11: DoReadL
/** Reads data from the stream buffer into the specified descriptor.
This function is called by ReadL(TDes8&,TInt,TRequestStatus&).
This implementation deals with the request synchronously, and completes the
request with KErrNone. Other implementations may choose to deal with this
in a true asynchronous manner.
In addition, the read operation itself uses the DoReadL(TAny*,TInt) variant.
@param aDes The target descriptor for the data read from the stream buffer.
On return, the length of the descriptor is set to the number of bytes read
from the stream buffer.
@param aMaxLength The maximum number of bytes to be read. This value must not
be greater than the maximum length of the descriptor, otherwise the function
raises a STORE-Stream 2 panic.
@param aStatus The request status that indicates the completion status of this
asynchronous request.
@return The maximum number of bytes to be read, as used in this request. This
implementation uses, and returns, the value supplied in aMaxLength. Other
implementations may choose to use a different value.
@see MStreamBuf::ReadL() */
EXPORT_C TInt MStreamBuf::DoReadL(TDes8& aDes,TInt aMaxLength,TRequestStatus& aStatus)
{
__ASSERT_DEBUG(aMaxLength<=aDes.MaxLength(),Panic(EStreamReadBeyondEnd));
aDes.SetLength(DoReadL((TUint8*)aDes.Ptr(),aMaxLength));
TRequestStatus* stat=&aStatus;
User::RequestComplete(stat,KErrNone);
return aMaxLength;
}
示例12: Read
// -----------------------------------------------------------------------------
// CDirectoryDesc::Read : Reading from a Directory
// -----------------------------------------------------------------------------
void CDirectoryDesc::Read(TDes8& aDesc, TRequestStatus& aStatus)
{
TInt errorNum = KErrNone;
const TInt16 KDirentSize = 8;
TInt readLen = aDesc.MaxLength();
TUint8* bufPtr = const_cast<TUint8*>(aDesc.Ptr());
TInt copiedInfo = 0;
TEntryArray entries;
errorNum = iDir.Read( entries );
TDirent direntEntry;
if (errorNum == KErrNone || errorNum == KErrEof)
{
errorNum = KErrNone;
TEntry entry;
TInt len = 0;
TInt count = entries.Count();
TBuf8<KMaxFileName> fileName;
TInt index = 0;
TInt copyLen = 0;
//Loop through each entry and get all the informations
for (; index<count && copiedInfo<readLen; index++, copiedInfo += copyLen)
{
entry = entries[index];
//Copy File's UID
TUid fileUID = entry.iType.MostDerived();
direntEntry.iEntryNum = fileUID.iUid;
HBufC8 *name;
if(ConvertUnicodeToUtf8(entry.iName,name,errorNum) == -1)
{
break;
}
//Copy entry type and record Length
fileName.Copy( name->Des() );
delete name;
len = fileName.Length();
direntEntry.iRecLen = KDirentSize + len + 1;
//Maintaing a four byte boundary.
direntEntry.iRecLen = Align4(direntEntry.iRecLen);
direntEntry.iEntryType = 0;
direntEntry.iNameLen = len;
//Copy entry name
Mem::Copy( direntEntry.iEntryName, fileName.PtrZ(), len+1);
//Copy structure on to the buffer
copyLen = Min(direntEntry.iRecLen, (readLen - copiedInfo));
Mem::Copy( bufPtr, &direntEntry, copyLen );
bufPtr += copyLen;
}
}
//Set the Length
aDesc.SetLength( copiedInfo );
TRequestStatus* status = &aStatus;
User::RequestComplete(status, errorNum);
}
示例13: ConnectionControl
/**
Performing ECNControl actions.
*/
TInt CPARAM_MESS_NAMEStep::ConnectionControl(TUint aOptionLevel, TUint aOptionName, TDes8& aOption)
{
TSockOpt arg;
arg.optionName = aOptionName;
arg.optionVal = &aOption; //Note that optionVal will be useless on the server side
arg.optionLen = aOption.MaxLength();
TPckgC<TSockOpt> buf(arg);
return SendReceive(ECNControl, TIpcArgs(&buf, aOptionLevel, &aOption,iSSRef ));
}
示例14: Get
/** Reads a descriptor setting.
@param aKey Key of setting to be read.
@param aValue Returns the value of the setting if it is a descriptor.
@param aActualLength Returns the actual length of the setting if it is a descriptor.
@return
KErrNone if successful,
KErrNotFound if the setting does not exist,
KErrArgument if the setting exists but is not a descriptor,
KErrOverflow if the descriptor is too small to receive the value in the repository,
plus other system-wide error codes.
@post Transactions fail only on those "other system-wide error codes".
@capability Dependent Caller must satisfy the read access policy of that key in the repository.
*/
EXPORT_C TInt CRepository::Get(TUint32 aKey, TDes8& aValue, TInt& aActualLength)
{
TBuf8<KMaxBinaryLength> val;
TInt ret = iImpl->Get(aKey, val);
if (ret==KErrNone)
{
TInt settingValueLength=val.Length();
//now check whether any string overflow
if (settingValueLength > aValue.MaxLength())
{
aActualLength=settingValueLength;
aValue.Copy(val.Left(aValue.MaxLength()));
return KErrOverflow;
}
else
{
aValue.Copy(val);
}
}
return ret;
}
示例15: Store
EXPORT_C TInt TMetaArrayBase::Store(TDes8& aBuffer) const
/**
* Stores content of a meta object (in iData) to a descriptor
*/
{
if (aBuffer.MaxLength() - aBuffer.Length() < (TInt)sizeof(TInt))
{
return KErrOverflow;
}
TInt count = Count();
aBuffer.Append((TUint8*)&count, sizeof(TInt));
TInt size = SizeOfType();
for ( TInt n = 0; n < count; n++ )
{
if (aBuffer.MaxLength() - aBuffer.Length() < size)
{
return KErrOverflow;
}
aBuffer.Append(At(n), size);
}
return KErrNone;
}