MCPcopy Create free account
hub / github.com/alembic/alembic / ReadStringArrayT

Function ReadStringArrayT

lib/Alembic/AbcCoreHDF5/StringReadUtil.cpp:392–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390//-*****************************************************************************
391template <class StringT, class CharT>
392static AbcA::ArraySamplePtr
393ReadStringArrayT( AbcA::ReadArraySampleCachePtr iCache,
394 hid_t iParent,
395 const std::string &iName,
396 const AbcA::DataType &iDataType )
397{
398 assert( iDataType.getExtent() > 0 );
399
400 // Open the data set.
401 hid_t dsetId = H5Dopen( iParent, iName.c_str(), H5P_DEFAULT );
402 ABCA_ASSERT( dsetId >= 0, "Cannot open dataset: " << iName );
403 DsetCloser dsetCloser( dsetId );
404
405 // Read the data space.
406 hid_t dspaceId = H5Dget_space( dsetId );
407 ABCA_ASSERT( dspaceId >= 0, "Could not get dataspace for dataSet: "
408 << iName );
409 DspaceCloser dspaceCloser( dspaceId );
410
411 // Read the digest, if there's a cache.
412 AbcA::ArraySample::Key key;
413 bool foundDigest = false;
414
415 // If we found a digest and there's a cache, see
416 // if we're in there, and return it if so.
417 if ( iCache )
418 {
419 key.origPOD = iDataType.getPod();
420 key.readPOD = key.origPOD;
421
422 hid_t dsetFtype = H5Dget_type( dsetId );
423 DtypeCloser dtypeCloser( dsetFtype );
424
425 // string arrays get packed together
426 key.numBytes = H5Sget_simple_extent_npoints( dspaceId ) *
427 H5Tget_size( dsetFtype );
428
429 foundDigest = ReadKey( dsetId, "key", key );
430 AbcA::ReadArraySampleID found = iCache->find( key );
431 if ( found )
432 {
433 AbcA::ArraySamplePtr ret = found.getSample();
434 assert( ret );
435 if ( ret->getDataType() != iDataType )
436 {
437 ABCA_THROW( "ERROR: Read data type for dset: " << iName
438 << ": " << ret->getDataType()
439 << " does not match expected data type: "
440 << iDataType );
441 }
442
443 // Got it!
444 return ret;
445 }
446 }
447
448 // Okay, we haven't found it in a cache.
449

Callers

nothing calls this directly

Calls 12

ReadKeyFunction · 0.85
AllocateArraySampleFunction · 0.85
rankMethod · 0.80
numPointsMethod · 0.80
setRankMethod · 0.80
rootPtrMethod · 0.80
ReadDimensionsFunction · 0.70
findMethod · 0.45
getSampleMethod · 0.45
getDataTypeMethod · 0.45
getDataMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected