#include <AlUnits.h>
class AlUnits
enum Type
{
kUnit, kSubunit, kPosition
};
enum LinearUnit
{
kMiles, kYards, kFeet, kInches,
kCentimeters, kMeters, kKilometers, kMillimeters
};
enum AngularUnit
{
kRadians, kDegrees, kMinutes, kSeconds
};
static AngularUnit angularUnits( Type type );
static double angularScale( Type type );
static LinearUnit linearUnits( Type type );
static double linearScale( Type type );
static double linearInCM( LinearUnit unit );
static double angularInDegrees( AngularUnit unit );
static statusCode parseStringAngular( const char* string, char* &ret, const
char* format=0 );
static statusCode parseStringLinear( const char* string, char* &ret, const
char* format=0 );
static statusCode parseStringNoUnits( const char* string, char* &ret, const
char* format=0 );
To convert a measurement to centimeters, use the equation
double scale = AlUnits::linearScale( type );
double unitsInCM = AlUnits::linearInCM( type );
sizeCM = sizeInUnits * unitsInCM * scale;
For example, the string '10deg:5.4min' is converted to degrees (10.09 degrees) and the resulting value is placed into the return string as '10.090000000 '.
Strings such as '10 deg:5.4min' or '10 deg, 5.4min' etc are not considered to be valid for a single angle value.
If the format string is not specified, then the default format string '%f' is used (this reads a single angle). The format string uses a simplified version of the typical 'printf' style arguments. To read three angles, specify format string of '%f %f %f'. In the input string, spaces and commas ("," or " ") are used to separate the input items.
For example, if the format string is "%f %f", then the input string should be formatted as two angles separated by a space (e.g. "10deg:5.4min 99sec"). The angles will be converted to degrees (10.09 degrees and 0.0275 degrees) and formatted into the return string separated by a space (e.g. "10.09000000 0.027500000").
Note that the returned string contains the angle without any units in its string.
This function is available only under OpenAlias.
ret - returned parsed string format - if this is not NULL, then it specifies the input format. '%f' is the default.
sFailure - format error
ret - returned parsed string
format - the input format
sFailure - format error
ret - returned parsed string
format - the input format
sFailure - format error