VAPoR  0.1
Public Member Functions | List of all members
VAPoR::UDUnits Class Reference

#include <UDUnitsClass.h>

Public Member Functions

 UDUnits ()
 
 ~UDUnits ()
 
int Initialize ()
 
bool IsPressureUnit (std::string unitstr) const
 
bool IsTimeUnit (std::string unitstr) const
 
bool IsLatUnit (std::string unitstr) const
 
bool IsLonUnit (std::string unitstr) const
 
bool IsLengthUnit (std::string unitstr) const
 
bool AreUnitsConvertible (const ut_unit *unit, std::string unitstr) const
 
bool ValidUnit (std::string unitstr) const
 
bool Convert (const std::string from, const std::string to, const float *src, float *dst, size_t n) const
 
bool Convert (const std::string from, const std::string to, const double *src, double *dst, size_t n) const
 
void DecodeTime (double seconds, int *year, int *month, int *day, int *hour, int *minute, int *second) const
 
double EncodeTime (int year, int month, int day, int hour, int minute, int second) const
 
std::string GetErrMsg () const
 

Detailed Description

Provides a C++ wrapper for Unidata's Udunits-2 package: http://www.unidata.ucar.edu/software/udunits/udunits-2/udunits2.html

Error handling: most methods in this class return an integer status flag, with a negative value indicating error. Error messages for the most recent error can be retrieved with GetErrMsg().

Definition at line 29 of file UDUnitsClass.h.

Constructor & Destructor Documentation

VAPoR::UDUnits::UDUnits ( )
VAPoR::UDUnits::~UDUnits ( )

Member Function Documentation

bool VAPoR::UDUnits::AreUnitsConvertible ( const ut_unit *  unit,
std::string  unitstr 
) const

Return true if the unit identified by the string contained in unitstr can be converted into the unit identified by unit. Otherwise false is returned

bool VAPoR::UDUnits::Convert ( const std::string  from,
const std::string  to,
const float *  src,
float *  dst,
size_t  n 
) const

Convert one unit to another

This method performs conversion between different units, when possible (see AreUnitsConvertible()). For example, converting meters to feet. The string from specifies the unit to convert from, and the string to specifies the unit to convert to.

Parameters
[in]fromA string specifying the source unit
[in]toA string specifying the destination unit
[in]srcAn array of source unit values
[out]dstAn array large enough to store the converted unit values.
[in]nThe number of elements in from
Return values
booleanA boolean status is returned indicating whether the conversion took place. Conversion will fail if the units are not convertible. No error message is generated.
See also
AreUnitsConvertible
bool VAPoR::UDUnits::Convert ( const std::string  from,
const std::string  to,
const double *  src,
double *  dst,
size_t  n 
) const
void VAPoR::UDUnits::DecodeTime ( double  seconds,
int *  year,
int *  month,
int *  day,
int *  hour,
int *  minute,
int *  second 
) const

Decode time specified in seconds to year, month, day, hour, minute and second.

This method uses Udunits-2 ut_decode_time() function to perform time conversion

double VAPoR::UDUnits::EncodeTime ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  second 
) const

Encode time specified to years, month, day, hour, minute and seconds to seconds

This method uses Udunits-2 ut_encode_time() function to perform time conversion

std::string VAPoR::UDUnits::GetErrMsg ( ) const

Get the most recent error message

This method returns a string containing the most recently occurring error message, if any.

int VAPoR::UDUnits::Initialize ( )

Initialize the Udunits-2 data base. Must be called after the constructor, prior to any other class methods

Return values
statusA negative int is returned on failure
bool VAPoR::UDUnits::IsLatUnit ( std::string  unitstr) const

Return true if the string provided by unitstr is recognized by Udunits-2 as a unit of Latitude

bool VAPoR::UDUnits::IsLengthUnit ( std::string  unitstr) const

Return true if the string provided by unitstr is recognized by Udunits-2 as a unit of length

bool VAPoR::UDUnits::IsLonUnit ( std::string  unitstr) const

Return true if the string provided by unitstr is recognized by Udunits-2 as a unit of Longitude

bool VAPoR::UDUnits::IsPressureUnit ( std::string  unitstr) const

Return true if the string provided by unitstr is recognized by Udunits-2 as a unit of pressure

bool VAPoR::UDUnits::IsTimeUnit ( std::string  unitstr) const

Return true if the string provided by unitstr is recognized by Udunits-2 as a unit of time

bool VAPoR::UDUnits::ValidUnit ( std::string  unitstr) const

Returns true if the string contained in unitstr is recognized as a valid unit by the Udunits-2 data base


The documentation for this class was generated from the following file: