UnitsApi.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef BASE_UNITSAPI_H
00025 #define BASE_UNITSAPI_H
00026
00027
00028 #if defined (_POSIX_C_SOURCE)
00029 # undef _POSIX_C_SOURCE
00030 #endif
00031 #if defined (_XOPEN_SOURCE)
00032 # undef _XOPEN_SOURCE
00033 #endif
00034
00035 #include <string>
00036 #include <Python.h>
00037 #include <QString>
00038 #include "UnitsSchema.h"
00039
00040 namespace Base {
00041
00042
00046 class BaseExport UnitsApi
00047 {
00048
00049 public:
00051 UnitsApi(const char* filter);
00052 UnitsApi(const std::string& filter);
00053 virtual ~UnitsApi();
00054
00061 static void setSchema(UnitSystem s);
00062
00063
00065 static double translateUnit(const char*);
00066 static double translateUnit(const QString &);
00067
00068
00071
00072 static QString toStrWithUserPrefs(QuantityType t,double Value);
00074 static void toStrWithUserPrefs(QuantityType t,double Value,QString &outValue,QString &outUnit);
00076 static PyObject *toPyWithUserPrefs(QuantityType t,double Value);
00078
00084
00085 static double toDblWithUserPrefs(QuantityType t,const QString & Str);
00087 static double toDblWithUserPrefs(QuantityType t,const char* Str);
00089 static double toDblWithUserPrefs(QuantityType t,double UserVal);
00091 static double toDblWithUserPrefs(QuantityType t,PyObject *ArgObj);
00093
00096
00097 static void setPrefOf(QuantityType t,const char* Str);
00099 static const QString & getPrefUnitOf(QuantityType t);
00101 static const QString getQuantityName(QuantityType t);
00103 static const double getPrefFactorOf(QuantityType t);
00105 static void setDefaults(void);
00107
00108 double Result;
00109
00110
00111 static PyMethodDef Methods[];
00112
00113
00114 protected:
00115
00116 static UnitsSchema * UserPrefSystem;
00117
00119 static double UserPrefFactor [50] ;
00121 static QString UserPrefUnit [50] ;
00122
00123
00124 static double parse(const char*,bool &UsedUnit);
00125
00126 protected:
00127 static PyObject *sTranslateUnit (PyObject *self,PyObject *args,PyObject *kwd);
00128 static PyObject *sGetWithPrefs (PyObject *self,PyObject *args,PyObject *kwd);
00129 };
00130
00131 }
00132
00133
00134 #endif // BASE_UNITSAPI_H