本文整理汇总了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;
}
示例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;
}
示例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;
}