version 5.4.0
remove CORS default header from PIHTTPServer fix several docs fix PIMathVector::dot return type add units directory with PIUnits facility
This commit is contained in:
81
libs/main/units/piunits_value.h
Normal file
81
libs/main/units/piunits_value.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*! \file piunits_value.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Unit value
|
||||
* \~russian Единица измерения
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unit value
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIUNITS_VALUE_H
|
||||
#define PIUNITS_VALUE_H
|
||||
|
||||
#include "piunits_base.h"
|
||||
|
||||
|
||||
namespace PIUnits {
|
||||
/*
|
||||
enum class Angle {
|
||||
Degree = 0x200,
|
||||
Radian,
|
||||
};
|
||||
enum class Time {
|
||||
Second = 0x300,
|
||||
Hertz,
|
||||
};
|
||||
enum class Temperature {
|
||||
Kelvin = 0x400,
|
||||
Celsius,
|
||||
Fahrenheit,
|
||||
};
|
||||
enum class Pressure {
|
||||
Pascal = 0x500,
|
||||
};
|
||||
enum class Distance {
|
||||
Meter = 0x500,
|
||||
};
|
||||
};
|
||||
*/
|
||||
class PIP_EXPORT Value {
|
||||
public:
|
||||
Value(double v = 0., int t = Class::Invalid);
|
||||
|
||||
bool isValid() const { return m_type >= 0 && m_class; }
|
||||
bool isNotValid() const { return m_type < 0 || !m_class; }
|
||||
|
||||
double value() const { return m_value; }
|
||||
PIString toString(char format = 'g', int prec = 5) const;
|
||||
|
||||
bool convert(int type_to);
|
||||
Value converted(int type_to);
|
||||
|
||||
private:
|
||||
double m_value = 0.;
|
||||
int m_type = -1;
|
||||
Class::Internal::ClassBase * m_class = nullptr;
|
||||
};
|
||||
|
||||
}; // namespace PIUnits
|
||||
|
||||
inline PICout operator<<(PICout s, const PIUnits::Value & v) {
|
||||
s << v.toString();
|
||||
return s;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user