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


C++ TSTRING::begin方法代码示例

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


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

示例1: MakeFile

void MakeFile( TSTRING& strNameMakeMe )
{
    try
    {
        iFSServices* pFSServices = iFSServices::GetInstance(); ASSERT( pFSServices );
        pFSServices->MakeTempFilename( strNameMakeMe );

        std::string strA;
        for( TSTRING::iterator i = strNameMakeMe.begin(); i != strNameMakeMe.end(); i++ )
        {
            char ach[6];
            ASSERT( MB_CUR_MAX <= 6 );

            int n = wctomb( ach, *i );
            ASSERT( n != -1 );
            
            for( int j = 0; j < n; j++ )
                strA += ach[j];
        }

        TOFSTREAM file( strA.c_str() );
        ASSERT( file );
        file.close();
    }
    catch( eFSServices e )
    {
        ASSERT( false );
    }
    catch( ... )
    {
        ASSERT( false );
    }
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:33,代码来源:textreportviewer_t.cpp

示例2: AllTestsRunOnEncodedString

bool cEncoder::AllTestsRunOnEncodedString( const TSTRING& s ) const
{
    TSTRING::const_iterator         cur = s.begin();  // pointer to working position in s
    const TSTRING::const_iterator   end = s.end();    // end of s
    TSTRING::const_iterator         first = end;          // identifies beginning of current character
    TSTRING::const_iterator         last  = end;          // identifies end of current character
    

    // while get next char (updates cur)
    while( cCharUtil::PopNextChar( cur, end, first, last ) )
    {
        sack_type::const_iterator atE;
        for( atE = m_encodings.begin(); 
             atE != m_encodings.end(); 
             atE++ )
        {
            if( (*atE)->NeedsEncoding( first, last ) )
            {
                return false;
            }
        }
    }

    return true;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:25,代码来源:displayencoder.cpp

示例3: util_RemoveDuplicateSeps

////////////////////////////////////////////////////////////////////////////////
// Function name    : util_RemoveDuplicateSeps
// Description      :
// takes all adjacent slashes and replaces them with a single slash
//      ///root//foo -> /root/foo
//      rel//foo///  -> rel/foo/
//
// Return type      : void
// Argument         : TSTRING& strPath
///////////////////////////////////////////////////////////////////////////////
void util_RemoveDuplicateSeps(TSTRING& strPath)
{
    bool              fLastCharWasSep = false;
    TSTRING::iterator iter            = strPath.begin();
    while (iter != strPath.end())
    {
        bool fErasedChar = false;
        // if we've found a char that's not '/', then it's not the root
        if (*iter == TW_SLASH)
        {
            // if this char is a duplicate sep, erase it
            if (fLastCharWasSep)
            {
                iter        = strPath.erase(iter);
                fErasedChar = true;
            }

            fLastCharWasSep = true;
        }
        else
        {
            fLastCharWasSep = false;
        }

        // don't go past end of string (could happen with erase)
        if (!fErasedChar)
            iter++;
    }
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:39,代码来源:unixfsservices.cpp

示例4: HexValueToCharString

TSTRING cCharEncoderUtil::HexValueToCharString( const TSTRING& str )
{
    TSTRING strOut;    
    TSTRING::const_iterator     at;

    for( at = str.begin(); at < str.end(); at += TCHAR_AS_HEX__IN_TCHARS )
    {
        strOut += hex_to_char( at, at + TCHAR_AS_HEX__IN_TCHARS );
    }

    return strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:12,代码来源:displayencoder.cpp

示例5: CharStringToHexValue

TSTRING cCharEncoderUtil::CharStringToHexValue( const TSTRING& str )
{
    TSTRING strOut;
    TSTRING::const_iterator at;

    for( at = str.begin(); at < str.end(); at++ )
    {
        strOut += char_to_hex( *at );
    }

    return strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:12,代码来源:displayencoder.cpp

示例6: Validate

void cParseNamedAttr::Validate() const
{
    if( NamesMatch( twparser::STR_PARSER_RULENAME, mstrName ) )
    {
        // no checking needed
    }
    else if( NamesMatch( twparser::STR_PARSER_EMAILTO, mstrName ) )
    {
        // no checking needed
    }
    else if( NamesMatch( twparser::STR_PARSER_SEVERITY, mstrName ) )
    {
        int iIgnore;
        cSeverityLimits sl;
        if( ! sl.InterpretInt( mstrValue, &iIgnore ) )
            throw eParserBadSevVal( mstrValue, mLineNum );
    }
    else if( NamesMatch( twparser::STR_PARSER_RECURSE, mstrName ) )
    {
        TSTRING str = mstrValue;
        std::transform( str.begin(), str.end(), str.begin(), _totlower );
    
        if( !NamesMatch( twparser::STR_PARSER_FALSE, str ) && !NamesMatch( twparser::STR_PARSER_TRUE, str ) )
        {
            // must be number
            int iIgnore;
            cRecurseDepthLimits rdl;
            if( ! rdl.InterpretInt( str, &iIgnore ) )
                throw eParserUnrecognizedAttrVal( mstrValue, mLineNum );                
        }
    }
    else
    {
        throw eParserUnrecognizedAttr( mstrName, mLineNum );
    }
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:36,代码来源:parserobjects.cpp

示例7: IsRoot

////////////////////////////////////////////////////////////////////////////////
// Function name    : IsRoot
// Description      : A root path is all '/'s
//
// Return type      : bool
// Argument         : const TSTRING& strPath
///////////////////////////////////////////////////////////////////////////////
bool cUnixFSServices::IsRoot(const TSTRING& strPath) const
{
    // and empty path is NOT the root path
    if (strPath.empty())
        return false;

    // check to see if all characters are a slash
    for (TSTRING::const_iterator iter = strPath.begin(); iter != strPath.end(); iter++)
    {
        // if we've found a char that's not '/', then it's not the root path
        if (*iter != TW_SLASH)
            return false;
    }

    return true;
}
开发者ID:Tripwire,项目名称:tripwire-open-source,代码行数:23,代码来源:unixfsservices.cpp

示例8: SplitString

static void SplitString( const TSTRING& str, TCHAR c, std::vector<TSTRING>& vStrings )
{
    vStrings.clear();

    TSTRING::const_iterator i, prev;
    for( prev = i = str.begin(); i != str.end(); i++ )
    {
        if( *i == c )
        {
            vStrings.push_back(TSTRING());
            vStrings.back().assign( prev, i );
            prev = i+1;
        }
    }
    if( prev != i )
    {
        vStrings.push_back(TSTRING());
        vStrings.back().assign( prev, i );
    }
}
开发者ID:brc0x1,项目名称:tripwire-open-source,代码行数:20,代码来源:dbexplore.cpp

示例9: Encode

void cEncoder::Encode( TSTRING& strIn ) const
{
    // TODO:BAM -- reserve space for strOut as an optimization?
    TSTRING strOut;         // encoded string we will build up

    TSTRING::const_iterator         cur = strIn.begin();  // pointer to working position in strIn
    const TSTRING::const_iterator   end = strIn.end();    // end of strIn
    TSTRING::const_iterator         first = end;          // identifies beginning of current character
    TSTRING::const_iterator         last  = end;          // identifies end of current character

    // while get next char (updates cur)
    while( cCharUtil::PopNextChar( cur, end, first, last ) )
    {
        bool fCharEncoded = false; // answers: did char need encoding?
        sack_type::const_iterator atE;

        // for all encoders
        for( atE = m_encodings.begin(); 
             atE != m_encodings.end();
             atE++ )
        {
            // does char need encoding?
            if( (*atE)->NeedsEncoding( first, last ) )
            {
                strOut += Encode( first, last, atE );
                fCharEncoded = true;
                break;  // each char should only fail at most one 
                        // encoding test, so it should be cool to quit
            }
        }

        if( ! fCharEncoded )
        {
            strOut.append( first, last ); // simply add current char to output since it needed no encoding
        }
    }

    // pass back encoded string
    strIn = strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:40,代码来源:displayencoder.cpp

示例10: Decode

void cEncoder::Decode( TSTRING& strIn ) const
{
    // TODO:BAM -- reserve space for strOut as an optimization?
    TSTRING strOut;         // decoded string we will build up

    TSTRING::const_iterator         cur = strIn.begin();  // pointer to working position in strIn
    const TSTRING::const_iterator   end = strIn.end();    // end of strIn
    TSTRING::const_iterator         first = end;          // identifies beginning of current character
    TSTRING::const_iterator         last  = end;          // identifies end of current character
    

    // while get next char (updates cur)
    while( cCharUtil::PopNextChar( cur, end, first, last ) )
    {
        // is this char the escape character?
        if( IsSingleTCHAR( first, last ) && 
            *first == iCharEncoder::EscapeChar() )
        {
            // get to identifier
            if( ! cCharUtil::PopNextChar( cur, end, first, last ) )
                ThrowAndAssert( eBadDecoderInput() );
            
            // this algorithm assumes that all identifiers are single char
            // so anything following the escape char should be a 
            // single-char identifier
            if( ! IsSingleTCHAR( first, last ) ) 
                THROW_INTERNAL( "displayencoder.cpp" );

            // determine to which encoding the identifier belongs
            bool fFoundEncoding = false;
            sack_type::const_iterator atE;
            for( atE = m_encodings.begin(); 
                 atE != m_encodings.end(); 
                 atE++ )
            {
                // is this the right encoding?
                if( *first == (*atE)->Identifier() )
                {
                    // this is the correct encoding....
                    fFoundEncoding = true;

                    // ...so decode char
                    strOut += (*atE)->Decode( &first, end ); // should modify cur
                    
                    cur = first; // advance current char pointer

                    break;  // no need to run other tests after 
                            // this because all identifiers should be unique
                }
            }

            if( ! fFoundEncoding )
                ThrowAndAssert( eUnknownEscapeEncoding( TSTRING( 1, *first ) ) );
        }
        else
        {        
            strOut.append( first, last );
        }
    }

    strIn = strOut;
}
开发者ID:faical-yannick-congo,项目名称:tripwire-open-source,代码行数:62,代码来源:displayencoder.cpp


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