[dev] add number concept

This commit is contained in:
Edouard DUPIN 2018-08-21 22:19:56 +02:00
parent 38a49557c8
commit 6632c13fc2
2 changed files with 42 additions and 0 deletions

View File

@ -328,6 +328,32 @@ bool fluorine::Variant::isFloat() const {
return m_dataType == fluorine::variantType::Float;
}
float_t fluorine::Variant::getNumber() const {
return getSafeNumber();
}
float_t fluorine::Variant::getSafeNumber() const {
if (isFloat() == true) {
return getFloat();
}
if (isUInt() == true) {
return getUInt();
}
if (isInt() == true) {
return getInt();
}
if (isBoolean() == true) {
return getBoolean()==true?1:0;
}
return 0;
}
bool fluorine::Variant::isNumber() const {
return m_dataType == fluorine::variantType::Float
|| m_dataType == fluorine::variantType::UnsignedInteger
|| m_dataType == fluorine::variantType::Integer
|| m_dataType == fluorine::variantType::Boolean;
}
void* fluorine::Variant::getRawPointer() const {
return m_dataUnion.m_rawPointer;
}

View File

@ -198,6 +198,22 @@ namespace fluorine {
* @return true if the node is a fluorine::Float
*/
bool isFloat() const;
public:
/**
* @brief Get the uint_t Value.
* @return requested value if compatible.
*/
float_t getNumber() const;
/**
* @brief Get the uint_t Value. (Safe mode)
* @return requested value if compatible.
*/
float_t getSafeNumber() const;
/**
* @brief check if the node is a fluorine::Float | fluorine::UnsignedInteger | fluorine::Integer
* @return true if the node is a fluorine::Float | fluorine::UnsignedInteger | fluorine::Integer
*/
bool isNumber() const;
public:
/**
* @brief Get the void* Value.