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


C++ TDesC8::FindC方法代码示例

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


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

示例1: ParseRangeHeader

// -----------------------------------------------------------------------------
//  CUpnpHttpSession::ParseRangeHeader
//  Parse range values
// -----------------------------------------------------------------------------
//    
TBool CUpnpRangeHeaderParser::ParseRangeHeader( TDesC8& aRangeHeader, TInt& aStartPos,
                                                TInt& aEndPos )
    {
    // Check header's syntax: "bytes=x-y" where y i optional
    TInt pos( KErrNotFound );

    // 1 string has to contain "="
    pos = aRangeHeader.FindC( UpnpString::KEqual() );
    if( pos == KErrNotFound ) 
        return EFalse;

    // 2 "bytes" has to be at the beginnig
    pos = aRangeHeader.FindC( UpnpHTTP::KBytes() );
    if( pos == KErrNotFound || pos != 0 ) 
        return EFalse;

    // 3 Sets position to after bytes
    pos = UpnpHTTP::KBytes().Length();

    // 4 If there any space or tab after "bytes" - move pos after it
    CUpnpRangeHeaderParser::MovePosition( aRangeHeader, pos );

    // 5 "=" - has to be at this position (after "bytes" + spaces or tabs)
    if( aRangeHeader[ pos ] != UpnpString::KEqual()[0] )
        return EFalse;

    // 6 Sets position to after "="
    pos++;

    // 7 If there any space or tab after "=" - move pos after it
    CUpnpRangeHeaderParser::MovePosition( aRangeHeader, pos );
    
    // 8 extract x-y. -1 stands for '=' length
    TPtrC8 byteRange = aRangeHeader.Right( aRangeHeader.Length() - pos );

    // 9 There can't be any comas because multi-range is not allowed
    if( byteRange.Find( UpnpString::KComa() ) != KErrNotFound ) 
        return EFalse;

    // 10 "-" delimiter must occure and it cant't be first char, because notation as follows: "-y"  is not allowed
    pos = byteRange.Find( UpnpString::KMinus() );
    if( pos == KErrNotFound ) 
        return EFalse;
    
    // 11 Checks if it is a final bytes request
    // e.g. Range: bytes= -20
    if( pos == 0 )
        {
        // If there any space or tab after "-" - move pos after it
        CUpnpRangeHeaderParser::MovePosition( byteRange.Right( byteRange.Length()-1 ), pos );
        // if pos equal 0 should be 1 to avoid "-" in getting number from string operation
        pos = pos == 0 ? 1 : pos;
        TLex8 endMinus( byteRange.Right( byteRange.Length() - pos  ) );
        endMinus.SkipSpace();
        TInt error = endMinus.Val( aEndPos );
        if ( !CUpnpRangeHeaderParser::HandleConversionException( endMinus, aEndPos, error ) )
            {
            return EFalse;
            }
            
        // We have to check if something else than space or tab leaves after conversion - unless for example 11a will be correct but it is not
        if ( CUpnpRangeHeaderParser::HasImproperChars( endMinus ) )
            return EFalse;
         
        aStartPos = KErrNotFound;
        return ETrue;
        }

    // 12 All looks fine, so now parse it and get x and y
    TLex8 start( byteRange.Left( pos ) );
    start.SkipSpace();

    // 13 If conversion fails - return error
    TInt error = start.Val( aStartPos );
    if ( !CUpnpRangeHeaderParser::HandleConversionException( start, aStartPos, error ) )
        {
        return EFalse;
        }
    // 14 We have to check if something else than space or tab leaves after conversion - unless for example 11a will be correct but it is not
    if ( CUpnpRangeHeaderParser::HasImproperChars( start ) )
            return EFalse;

    // y is optional
    if( ( byteRange.Length() - pos - 1 ) > 0 )
        {
        TLex8 end( byteRange.Right( byteRange.Length() - pos - 1 ) );
        end.SkipSpace();
        
        error = end.Val( aEndPos );
        if ( !CUpnpRangeHeaderParser::HandleConversionException( end, aEndPos, error ) )
            {
            return EFalse;
            }
            
        // We have to check if something else than space or tab leaves after conversion - unless for example 11a will be correct but it is not
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:101,代码来源:upnprangeheaderparser.cpp


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