/** * Gets the number of variable attributes. * @return The number of variable attributes in the opened file. */ int HDF5FileReader::getNumberOfVariableAttributes() { int numVAttributes; //get the first variable and see how many attributes. They should all be the same. H5::DataSet dataset = this->variableGroup->openDataSet(this->variableGroup->getObjnameByIdx(0)); numVAttributes = dataset.getNumAttrs(); return numVAttributes; }
void ossim_hdf5::printObject( H5::H5File* file, const std::string& objectName, const std::string& prefix, std::ostream& out ) { #if 0 std::cout << "printObject entered..." << "\nobjectName: " << objectName << "\nprefix: " << prefix << std::endl; #endif H5::DataSet dataset = file->openDataSet( objectName ); // Get the class of the datatype that is used by the dataset. H5T_class_t type_class = dataset.getTypeClass(); out << prefix << ".class_type: " << ossim_hdf5::getDatatypeClassType( type_class ) << std::endl; const ossim_uint32 ATTRS_COUNT = dataset.getNumAttrs(); for ( ossim_uint32 aIdx = 0; aIdx < ATTRS_COUNT; ++aIdx ) { H5::Attribute attr = dataset.openAttribute( aIdx ); ossim_hdf5::printAttribute( attr, prefix, out ); attr.close(); } // Extents: std::vector<ossim_uint32> extents; ossim_hdf5::getExtents( &dataset, extents ); for ( ossim_uint32 i = 0; i < extents.size(); ++i ) { ossimString os; std::string exStr = ".extent"; exStr += os.toString(i).string(); out << prefix << exStr << ": " << extents[i] << std::endl; } // ossimScalarType scalar = getScalarType( type_class, dataset.getId() ); ossimScalarType scalar = ossim_hdf5::getScalarType( dataset.getId() ); if ( scalar != OSSIM_SCALAR_UNKNOWN) { out << prefix << "." << ossimKeywordNames::SCALAR_TYPE_KW << ": " << ossimScalarTypeLut::instance()->getEntryString( scalar ) << std::endl; if ( ossim::scalarSizeInBytes( scalar ) > 1 ) { ossimByteOrder byteOrder = ossim_hdf5::getByteOrder( &dataset ); std::string byteOrderString = "little_endian"; if ( byteOrder == OSSIM_BIG_ENDIAN ) { byteOrderString = "big_endian"; } out << prefix << "." <<ossimKeywordNames::BYTE_ORDER_KW << ": " << byteOrderString << std::endl; } } #if 0 // Attributes: int numberOfAttrs = dataset.getNumAttrs(); cout << "numberOfAttrs: " << numberOfAttrs << endl; for ( ossim_int32 attrIdx = 0; attrIdx < numberOfAttrs; ++attrIdx ) { H5::Attribute attribute = dataset.openAttribute( attrIdx ); cout << "attribute.from class: " << attribute.fromClass() << endl; } #endif dataset.close(); } // End: printObject