radarlib 1.4.6
read_attributes.cpp
/*===========================================================================*/
/*
/* Questo programma legge gli attributi scritti dall'esempio write_attributes.cpp
/*
/* Esempo di utilizzo:
/* main.exe volume.h5
/*
/*===========================================================================*/
#include <iostream>
using namespace OdimH5v20;
int main(int argc, char* argv[])
{
if (argc != 2)
{
std::cerr << "Usage: " << argv[0] << " <odimh5file>" << std::endl;
return -1;
}
OdimFactory* factory = NULL;
OdimObject* odimobj = NULL;
try
{
/* creazione factory */
factory = new OdimFactory();
/* apertura volume */
odimobj = factory->open(argv[1]);
/* esempi di lettura diretto con metodi specifici */
std::string object = odimobj->getObject();
time_t datetime = odimobj->getDateTime();
/* esempi di lettura con metodi generici */
bool boolval = odimobj->getWhat()->getBool("booleano");
char charval = odimobj->getWhat()->getChar("char");
unsigned char ucharval = odimobj->getWhat()->getUChar("unsigned char");
short shortval = odimobj->getWhat()->getShort("short");
unsigned short ushortval = odimobj->getWhat()->getUShort("unsigned short");
int intval = odimobj->getWhat()->getInt("int");
unsigned int uintval = odimobj->getWhat()->getUInt("unsigned int");
int64_t int64val = odimobj->getWhat()->getLong("long"); /* il nome long si riferisce sempre a interi a 64 bit */
float floatval = odimobj->getWhat()->getFloat("float");
double doubleval = odimobj->getWhat()->getDouble("double");
std::string stringval = odimobj->getWhat()->getStr("string");
/* esempi di lettura di sequenze di valori con metodi generici */
std::vector<bool> bools = odimobj->getWhat()->getBools("bools");
std::vector<int> ints = odimobj->getWhat()->getInts("ints");
std::vector<double> doubles = odimobj->getWhat()->getDoubles("doubles");
std::vector<std::string> strings = odimobj->getWhat()->getStrings("strings");
/* esempio di lettura di sequenze di coppie di valori con metodi generici */
std::vector<std::pair<float,float> > angles;
angles = odimobj->getWhat()->getFloatPairs("angles");
/* esempio di lettura di sequenze con metodi specific */
AZTimes tempo1;
AZTimes tempo2;
std::vector<AZTimes> tempi = odimobj->getWhat()->getAZTimes("tempi");
tempo1 = tempi[0];
tempo2 = tempi[1];
std::cout << "Lettura eseguita!" << std::endl;
}
catch (std::exception& stde)
{
std::cerr << "Errore di esecuzione: " << stde.what() << std::endl;
}
catch (...)
{
std::cerr << "Errore sconosciuto" << std::endl;
}
delete odimobj;
delete factory;
return 0;
}
Azimuth angles pair.
Definition odimh5v20_support.hpp:338
short getShort(const char *name)
Get the value of a 64 bit signed attribute converting it to 16 bit signed value.
Definition odimh5v20_metadata.cpp:142
bool getBool(const char *name)
Get the value of a boolean attribute.
Definition odimh5v20_metadata.cpp:136
unsigned int getUInt(const char *name)
Get the value of a 64 bit signed attribute converting it to 32 bit unsigned value.
Definition odimh5v20_metadata.cpp:148
unsigned char getUChar(const char *name)
Get the value of a 64 bit signed attribute converting it to 8 bit unsigned value.
Definition odimh5v20_metadata.cpp:140
std::vector< std::string > getStrings(const char *name, bool mandatory=false)
Get the value of a sequence attribute converting it to string values.
Definition odimh5v20_metadata.cpp:241
double getDouble(const char *name)
Get the value of a 64 bit floating point attribute.
Definition odimh5v20_metadata.cpp:156
std::vector< AZTimes > getAZTimes(const char *name)
Get the value of a sequence attribute converting it to azimuth time pairs.
Definition odimh5v20_metadata.cpp:353
int getInt(const char *name)
Get the value of a 64 bit signed attribute converting it to 32 bit signed value.
Definition odimh5v20_metadata.cpp:146
std::vector< bool > getBools(const char *name, bool mandatory=false)
Get the value of a sequence attribute converting it to boolean values.
Definition odimh5v20_metadata.cpp:218
int64_t getLong(const char *name)
Get the value of a 64 bit signed attribute.
Definition odimh5v20_metadata.cpp:150
float getFloat(const char *name)
Get the value of a 64 bit floating point attribute converting it to 32 bit floating point value.
Definition odimh5v20_metadata.cpp:154
std::vector< int > getInts(const char *name, bool mandatory=false)
Get the value of a sequence attribute converting it to 32 bit signed values.
Definition odimh5v20_metadata.cpp:235
char getChar(const char *name)
Get the value of a 64 bit signed attribute converting it to 8bit signed value.
Definition odimh5v20_metadata.cpp:138
std::vector< std::pair< float, float > > getFloatPairs(const char *name, bool mandatory=false)
Get the value of a sequence attribute converting it to 32 bit floating point value pairs.
Definition odimh5v20_metadata.cpp:299
unsigned short getUShort(const char *name)
Get the value of a 64 bit signed attribute converting it to 16 bit unsigned value.
Definition odimh5v20_metadata.cpp:144
std::vector< double > getDoubles(const char *name, bool mandatory=false)
Get the value of a sequence attribute converting it to 64 bit floating point values.
Definition odimh5v20_metadata.cpp:240
std::string getStr(const char *name)
Get the value of a string attribute.
Definition odimh5v20_metadata.cpp:158
OdimH5 objects factory.
Definition odimh5v20_factory.hpp:50
virtual OdimObject * open(const std::string &path)
Get a OdimH5 object from an existing file.
Definition odimh5v20_factory.cpp:112
Generic OdimH5 v2.0 object.
Definition odimh5v20_classes.hpp:95
virtual time_t getDateTime()
Get the joined value of 'date' and 'time' attributes.
Definition odimh5v20_classes.cpp:296
virtual std::string getObject()
Get the value of 'object' attribute.
Definition odimh5v20_classes.cpp:292
virtual MetadataGroup * getWhat()
Get the WHAT attributes group.
Definition odimh5v20_classes.cpp:172
Namespace related to ODIMH5 version 2.0.
Definition odimh5v20.hpp:46
Main header file of the library.