void SlicedArrayImpl::decodeJSON( JSON::Entity const &entity, void *data ) const
 {
   entity.requireArray();
     
   bits_t *dstBits = reinterpret_cast<bits_t *>(data);
   if ( entity.value.array.size != dstBits->size )
     throw Exception( "JSON array size must equal sliced array size" );
     
   size_t membersFound = 0;
   JSON::ArrayDecoder arrayDecoder( entity );
   JSON::Entity elementEntity;
   while ( arrayDecoder.getNext( elementEntity ) )
   {
     FABRIC_ASSERT( membersFound < entity.value.array.size );
     try
     {
       void *memberData = (void*)m_variableArrayImpl->getImmutableMemberData_NoCheck( &dstBits->rcva->varArray, dstBits->offset + membersFound );
       m_memberImpl->decodeJSON( elementEntity, memberData );
     }
     catch ( Exception e )
     {
       throw _(membersFound) + ": " + e;
     }
     ++membersFound;
   }
   
   FABRIC_ASSERT( membersFound == entity.value.array.size );
 }
Beispiel #2
0
ConstArray::ConstArray(
    RC::ConstHandle<RT::Manager> const &rtManager,
    RC::ConstHandle<RT::Desc> const &elementDesc,
    JSON::Entity const &entity
)
{
    entity.requireArray();
    m_fixedArrayDesc = rtManager->getFixedArrayOf( elementDesc, entity.value.array.size );
    m_data.resize( m_fixedArrayDesc->getAllocSize(), 0 );
    m_fixedArrayDesc->decodeJSON( entity, &m_data[0] );
}