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


C++ DataElement::decodeFrom方法代码示例

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


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

示例1: decodeFrom

// Decode this element starting at the index in the provided buffer
size_t HLAvariableArray::decodeFrom( const std::vector<Octet>& buffer, size_t index )
	throw( EncoderException )
{
	size_t available = buffer.size();
	if( index + BitHelpers::LENGTH_INT > available )
		throw EncoderException( L"Insufficient data in buffer to decode value" );

	// Decode received array size
	HLAinteger32BE size;
	index = size.decodeFrom( buffer, index );
	size_t receivedSize = size.get();

	// Resize to the new element count. This will either add element clones, or cull the end of
	// the existing list until it is the right size
	this->_impl->resize( receivedSize );

	// Decode all the elements!
	for( size_t i = 0 ; i < receivedSize ; ++i )
	{
		DataElement* element = this->_impl->get( i );
		index = element->decodeFrom( buffer, index );
	}

	return index;
}
开发者ID:JeanPhilippeLebel,项目名称:portico,代码行数:26,代码来源:HLAvariableArray.cpp

示例2: decodeFrom

// Decode this element starting at the index in the provided buffer
size_t HLAfixedArray::decodeFrom( const std::vector<Octet>& buffer, size_t index )
throw( EncoderException )
{
    size_t available = buffer.size();
    if( index + BitHelpers::LENGTH_INT > available )
        throw EncoderException( L"Insufficient data in buffer to decode value" );

    // Decode received array size
    HLAinteger32BE size;
    index = size.decodeFrom( buffer, index );

    size_t receivedSize = size.get();
    if( receivedSize != this->size() )
    {
        // Received array size was different to what we were expecting, so throw an exception
        std::wstringstream stream;
        stream << L"Element count in decoded array differs. Expected[" <<
               this->size() <<
               "] Received [" <<
               receivedSize << "]";

        throw EncoderException( stream.str() );
    }

    // Decode all the elements!
    for( size_t i = 0 ; i < receivedSize ; ++i )
    {
        DataElement* element = this->_impl->get( i );
        index = element->decodeFrom( buffer, index );
    }

    return index;
}
开发者ID:JeanPhilippeLebel,项目名称:portico,代码行数:34,代码来源:HLAfixedArray.cpp

示例3: decodeFrom

// Decode this element starting at the index in the provided buffer
size_t HLAfixedRecord::decodeFrom( const std::vector<Octet>& buffer, size_t index )
	throw( EncoderException )
{
	// Decode all the elements!
	for( size_t i = 0 ; i < this->size() ; ++i )
	{
		DataElement* element = this->_impl->get( i );
		index = element->decodeFrom( buffer, index );
	}

	return index;
}
开发者ID:JeanPhilippeLebel,项目名称:portico,代码行数:13,代码来源:HLAfixedRecord.cpp


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