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


C++ WideString::GetSize方法代码示例

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


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

示例1: SerializeWideString

/// @copydoc Serializer::SerializeWideString()
void BinarySerializer::SerializeWideString( WideString& rValue )
{
    if( ShouldSerializeCurrentProperty() )
    {
        HELIUM_ASSERT( rValue.GetSize() <= UINT32_MAX );
        uint32_t stringLength = static_cast< uint32_t >( rValue.GetSize() );
        m_pPropertyStream->Write( &stringLength, sizeof( stringLength ), 1 );

        m_pPropertyStream->Write( rValue.GetData(), sizeof( wchar_t ), stringLength );
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:12,代码来源:BinarySerializer.cpp

示例2: StringBase

/// Copy constructor.
///
/// When copying, only the memory needed to hold onto the used contents of the source string will be allocated (i.e.
/// if the source string has 10 elements but a capacity of 20, only memory for the 10 used elements will be
/// allocated for this copy).
///
/// @param[in] rSource  String from which to copy.
WideString::WideString( const WideString& rSource )
    : StringBase( rSource.GetData(), rSource.GetSize() )
{
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例3: CacheEntry


//.........这里部分代码省略.........
            else
            {
                pEntryUpdate->offset = originalOffset;
                pEntryUpdate->timestamp = originalTimestamp;
                pEntryUpdate->size = originalSize;
            }

            bCacheSuccess = false;
        }
        else
        {
            size_t writeSize = pCacheStream->Write( pData, 1, size );
            if( writeSize != size )
            {
                HELIUM_TRACE(
                    TRACE_ERROR,
                    ( TXT( "Cache: Failed to write %" ) TPRIu32 TXT( " bytes to cache \"%s\" (%" ) TPRIuSZ
                    TXT( " bytes written).\n" ) ),
                    size,
                    *m_cacheFileName,
                    writeSize );

                if( bNewEntry )
                {
                    m_entries.Pop();
                    m_entryMap.Remove( entryAccessor );
                    m_pEntryPool->Release( pEntryUpdate );
                }
                else
                {
                    pEntryUpdate->offset = originalOffset;
                    pEntryUpdate->timestamp = originalTimestamp;
                    pEntryUpdate->size = originalSize;
                }

                bCacheSuccess = false;
            }
            else
            {
                HELIUM_TRACE( TRACE_INFO, TXT( "Cache: Rewriting TOC file \"%s\".\n" ), *m_tocFileName );

                FileStream* pTocStream = File::Open( m_tocFileName, FileStream::MODE_WRITE, true );
                if( !pTocStream )
                {
                    HELIUM_TRACE( TRACE_ERROR, TXT( "Cache: Failed to open TOC \"%s\" for writing.\n" ), *m_tocFileName );
                }
                else
                {
                    BufferedStream* pBufferedStream = new BufferedStream( pTocStream );
                    HELIUM_ASSERT( pBufferedStream );

                    pBufferedStream->Write( &TOC_MAGIC, sizeof( TOC_MAGIC ), 1 );
                    pBufferedStream->Write( &sm_Version, sizeof( sm_Version ), 1 );

                    uint32_t entryCount = static_cast< uint32_t >( m_entries.GetSize() );
                    pBufferedStream->Write( &entryCount, sizeof( entryCount ), 1 );

                    WideString entryPath;
#if !HELIUM_UNICODE
                    CharString entryPathCharString;
#endif
                    uint_fast32_t entryCountFast = entryCount;
                    for( uint_fast32_t entryIndex = 0; entryIndex < entryCountFast; ++entryIndex )
                    {
                        Entry* pEntry = m_entries[ entryIndex ];
                        HELIUM_ASSERT( pEntry );

#if HELIUM_UNICODE
                        pEntry->path.ToString( entryPath );
#else
                        pEntry->path.ToString( entryPathCharString );
                        StringConverter< char, wchar_t >::Convert( entryPath, entryPathCharString );
#endif

                        HELIUM_ASSERT( entryPath.GetSize() < UINT16_MAX );
                        uint16_t pathSize = static_cast< uint16_t >( entryPath.GetSize() );
                        pBufferedStream->Write( &pathSize, sizeof( pathSize ), 1 );

                        pBufferedStream->Write( *entryPath, sizeof( tchar_t ), pathSize );

                        pBufferedStream->Write( &pEntry->subDataIndex, sizeof( pEntry->subDataIndex ), 1 );

                        pBufferedStream->Write( &pEntry->offset, sizeof( pEntry->offset ), 1 );
                        pBufferedStream->Write( &pEntry->timestamp, sizeof( pEntry->timestamp ), 1 );
                        pBufferedStream->Write( &pEntry->size, sizeof( pEntry->size ), 1 );
                    }

                    delete pBufferedStream;
                    delete pTocStream;
                }
            }
        }

        delete pCacheStream;
    }

    rLoader.Unlock();

    return bCacheSuccess;
}
开发者ID:,项目名称:,代码行数:101,代码来源:


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