当前位置: 首页>>代码示例>>C++>>正文


C++ HBufC8::Length方法代码示例

本文整理汇总了C++中HBufC8::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ HBufC8::Length方法的具体用法?C++ HBufC8::Length怎么用?C++ HBufC8::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HBufC8的用法示例。


在下文中一共展示了HBufC8::Length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadOldVersionFileL

TInt CVersionFileReader::ReadOldVersionFileL(const TDesC& aFilename)
{
   // The file contains a string matching this regex
   // [0-9]\+\.[0-9]\+_[0-9]\+
   iOldVersionArray->Reset();
   class RFs& fs = CCoeEnv::Static()->FsSession();
   class RFile versionFile;
   TInt ret = versionFile.Open(fs, aFilename, 
                               EFileStreamText | EFileRead);
   if(ret != KErrNone) {
      /* Could not open file, return the error code */
      return ret;
   }
   HBufC8* line = HBufC8::NewLC(30);
   TInt pos = -1;
   versionFile.Seek(ESeekStart, pos);
   TPtr8 pLine = line->Des();
   ret = versionFile.Read(pLine);
   iOldVersionArray->AppendL(*line);
   if(line->Length() == 0) {
      versionFile.Close();
      return KErrEof;
   }
   versionFile.Close();
   if(line->Locate('_') != KErrNotFound) {
      iOldVersionArray->AppendL(line->Left(line->Locate('_')));
      iOldVersionArray->AppendL(line->Right(line->Length() - line->Locate('_') - 1));
   } else {
      iOldVersionArray->AppendL(*line);
   }

   CleanupStack::PopAndDestroy(line);

   return ret;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:35,代码来源:VersionFileReader.cpp

示例2: ptr

EXPORT_C HBufC8* CTestConfig::ReplaceLC(const TDesC8& aOld, const TDesC8& aNew, const TDesC8& aOldString)
    {
    HBufC8* rString = aOldString.AllocLC();
    TInt oldLen = aOld.Length();
    TInt newLen = aNew.Length();

    if (!oldLen)
        return rString;

    for (TInt pos = 0; pos < rString->Length(); pos += newLen)
        {
        TPtrC8 ptrC = rString->Mid(pos);
        TInt find = ptrC.Find(aOld);

        if (find == KErrNotFound)
            return rString;
    
        pos += find;

        if (newLen > oldLen)
            {
            rString = rString->ReAllocL(rString->Length() + newLen - oldLen);
            CleanupStack::Pop();
            CleanupStack::PushL(rString);
            }

        TPtr8 ptr(rString->Des());
        ptr.Replace(pos, oldLen, aNew);
        }

    return rString;
    }
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:32,代码来源:testconfigfile.cpp

示例3: ToTextHeaderPartLC

// -----------------------------------------------------------------------------
// CSIPMessage::ToTextHeaderPartLC
// -----------------------------------------------------------------------------
//
EXPORT_C CBufBase* CSIPMessage::ToTextHeaderPartLC ()
    {
    const TInt KResultBufExpandSize = 100;
    CBufFlat* encodedHeaderPart = CBufFlat::NewL(KResultBufExpandSize);
    CleanupStack::PushL(encodedHeaderPart);
    HBufC8* firstLine = ToTextFirstLineLC ();    
    encodedHeaderPart->InsertL (0,*firstLine);
    TInt encodedLength = firstLine->Length();
    CleanupStack::PopAndDestroy(firstLine);
    encodedHeaderPart->InsertL (encodedLength,KCRLF);
    encodedLength += KCRLF().Length();

    // Add headers
    for (TInt i=0; i < iSIPHeaderListArray.Count(); i++)
        {
        TSglQueIter<CSIPHeaderBase> iter(iSIPHeaderListArray[i]);
        TInt headerCountInList=0;
        while (iter)
            {
            CSIPHeaderBase* header = iter++;
            HBufC8* headerAsText = NULL;
            if (++headerCountInList == 1 || !header->EncodeMultipleToOneLine())
                {
                headerAsText = header->ToTextLC();
                }
            else
                {
                headerAsText = header->ToTextValueLC();
                }
            encodedHeaderPart->InsertL (encodedLength,*headerAsText);
            encodedLength += headerAsText->Length();
            CleanupStack::PopAndDestroy(headerAsText);
            if (!iter || !header->EncodeMultipleToOneLine())
                {
                encodedHeaderPart->InsertL (encodedLength,KCRLF);
                encodedLength += KCRLF().Length();
                }
            else 
                {
                encodedHeaderPart->InsertL (encodedLength,KComma);
                encodedLength += KComma().Length();
                }
            }
        }

    // Add Content-Length header
    HBufC8* contentLengthHeaderAsText = ToTextContentLengthLC ();
    encodedHeaderPart->InsertL (encodedLength,*contentLengthHeaderAsText);
    encodedLength += contentLengthHeaderAsText->Length();
    CleanupStack::PopAndDestroy(contentLengthHeaderAsText);

    // Add CRLF CRLF ending the header part
    encodedHeaderPart->InsertL (encodedLength,KCRLFCRLF);
    encodedLength += KCRLFCRLF().Length();

    return encodedHeaderPart;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:61,代码来源:CSIPMessage.cpp

示例4: ReadNewVersionFileL

TInt CVersionFileReader::ReadNewVersionFileL(const TDesC& versionFile)
{
   iNewVersionArray->Reset();
   class RFs& fs = CCoeEnv::Static()->FsSession();
   class RFile file;
   TInt ret = file.Open(fs, versionFile, 
                        EFileStreamText | EFileRead);
   if(ret != KErrNone) {
      /* Could not open file, return the error code */
      return ret;
   }
   
   HBufC8* line = HBufC8::NewLC(40);
   TInt pos = -1;
   file.Seek(ESeekStart, pos);
   TPtr8 pLine = line->Des();
   ret = file.Read(pLine);
   if(line->Length() == 0) {
      // Empty file
      file.Close();
      return KErrEof;
   }
   file.Close();

   // The file contains a string that should match this regex:
   // [0-9]+\.[0-9]+\.[0-9]\+:[0-9]+\.[0-9]+\.[0-9]\+:[0-9]\+
   // The string is separated into three parts by ':'. 
   // The first part is the application version
   // The second part is the resource version
   // The third part is the mlfw version.
   const TChar colon = ':';
   const TChar dot = '.';
   while(line->Length() > 0) {
      if(line->Locate(colon) != KErrNotFound) {
         TPtrC8 part = line->Left(line->Locate(colon));
         TPtrC8 version = part.Left(part.LocateReverse(dot));
         TPtrC8 misc = part.Right(part.Length() - part.LocateReverse(dot) - 1);
         iNewVersionArray->AppendL(part);
         iNewVersionArray->AppendL(version);
         iNewVersionArray->AppendL(misc);
         line->Des().CopyF(line->Right(line->Length() - line->Locate(colon) - 1));
      } else {
         iNewVersionArray->AppendL(*line);
         break;
      }
   }
   CleanupStack::PopAndDestroy(line);
   return 0;
}
开发者ID:VLjs,项目名称:Wayfinder-S60-Navigator,代码行数:49,代码来源:VersionFileReader.cpp

示例5: infoBuf

///////////////////////////////////////////////////////////////////////////////
//
// Private methods
//
///////////////////////////////////////////////////////////////////////////////
HBufC8* CIkev1Dialog::CreateDialogInput(TIPSecDialogInfo& aDialogInfo, TBool aUserNameCache)
{
    //
    // Create dialog input data buffer. Concatenate cached user name
    // string into input data if requested and if cached name exists
    //
    HBufC8* DialogInput;
    HBufC8* UserName = NULL;
    TInt    UserNameLth = 0;	
    TPckgBuf<TIPSecDialogInfo> infoBuf(aDialogInfo);
    
    if ( aUserNameCache ) {
       UserName = GetUserNameFromFile();
       if ( UserName )
          UserNameLth = UserName->Length();
    }

    DialogInput = HBufC8::New(sizeof(TIPSecDialogInfo) + UserNameLth);
    if ( DialogInput ) {
       DialogInput->Des().Copy(infoBuf);
       if ( UserName ) {
          DialogInput->Des().Append(UserName->Des());
          delete UserName;
       }	  
    }   

    return DialogInput;
}   
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:33,代码来源:ikev1dialog.cpp

示例6: fullname

// -----------------------------------------------------------------------------
// CSIPHeaderBase::ToTextL
// -----------------------------------------------------------------------------
//
EXPORT_C HBufC8* CSIPHeaderBase::ToTextL() const
    {
    TPtrC8 fullname(Name().DesC());
    // Because SIP Codec's string table has entry "expires" before "Expires",
    // and entry "require" before "Require",
    // literal "Expires" and "Require" must be used here. 
    // Changing the order of string table entries would have caused a SC break.	
    if (Name() == SIPStrings::StringF(SipStrConsts::EExpiresHeader))
        {
        fullname.Set(KExpiresHeaderNameDes);
        }
    else if (Name() == SIPStrings::StringF(SipStrConsts::ERequireHeader))
        {
        fullname.Set(KRequireHeaderNameDes);
        }
    else
        {
        }
    TUint headerLength = fullname.Length();
    headerLength += KColonAndSpace().Length();
    HBufC8* encodedHeaderValue = ToTextValueL();
    headerLength += encodedHeaderValue->Length();

    CleanupStack::PushL (encodedHeaderValue);

    HBufC8* encodedHeader = HBufC8::NewL(headerLength);
    TPtr8 encodedHeaderPtr = encodedHeader->Des(); 
    encodedHeaderPtr.Append(fullname);
    encodedHeaderPtr.Append(KColonAndSpace);
    encodedHeaderPtr.Append(*encodedHeaderValue);
    
    CleanupStack::PopAndDestroy(encodedHeaderValue);

    return encodedHeader;
    }
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:39,代码来源:CSIPHeaderBase.cpp

示例7: GetData

// From MMDXMLParserDataProvided
// TODO: Should GetData be a leaving function? Allows more flexibility to implementations of this funtion?
void CTestDataSupplier::GetData(TPtrC8 &aPtr, TRequestStatus &aStatus)
    {
    // Read the data into the descriptor
    delete iCurrentChunk;
    iCurrentChunk = NULL;
    iCurrentChunk = HBufC8::NewL(iChunkSize);
    TPtr8 chunk = iCurrentChunk->Des();
    iFile.Read(chunk, iChunkSize); // Ignore the error code, assume end of file if we haven't read any data.

    TDataProviderResults result;

    if (iCurrentChunk->Length() != 0)
        {
        aPtr.Set(*iCurrentChunk);
        result = KMoreData;
        }
    else
        {
        // Assume that if we haven't got any data then we're at the end of the stream.
        result = KDataStreamEnd;
        }

//	iChunkSize++;
    TRequestStatus *s = &aStatus;
    User::RequestComplete(s, (TInt)result);
    return;
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:29,代码来源:smiltranslatortest.cpp

示例8: WriteContentLineL

/**
Writes the current content line to the stream after conversion to UTF-8.
Performs any necessary folding.
@internalTechnology
*/
void CICalContentLineWriter::WriteContentLineL()
    {
    TRACE_ENTRY_POINT;
    
    // Convert to UTF-8 for writing
    HBufC8* tmpLine = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iCurrentLine);
    CleanupStack::PushL(tmpLine);
    
    TInt pos(0);
    TInt remaining(tmpLine->Length());
    
    // Fold the line if longer than 75 octets
    TInt lineLength(KICalMaxLineLength);
    
    while (remaining > lineLength)
        {
        iWriteStream.WriteL(tmpLine->Mid(pos), lineLength);
        iWriteStream.WriteL(KICalFoldLine);
        pos += lineLength;
        remaining -= lineLength;
        lineLength = KICalMaxFoldedLineLength;
        }
        
    // Complete the line
    iWriteStream.WriteL(tmpLine->Mid(pos));
    iWriteStream.WriteL(KICalCRLF);	

    CleanupStack::PopAndDestroy(tmpLine);
    
    iCurrentLine->Des().SetLength(0);
    
    TRACE_EXIT_POINT;
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:38,代码来源:ICalContentLineWriter.cpp

示例9:

HBufC* CSTPreferences::ReadAndConvertFromUtf8ToUnicodeL(RFile& aFile, TInt aLength)
{
    HBufC8* utfBuffer = HBufC8::NewLC(aLength);
    TPtr8 utfBufferPtr = utfBuffer->Des();
    
    if ((aFile.Read(utfBufferPtr, aLength) != KErrNone) ||
        (utfBuffer->Length() != aLength))
    {
        CleanupStack::PopAndDestroy(); // utfBuffer
        return NULL;
    }			
    
    HBufC* unicodeBuffer = HBufC::NewLC(aLength);
    TPtr unicodeBufferPtr = unicodeBuffer->Des();
    
    if (CnvUtfConverter::ConvertToUnicodeFromUtf8(unicodeBufferPtr, *utfBuffer) != KErrNone)
    {
        CleanupStack::PopAndDestroy(); // unicodeBuffer
        CleanupStack::PopAndDestroy(); // utfBuffer
        return NULL;
    }
    
    CleanupStack::Pop(); // unicodeBuffer
    CleanupStack::PopAndDestroy(); // utfBuffer

    return unicodeBuffer;
}
开发者ID:Nokia700,项目名称:SymTorrent,代码行数:27,代码来源:STPreferences.cpp

示例10: UPPayNetRequest

int UPPayNetRequest(const TDesC& aAddr,const char* result, char** response)
{
    int ret = 0; 
    CSyncHttpConnection* httpConnection = new CSyncHttpConnection();
    int len = strlen(result);
    TPtr8 ptr((TUint8 *)result,len,len);
    //CommonUtils::WriteLogL(_L("send!!!!!!!!!!!!!!!!!!!!!:\n"));
    //CommonUtils::WriteLogL(ptr,len);
    TBool error = EFalse;
    //httpConnection->GetRespone(_L("http://www.baidu.com"),error);//http://202.101.25.178:8080/Gateway/MobilePayment  //http://222.66.233.198:8080/Gateway/MobilePayment
    HBufC8* res = httpConnection->PostRespone(aAddr,ptr,error);////
    if(res)
    {
        len = res->Length()+1;
        *response = (char*)User::Alloc(len);
        if(*response)
        {
            memset(*response,0,len);
            Mem::Copy(*response,res->Ptr(),len-1);
            ret = 1;
            //CommonUtils::WriteLogL(_L("\nreceive!!!!!!!!!!!!!!!!!!!!!:\n"));
            //CommonUtils::WriteLogL(res->Des(),ret);
            //CommonUtils::WriteLogL(_L("\nend!!!!!!!!!!!!!!!!!!!!!\n"));
        }
    }
    delete httpConnection;
    return ret;
}
开发者ID:zhonghualee,项目名称:TestSymbian,代码行数:28,代码来源:UPPayHttpConnection.cpp

示例11: IorepReadL

void CIoFile::IorepReadL(MIoReader& aReader)
    {
    TInt fileSize;
    User::LeaveIfError(iFile.Size(fileSize));
    if (iPos < fileSize)
        {
        TDes& readBuf = aReader.IorReadBuf();
        iTempReadBuf.Zero();
        HBufC8* narrowBuf = HBufC8::NewLC(readBuf.MaxLength());
        TPtr8 narrowBufPtr(narrowBuf->Des());
        User::LeaveIfError(iFile.Read(narrowBufPtr, readBuf.MaxLength()));
        iPos += narrowBuf->Length();
        iTempReadBuf.AppendUtf8L(narrowBufPtr);
        if (iPos >= fileSize)
            {
            iTempReadBuf.FinalizeUtf8();
            }
        readBuf.Copy(iTempReadBuf);
        aReader.IorDataBuffered(readBuf.Length());
        CleanupStack::PopAndDestroy(narrowBuf);
        if (iPos >= fileSize)
            {
            aReader.IorReadComplete(KErrNone);
            }
        }
    else
        {
        aReader.IorReadComplete(KErrEof);
        }
    }
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:30,代码来源:file.cpp

示例12: WriteData

// ---------------------------------------------------------------------------
// WriteData()
// ---------------------------------------------------------------------------
//
TInt TReportUtils::WriteData(HBufC8& aData, const CField* aField,
    TInt aIndex, TInt aValue)
    {
    if ( 0 <= aIndex && aIndex < aField->Count() )
        {
        // The offset in bits from the start of the report to the value
        TInt offset = aField->Offset() + aIndex * aField->Size();

        // How many bits in the least significant byte are not part of the value
        TInt bitsToShift = offset & KThreeLSB;

        TUint mask = KValueMask >> ((KSizeOfByte * sizeof(TInt)) - aField->Size());
        mask <<= bitsToShift;
        aValue <<= bitsToShift;

        TPtr8 data = aData.Des();

        // Write out the bytes, least significant first
        for ( TInt i = offset >> KThreeLSBShift; mask && i < aData.Length(); i++ )
            {
            TUint8 maskByte = static_cast<TUint8>(mask);

            // The extra cast is because MSVC6 thinks that or-ing 2
            // TUint8s together gives an int.
            data[i] = static_cast<TUint8>(
                (static_cast<TUint8>(aValue) & maskByte)
                | (aData[i] & ~maskByte));
            mask >>= KSizeOfByte;
            aValue >>= KSizeOfByte;
            }

        return KErrNone;
        }
开发者ID:kuailexs,项目名称:symbiandump-mw3,代码行数:37,代码来源:hidreportbase.cpp

示例13: SaveSettingL

void CSTPreferences::SaveSettingL(RFile& aFile, const TDesC8& aSettingName, const TDesC& aSettingValue)
{
    aFile.Write(aSettingName);
    aFile.Write(KLit8Colon);
    
    
    HBufC8* encodedSettingValue = ConvertToUtf8L(aSettingValue);
    if (encodedSettingValue)
    {
        CleanupStack::PushL(encodedSettingValue);
        
        TBuf8<16> settingLength;
        settingLength.Num(encodedSettingValue->Length());
        aFile.Write(settingLength);
        
        aFile.Write(KLit8EqualSign);
        aFile.Write(*encodedSettingValue);
        CleanupStack::PopAndDestroy(); // encodedSettingValue
    }
    else
    {
        _LIT8(KLit8Unset, "0=");
        aFile.Write(KLit8Unset);
    }
    
    aFile.Write(KLit8EndLine);
}
开发者ID:Nokia700,项目名称:SymTorrent,代码行数:27,代码来源:STPreferences.cpp

示例14: LoadMappingsL

void Cdmatest::LoadMappingsL()
    {
    TDataType type; 
    HBufC8 *data = LoadFileLC( KMappingTableFile,  type );
    RDesReadStream buf( *data );
    CleanupClosePushL( buf );

    TInt len( data->Length() );
    while (buf.Source()->TellL( MStreamBuf::ERead ).Offset() < len)
        {
        TUint32 val = buf.ReadUint32L();
        TBuf8<256> uri;
        TBuf8<64> luid;
        buf.ReadL(uri, val);
        val = buf.ReadUint32L();
        buf.ReadL(luid, val);
        TMapping m( uri, luid ) ;
        TInt err( iMappingTable.Append( m )	);
        if ( err == KErrNone )
            {
            iLog->Log( _L8( "Loaded mapping: '%S' : '%S'"), &m.iURI, &m.iLuid );
            }
        else
            {
            iLog->Log( _L8( "FAILED TO Load mapping: '%d' "), err );
            }
        }
    CleanupStack::PopAndDestroy( &buf); // buf
    CleanupStack::PopAndDestroy( data ); // data
    }
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:30,代码来源:dmatest.cpp

示例15: ParseIkeDataL

void CPolicyImporter::ParseIkeDataL()
    {
    LOG_("-> CPolicyImporter::ParseIkeDataL()");

    HBufC* polFile = iFileUtil.MakeFileNameLC(iImportDir, iCurrPolicyId, KPolFileExt);

    if (!iFileUtil.FileExists(*polFile))
        {
        LOG_("<- CPolicyImporter::ParseIkeDataL() LEAVE (KVpnErrNoPolicyFile)");
        User::Leave(KVpnErrNoPolicyFile);
        }

    HBufC8* fileData = iFileUtil.LoadFileDataL(*polFile);
    CleanupStack::PushL(fileData);

    HBufC* fileData16 = HBufC::NewLC(fileData->Length());

    fileData16->Des().Copy(*fileData);

    delete iCurrIkeDataArray;
    iCurrIkeDataArray = NULL;
    iCurrIkeDataArray = CIkeDataArray::NewL(1);

    TIkeParser* ikeParser = new (ELeave) TIkeParser(*fileData16);
    CleanupStack::PushL(ikeParser);
    ikeParser->ParseIKESectionsL(iCurrIkeDataArray);

    CleanupStack::PopAndDestroy(4); // ikeParser, fileData16, fileData, polFile
    LOG_("<- CPolicyImporter::ParseIkeDataL()");
    }
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:30,代码来源:policyimporter.cpp


注:本文中的HBufC8::Length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。