[DEV] create variant library
This commit is contained in:
parent
4208e44c18
commit
1de2ed72bf
28
doxy_fluorine.py
Normal file
28
doxy_fluorine.py
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
import os
|
||||
import doxy.module as module
|
||||
import doxy.debug as debug
|
||||
import doxy.tools as tools
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name)
|
||||
my_module.set_version("version.txt")
|
||||
my_module.set_title("fluorine: Ewol JSON parser")
|
||||
my_module.set_website("http://atria-soft.github.io/" + module_name)
|
||||
my_module.set_website_sources("http://github.com/atria-soft/" + module_name)
|
||||
my_module.add_depend([
|
||||
'elog',
|
||||
'etk',
|
||||
'ememory'
|
||||
])
|
||||
my_module.add_exclude_symbols([
|
||||
'*operator<<*',
|
||||
])
|
||||
my_module.add_exclude_file([
|
||||
'debug.hpp',
|
||||
])
|
||||
my_module.add_file_patterns([
|
||||
'*.hpp',
|
||||
'*.md',
|
||||
])
|
||||
return my_module
|
357
fluorine/Variant.cpp
Normal file
357
fluorine/Variant.cpp
Normal file
@ -0,0 +1,357 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <fluorine/Variant.hpp>
|
||||
#include <fluorine/debug.hpp>
|
||||
#include <etk/Allocator.hpp>
|
||||
|
||||
fluorine::Variant fluorine::empty() {
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
etk::Stream& fluorine::operator <<(etk::Stream& _os, const fluorine::Variant& _obj) {
|
||||
switch (_obj.getType()) {
|
||||
case fluorine::variantType::Undefined:
|
||||
_os << "undefined";
|
||||
break;
|
||||
case fluorine::variantType::Integer:
|
||||
_os << _obj.getInt();
|
||||
break;
|
||||
case fluorine::variantType::UnsignedInteger:
|
||||
_os << _obj.getUInt();
|
||||
break;
|
||||
case fluorine::variantType::Float:
|
||||
_os << _obj.getFloat();
|
||||
break;
|
||||
case fluorine::variantType::Null:
|
||||
_os << "null";
|
||||
break;
|
||||
case fluorine::variantType::Boolean:
|
||||
_os << _obj.getBoolean();
|
||||
break;
|
||||
case fluorine::variantType::RawPointer:
|
||||
_os << _obj.getRawPointer();
|
||||
break;
|
||||
case fluorine::variantType::String:
|
||||
_os << _obj.getString();
|
||||
break;
|
||||
case fluorine::variantType::Color:
|
||||
_os << _obj.getColor();
|
||||
break;
|
||||
case fluorine::variantType::Vec2:
|
||||
_os << _obj.getVec2();
|
||||
break;
|
||||
case fluorine::variantType::IVec2:
|
||||
_os << _obj.getIVec2();
|
||||
break;
|
||||
case fluorine::variantType::Vec3:
|
||||
_os << _obj.getVec3();
|
||||
break;
|
||||
case fluorine::variantType::IVec3:
|
||||
_os << _obj.getIVec3();
|
||||
break;
|
||||
default:
|
||||
_os << "<<ERROR VARIANT>>";
|
||||
break;
|
||||
}
|
||||
return _os;
|
||||
}
|
||||
|
||||
void fluorine::Variant::swap(Variant& _obj) {
|
||||
etk::swap(m_dataUnion, _obj.m_dataUnion);
|
||||
etk::swap(m_dataType, _obj.m_dataType);
|
||||
}
|
||||
|
||||
enum fluorine::variantType fluorine::Variant::getType() const {
|
||||
return m_dataType;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(Variant&& _obj) {
|
||||
m_dataUnion.m_rawPointer = null;
|
||||
etk::swap(*this, _obj);
|
||||
}
|
||||
/**
|
||||
* @brief Copy contructor
|
||||
* @param[in] _obj Object to copy.
|
||||
*/
|
||||
fluorine::Variant::Variant(const Variant& _obj) {
|
||||
fluorine::Variant tmp = _obj.clone();
|
||||
etk::swap(*this, tmp);
|
||||
}
|
||||
|
||||
|
||||
fluorine::Variant& fluorine::Variant::operator= (Variant&& _obj) {
|
||||
etk::swap(*this, _obj);
|
||||
return *this;
|
||||
}
|
||||
|
||||
fluorine::Variant& fluorine::Variant::operator= (const Variant& _obj) {
|
||||
fluorine::Variant tmp = _obj.clone();
|
||||
etk::swap(*this, tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
fluorine::Variant fluorine::Variant::clone() const {
|
||||
switch (getType()) {
|
||||
case fluorine::variantType::Undefined:
|
||||
return fluorine::Variant{};
|
||||
case fluorine::variantType::Integer:
|
||||
return fluorine::Variant{getInt()};
|
||||
case fluorine::variantType::UnsignedInteger:
|
||||
return fluorine::Variant{getUInt()};
|
||||
case fluorine::variantType::Float:
|
||||
return fluorine::Variant{getFloat()};
|
||||
case fluorine::variantType::Null:
|
||||
return fluorine::Variant{null};
|
||||
case fluorine::variantType::Boolean:
|
||||
return fluorine::Variant{getBoolean()};
|
||||
case fluorine::variantType::RawPointer:
|
||||
return fluorine::Variant{getRawPointer()};
|
||||
case fluorine::variantType::String:
|
||||
return fluorine::Variant{getString()};
|
||||
case fluorine::variantType::Color:
|
||||
return fluorine::Variant{getColor()};
|
||||
case fluorine::variantType::Vec2:
|
||||
return fluorine::Variant{getVec2()};
|
||||
case fluorine::variantType::IVec2:
|
||||
return fluorine::Variant{getIVec2()};
|
||||
case fluorine::variantType::Vec3:
|
||||
return fluorine::Variant{getVec3()};
|
||||
case fluorine::variantType::IVec3:
|
||||
return fluorine::Variant{getIVec3()};
|
||||
}
|
||||
return fluorine::Variant();
|
||||
}
|
||||
|
||||
void fluorine::Variant::clear() {
|
||||
switch (getType()) {
|
||||
case fluorine::variantType::Undefined:
|
||||
case fluorine::variantType::Integer:
|
||||
case fluorine::variantType::UnsignedInteger:
|
||||
case fluorine::variantType::Float:
|
||||
case fluorine::variantType::Null:
|
||||
case fluorine::variantType::Boolean:
|
||||
case fluorine::variantType::RawPointer:
|
||||
break;
|
||||
case fluorine::variantType::String:
|
||||
ETK_DELETE(etk::String, m_dataUnion.m_string);
|
||||
break;
|
||||
case fluorine::variantType::Color:
|
||||
ETK_DELETE(etk::Color<>, m_dataUnion.m_color);
|
||||
break;
|
||||
case fluorine::variantType::Vec2:
|
||||
ETK_DELETE(vec2, m_dataUnion.m_vec2);
|
||||
break;
|
||||
case fluorine::variantType::IVec2:
|
||||
ETK_DELETE(ivec2, m_dataUnion.m_ivec2);
|
||||
break;
|
||||
case fluorine::variantType::Vec3:
|
||||
ETK_DELETE(vec3, m_dataUnion.m_vec3);
|
||||
break;
|
||||
case fluorine::variantType::IVec3:
|
||||
ETK_DELETE(ivec3, m_dataUnion.m_ivec3);
|
||||
break;
|
||||
}
|
||||
m_dataUnion.m_rawPointer = null;
|
||||
}
|
||||
|
||||
|
||||
fluorine::Variant::Variant():
|
||||
m_dataType(fluorine::variantType::Undefined) {
|
||||
m_dataUnion.m_rawPointer = null;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const etk::NullPtr&):
|
||||
m_dataType(fluorine::variantType::Null) {
|
||||
m_dataUnion.m_rawPointer = null;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const int8_t& _value):
|
||||
m_dataType(fluorine::variantType::Integer) {
|
||||
m_dataUnion.m_int = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const int16_t& _value):
|
||||
m_dataType(fluorine::variantType::Integer) {
|
||||
m_dataUnion.m_int = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const int32_t& _value):
|
||||
m_dataType(fluorine::variantType::Integer) {
|
||||
m_dataUnion.m_int = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const int64_t& _value):
|
||||
m_dataType(fluorine::variantType::Integer) {
|
||||
m_dataUnion.m_int = _value;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const uint8_t& _value):
|
||||
m_dataType(fluorine::variantType::UnsignedInteger) {
|
||||
m_dataUnion.m_uint = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const uint16_t& _value):
|
||||
m_dataType(fluorine::variantType::UnsignedInteger) {
|
||||
m_dataUnion.m_uint = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const uint32_t& _value):
|
||||
m_dataType(fluorine::variantType::UnsignedInteger) {
|
||||
m_dataUnion.m_uint = _value;
|
||||
}
|
||||
fluorine::Variant::Variant(const uint64_t& _value):
|
||||
m_dataType(fluorine::variantType::UnsignedInteger) {
|
||||
m_dataUnion.m_uint = _value;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const float_t& _value):
|
||||
m_dataType(fluorine::variantType::Float) {
|
||||
m_dataUnion.m_float = _value;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const bool& _value):
|
||||
m_dataType(fluorine::variantType::Boolean) {
|
||||
m_dataUnion.m_boolean = _value;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const etk::String& _value):
|
||||
m_dataType(fluorine::variantType::String) {
|
||||
m_dataUnion.m_string = ETK_NEW(etk::String, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const char* _value):
|
||||
m_dataType(fluorine::variantType::String) {
|
||||
m_dataUnion.m_string = ETK_NEW(etk::String, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const void* _value):
|
||||
m_dataType(fluorine::variantType::RawPointer) {
|
||||
m_dataUnion.m_rawPointer = (void*)_value;
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const vec2& _value):
|
||||
m_dataType(fluorine::variantType::Vec2) {
|
||||
m_dataUnion.m_vec2 = ETK_NEW(vec2, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const ivec2& _value):
|
||||
m_dataType(fluorine::variantType::IVec2) {
|
||||
m_dataUnion.m_ivec2 = ETK_NEW(ivec2, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const vec3& _value):
|
||||
m_dataType(fluorine::variantType::Vec3) {
|
||||
m_dataUnion.m_vec3 = ETK_NEW(vec3, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const ivec3& _value):
|
||||
m_dataType(fluorine::variantType::IVec3) {
|
||||
m_dataUnion.m_ivec3 = ETK_NEW(ivec3, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::Variant(const etk::Color<>& _value):
|
||||
m_dataType(fluorine::variantType::Color) {
|
||||
m_dataUnion.m_color = ETK_NEW(etk::Color<>, _value);
|
||||
}
|
||||
|
||||
fluorine::Variant::~Variant() {
|
||||
clear();
|
||||
}
|
||||
|
||||
bool fluorine::Variant::getBoolean() const {
|
||||
return m_dataUnion.m_boolean;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isBoolean() const {
|
||||
return m_dataType == fluorine::variantType::Boolean;
|
||||
}
|
||||
|
||||
int_t fluorine::Variant::getInt() const {
|
||||
return m_dataUnion.m_int;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isInt() const {
|
||||
return m_dataType == fluorine::variantType::Integer;
|
||||
}
|
||||
|
||||
uint_t fluorine::Variant::getUInt() const {
|
||||
return m_dataUnion.m_uint;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isUInt() const {
|
||||
return m_dataType == fluorine::variantType::UnsignedInteger;
|
||||
}
|
||||
|
||||
float_t fluorine::Variant::getFloat() const {
|
||||
return m_dataUnion.m_float;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isFloat() const {
|
||||
return m_dataType == fluorine::variantType::Float;
|
||||
}
|
||||
|
||||
void* fluorine::Variant::getRawPointer() const {
|
||||
return m_dataUnion.m_rawPointer;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isRawPointer() const {
|
||||
return m_dataType == fluorine::variantType::RawPointer;
|
||||
}
|
||||
|
||||
etk::String fluorine::Variant::getString() const {
|
||||
return *(m_dataUnion.m_string);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isString() const {
|
||||
return m_dataType == fluorine::variantType::String;
|
||||
}
|
||||
|
||||
etk::Color<> fluorine::Variant::getColor() const {
|
||||
return *(m_dataUnion.m_color);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isColor() const {
|
||||
return m_dataType == fluorine::variantType::Color;
|
||||
}
|
||||
|
||||
vec2 fluorine::Variant::getVec2() const {
|
||||
return *(m_dataUnion.m_vec2);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isVec2() const {
|
||||
return m_dataType == fluorine::variantType::Vec2;
|
||||
}
|
||||
|
||||
ivec2 fluorine::Variant::getIVec2() const {
|
||||
return *(m_dataUnion.m_ivec2);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isIVec2() const {
|
||||
return m_dataType == fluorine::variantType::IVec2;
|
||||
}
|
||||
|
||||
vec3 fluorine::Variant::getVec3() const {
|
||||
return *(m_dataUnion.m_vec3);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isVec3() const {
|
||||
return m_dataType == fluorine::variantType::Vec3;
|
||||
}
|
||||
|
||||
ivec3 fluorine::Variant::getIVec3() const {
|
||||
return *(m_dataUnion.m_ivec3);
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isIVec3() const {
|
||||
return m_dataType == fluorine::variantType::IVec3;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isNull() const {
|
||||
return m_dataType == fluorine::variantType::Null;
|
||||
}
|
||||
|
||||
bool fluorine::Variant::isUndefined() const {
|
||||
return m_dataType == fluorine::variantType::Undefined;
|
||||
}
|
||||
|
286
fluorine/Variant.hpp
Normal file
286
fluorine/Variant.hpp
Normal file
@ -0,0 +1,286 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Color.hpp>
|
||||
#include <etk/math/Vector2D.hpp>
|
||||
#include <etk/math/Vector3D.hpp>
|
||||
#include <fluorine/variantType.hpp>
|
||||
|
||||
/**
|
||||
* @brief fluorine namespace containing all function for JSON interpretor
|
||||
*/
|
||||
namespace fluorine {
|
||||
union DataType {
|
||||
int_t m_int;
|
||||
uint_t m_uint;
|
||||
float_t m_float;
|
||||
bool m_boolean;
|
||||
void * m_rawPointer;
|
||||
etk::String* m_string;
|
||||
ivec2* m_ivec2;
|
||||
vec2* m_vec2;
|
||||
ivec3* m_ivec3;
|
||||
vec3* m_vec3;
|
||||
etk::Color<>* m_color;
|
||||
};
|
||||
/**
|
||||
* @brief Basic main object of all json elements.
|
||||
*/
|
||||
class Variant {
|
||||
protected:
|
||||
union fluorine::DataType m_dataUnion; //!< Variant Data...
|
||||
fluorine::variantType m_dataType = fluorine::variantType::Undefined; //!< Type of the Data...
|
||||
public:
|
||||
/**
|
||||
* @brief Get Variant type
|
||||
* @return Type of the object
|
||||
*/
|
||||
enum fluorine::variantType getType() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Move contructor
|
||||
* @param[in] _obj Object to move.
|
||||
*/
|
||||
Variant(Variant&& _obj);
|
||||
/**
|
||||
* @brief Copy contructor
|
||||
* @param[in] _obj Object to copy.
|
||||
*/
|
||||
Variant(const Variant& _obj);
|
||||
/**
|
||||
* @brief Move operator
|
||||
* @param[in] _obj Object to move.
|
||||
*/
|
||||
Variant& operator= (Variant&& _obj);
|
||||
/**
|
||||
* @brief Copy operator
|
||||
* @param[in] _obj Object to copy.
|
||||
*/
|
||||
Variant& operator= (const Variant& _obj);
|
||||
/**
|
||||
* @brief Constuctor that generate an undefined element
|
||||
*/
|
||||
Variant();
|
||||
/**
|
||||
* @brief Constuctor that generate a null element
|
||||
*/
|
||||
Variant(const etk::NullPtr& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a int_t value
|
||||
*/
|
||||
Variant(const int8_t& _value);
|
||||
Variant(const int16_t& _value);
|
||||
Variant(const int32_t& _value);
|
||||
Variant(const int64_t& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a uint_t value
|
||||
*/
|
||||
Variant(const uint8_t& _value);
|
||||
Variant(const uint16_t& _value);
|
||||
Variant(const uint32_t& _value);
|
||||
Variant(const uint64_t& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a float_t value
|
||||
*/
|
||||
Variant(const float_t& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a boolean value
|
||||
*/
|
||||
Variant(const bool& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a string value
|
||||
*/
|
||||
Variant(const etk::String& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a string value
|
||||
*/
|
||||
Variant(const char* _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a RAW pointer value
|
||||
*/
|
||||
Variant(const void* _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a vec2 value
|
||||
*/
|
||||
Variant(const vec2& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a ivec2 value
|
||||
*/
|
||||
Variant(const ivec2& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a vec3 value
|
||||
*/
|
||||
Variant(const vec3& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a ivec3 value
|
||||
*/
|
||||
Variant(const ivec3& _value);
|
||||
/**
|
||||
* @brief Constuctor that generate a etk::Color<> value
|
||||
*/
|
||||
Variant(const etk::Color<>& _value);
|
||||
public:
|
||||
/**
|
||||
* @brief Virtualize destructor
|
||||
*/
|
||||
~Variant();
|
||||
public:
|
||||
/**
|
||||
* @brief Get the Boolean Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
bool getBoolean() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Boolean
|
||||
* @return true if the node is a fluorine::Boolean
|
||||
*/
|
||||
bool isBoolean() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the int_t Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
int_t getInt() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Integer
|
||||
* @return true if the node is a fluorine::Integer
|
||||
*/
|
||||
bool isInt() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the uint_t Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
uint_t getUInt() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::UnsignedInteger
|
||||
* @return true if the node is a fluorine::UnsignedInteger
|
||||
*/
|
||||
bool isUInt() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the uint_t Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
float_t getFloat() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Float
|
||||
* @return true if the node is a fluorine::Float
|
||||
*/
|
||||
bool isFloat() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the void* Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
void* getRawPointer() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::RawPointer
|
||||
* @return true if the node is a fluorine::RawPointer
|
||||
*/
|
||||
bool isRawPointer() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the etk::String Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
etk::String getString() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::String
|
||||
* @return true if the node is a fluorine::String
|
||||
*/
|
||||
bool isString() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the etk::Color Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
etk::Color<> getColor() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Color
|
||||
* @return true if the node is a fluorine::Color
|
||||
*/
|
||||
bool isColor() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the vec2 Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
vec2 getVec2() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Vec2
|
||||
* @return true if the node is a fluorine::Vec2
|
||||
*/
|
||||
bool isVec2() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the ivec2 Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
ivec2 getIVec2() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::IVec2
|
||||
* @return true if the node is a fluorine::IVec2
|
||||
*/
|
||||
bool isIVec2() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the vec3 Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
vec3 getVec3() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Vec3
|
||||
* @return true if the node is a fluorine::Vec3
|
||||
*/
|
||||
bool isVec3() const;
|
||||
public:
|
||||
/**
|
||||
* @brief Get the ivec3 Value.
|
||||
* @return requested value if compatible.
|
||||
*/
|
||||
ivec3 getIVec3() const;
|
||||
/**
|
||||
* @brief check if the node is a fluorine::IVec3
|
||||
* @return true if the node is a fluorine::IVec3
|
||||
*/
|
||||
bool isIVec3() const;
|
||||
public:
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Null
|
||||
* @return true if the node is a fluorine::Null
|
||||
*/
|
||||
bool isNull() const;
|
||||
public:
|
||||
/**
|
||||
* @brief check if the node is a fluorine::Undefined
|
||||
* @return true if the node is a fluorine::Undefined
|
||||
*/
|
||||
bool isUndefined() const;
|
||||
/**
|
||||
* @brief clear the Variant ==> set undefined
|
||||
*/
|
||||
Variant clone() const;
|
||||
/**
|
||||
* @brief clear the Variant ==> set undefined
|
||||
*/
|
||||
void clear();
|
||||
/**
|
||||
* @brief Swap 2 object Variant
|
||||
* @param[in] second object to swap.
|
||||
*/
|
||||
void swap(Variant& _obj);
|
||||
};
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream& _os, const fluorine::Variant& _obj);
|
||||
/**
|
||||
* @brief create an empty Variant (that does not exist:unknow ...)
|
||||
* @return empty value (not usable)
|
||||
*/
|
||||
fluorine::Variant empty();
|
||||
}
|
13
fluorine/debug.cpp
Normal file
13
fluorine/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <fluorine/debug.hpp>
|
||||
|
||||
int32_t fluorine::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("fluorine");
|
||||
return g_val;
|
||||
}
|
||||
|
37
fluorine/debug.hpp
Normal file
37
fluorine/debug.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.hpp>
|
||||
|
||||
namespace fluorine {
|
||||
int32_t getLogId();
|
||||
};
|
||||
#define FLUORINE_BASE(info,data) ELOG_BASE(fluorine::getLogId(),info,data)
|
||||
|
||||
#define FLUORINE_CRITICAL(data) FLUORINE_BASE(1, data)
|
||||
#define FLUORINE_ERROR(data) FLUORINE_BASE(2, data)
|
||||
#define FLUORINE_WARNING(data) FLUORINE_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define FLUORINE_INFO(data) FLUORINE_BASE(4, data)
|
||||
#define FLUORINE_DEBUG(data) FLUORINE_BASE(5, data)
|
||||
#define FLUORINE_VERBOSE(data) FLUORINE_BASE(6, data)
|
||||
#define FLUORINE_TODO(data) FLUORINE_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define FLUORINE_INFO(data) do { } while(false)
|
||||
#define FLUORINE_DEBUG(data) do { } while(false)
|
||||
#define FLUORINE_VERBOSE(data) do { } while(false)
|
||||
#define FLUORINE_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define FLUORINE_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
JSON_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
||||
|
57
fluorine/variantType.cpp
Normal file
57
fluorine/variantType.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <fluorine/variantType.hpp>
|
||||
#include <fluorine/debug.hpp>
|
||||
|
||||
|
||||
|
||||
etk::Stream& fluorine::operator <<(etk::Stream& _os, enum fluorine::variantType _obj) {
|
||||
switch (_obj) {
|
||||
case fluorine::variantType::Undefined:
|
||||
_os << "fluorine::variantType::Undefined";
|
||||
break;
|
||||
case fluorine::variantType::Integer:
|
||||
_os << "fluorine::variantType::Integer";
|
||||
break;
|
||||
case fluorine::variantType::UnsignedInteger:
|
||||
_os << "fluorine::variantType::UnsignedInteger";
|
||||
break;
|
||||
case fluorine::variantType::Float:
|
||||
_os << "fluorine::variantType::Float";
|
||||
break;
|
||||
case fluorine::variantType::Null:
|
||||
_os << "fluorine::variantType::Null";
|
||||
break;
|
||||
case fluorine::variantType::RawPointer:
|
||||
_os << "fluorine::variantType::RawPointer";
|
||||
break;
|
||||
case fluorine::variantType::String:
|
||||
_os << "fluorine::variantType::String";
|
||||
break;
|
||||
case fluorine::variantType::Boolean:
|
||||
_os << "fluorine::variantType::Boolean";
|
||||
break;
|
||||
case fluorine::variantType::Color:
|
||||
_os << "fluorine::variantType::Color";
|
||||
break;
|
||||
case fluorine::variantType::Vec2:
|
||||
_os << "fluorine::variantType::Vec2";
|
||||
break;
|
||||
case fluorine::variantType::IVec2:
|
||||
_os << "fluorine::variantType::IVec2";
|
||||
break;
|
||||
case fluorine::variantType::Vec3:
|
||||
_os << "fluorine::variantType::Vec3";
|
||||
break;
|
||||
case fluorine::variantType::IVec3:
|
||||
_os << "fluorine::variantType::IVec3";
|
||||
break;
|
||||
}
|
||||
return _os;
|
||||
}
|
||||
|
||||
|
32
fluorine/variantType.hpp
Normal file
32
fluorine/variantType.hpp
Normal file
@ -0,0 +1,32 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <etk/Stream.hpp>
|
||||
|
||||
namespace fluorine {
|
||||
/**
|
||||
* @brief Type of the JSON elements.
|
||||
*/
|
||||
enum class variantType {
|
||||
Undefined, //!< Undefined Value ...
|
||||
Integer, //!< int_t value
|
||||
UnsignedInteger, //!< uint_t value
|
||||
Float, //!< Float value (double)
|
||||
Null, //!< Null value
|
||||
RawPointer, //!< Void * pointer
|
||||
String, //!< String element
|
||||
Boolean, //!< Boolean element
|
||||
Color, //!< Color RGBA float element
|
||||
Vec2, //!< 2D vector Position (float)
|
||||
IVec2, //!< 2D vector Position (integer)
|
||||
Vec3, //!< 3D vector Position (float)
|
||||
IVec3, //!< 3D vector Position (integer)
|
||||
};
|
||||
//! @not_in_doc
|
||||
etk::Stream& operator <<(etk::Stream& _os, enum variantType _obj);
|
||||
}
|
||||
|
44
lutin_fluorine-test.py
Normal file
44
lutin_fluorine-test.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_sub_type():
|
||||
return "TEST"
|
||||
|
||||
def get_name():
|
||||
return "fluorine-test"
|
||||
|
||||
def get_desc():
|
||||
return "fluorine test application"
|
||||
|
||||
def get_licence():
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return "authors.txt"
|
||||
|
||||
def get_version():
|
||||
return "version.txt"
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_src_file([
|
||||
'test/test.cpp',
|
||||
'test/testAll.cpp',
|
||||
])
|
||||
my_module.add_depend([
|
||||
'fluorine',
|
||||
'etest',
|
||||
'test-debug'
|
||||
])
|
||||
return True
|
||||
|
47
lutin_fluorine.py
Normal file
47
lutin_fluorine.py
Normal file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import lutin.tools as tools
|
||||
|
||||
|
||||
def get_type():
|
||||
return "LIBRARY"
|
||||
|
||||
def get_desc():
|
||||
return "fluorine interface for variant implementation"
|
||||
|
||||
def get_licence():
|
||||
return "MPL-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return "authors.txt"
|
||||
|
||||
def get_version():
|
||||
return "version.txt"
|
||||
|
||||
def configure(target, my_module):
|
||||
my_module.add_depend([
|
||||
'elog',
|
||||
'etk',
|
||||
'ememory'
|
||||
])
|
||||
my_module.add_extra_flags()
|
||||
my_module.add_src_file([
|
||||
'fluorine/debug.cpp',
|
||||
'fluorine/variantType.cpp',
|
||||
'fluorine/Variant.cpp',
|
||||
])
|
||||
my_module.add_header_file([
|
||||
'fluorine/debug.hpp',
|
||||
'fluorine/variantType.hpp',
|
||||
'fluorine/Variant.hpp',
|
||||
])
|
||||
my_module.add_path(".")
|
||||
return True
|
||||
|
||||
|
24
test/test.cpp
Normal file
24
test/test.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2014, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/archive/Archive.hpp>
|
||||
#include <test-debug/debug.hpp>
|
||||
#include <etest/etest.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
// init test engine:
|
||||
etest::init(argc, argv);
|
||||
// init etk log system and file interface:
|
||||
etk::init(argc, argv);
|
||||
// Run all test with etest
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
420
test/testAll.cpp
Normal file
420
test/testAll.cpp
Normal file
@ -0,0 +1,420 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include "fluorine/Variant.hpp"
|
||||
#include <etest/etest.hpp>
|
||||
|
||||
TEST(constructor, testUndefined) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testBoolean) {
|
||||
fluorine::Variant element(false);
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), true);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testInt) {
|
||||
fluorine::Variant element(int_t(-9123456789LL));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), true);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testUnsignedInt) {
|
||||
fluorine::Variant element(uint_t(9123456789UL));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), true);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testFloat) {
|
||||
fluorine::Variant element(float_t(76543.7654));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), true);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testRawPointer) {
|
||||
fluorine::Variant element((void*)654321);
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), true);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testString_1) {
|
||||
fluorine::Variant element("HGFDSQ");
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), true);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testString_2) {
|
||||
fluorine::Variant element(etk::String("HGFDSQ"));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), true);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testColor) {
|
||||
fluorine::Variant element(etk::Color<>(55,55,55,65));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), true);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testVec2) {
|
||||
fluorine::Variant element(vec2(43.6f,65.0f));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), true);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec2) {
|
||||
fluorine::Variant element(ivec2(43,65));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), true);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testVec3) {
|
||||
fluorine::Variant element(vec3(43.6f, 65.0f, 333.6f));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), true);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec3) {
|
||||
fluorine::Variant element(ivec3(43, 65, 333));
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), true);
|
||||
EXPECT_EQ(element.isNull(), false);
|
||||
}
|
||||
|
||||
TEST(constructor, testNull) {
|
||||
fluorine::Variant element(null);
|
||||
EXPECT_EQ(element.isUndefined(), false);
|
||||
EXPECT_EQ(element.isBoolean(), false);
|
||||
EXPECT_EQ(element.isInt(), false);
|
||||
EXPECT_EQ(element.isUInt(), false);
|
||||
EXPECT_EQ(element.isFloat(), false);
|
||||
EXPECT_EQ(element.isRawPointer(), false);
|
||||
EXPECT_EQ(element.isString(), false);
|
||||
EXPECT_EQ(element.isColor(), false);
|
||||
EXPECT_EQ(element.isVec2(), false);
|
||||
EXPECT_EQ(element.isIVec2(), false);
|
||||
EXPECT_EQ(element.isVec3(), false);
|
||||
EXPECT_EQ(element.isIVec3(), false);
|
||||
EXPECT_EQ(element.isNull(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(constructor, testBooleanValue) {
|
||||
fluorine::Variant element(false);
|
||||
EXPECT_EQ(element.getBoolean(), false);
|
||||
element = true;
|
||||
EXPECT_EQ(element.getBoolean(), true);
|
||||
}
|
||||
|
||||
TEST(constructor, testIntValue) {
|
||||
fluorine::Variant element(int_t(-9123456789LL));
|
||||
EXPECT_EQ(element.getInt(), int_t(-9123456789LL));
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testUnsignedIntValue) {
|
||||
fluorine::Variant element(uint_t(9123456789UL));
|
||||
EXPECT_EQ(element.getUInt(), uint_t(9123456789UL));
|
||||
}
|
||||
|
||||
TEST(constructor, testFloatValue) {
|
||||
fluorine::Variant element(float_t(76543.7654));
|
||||
EXPECT_EQ(element.getFloat(), float_t(76543.7654));
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testRawPointerValue) {
|
||||
fluorine::Variant element((void*)654321);
|
||||
EXPECT_EQ(element.getRawPointer(), (void*)654321);
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testString_1Value) {
|
||||
fluorine::Variant element("HGFDSQ");
|
||||
EXPECT_EQ(element.getString(), "HGFDSQ");
|
||||
}
|
||||
|
||||
TEST(constructor, testString_2Value) {
|
||||
fluorine::Variant element(etk::String("HGFDSQ"));
|
||||
EXPECT_EQ(element.getString(), "HGFDSQ");
|
||||
}
|
||||
|
||||
TEST(constructor, testColorValue) {
|
||||
fluorine::Variant element(etk::Color<>(55,55,55,65));
|
||||
EXPECT_EQ(element.getColor(), etk::Color<>(55,55,55,65));
|
||||
}
|
||||
|
||||
TEST(constructor, testVec2Value) {
|
||||
fluorine::Variant element(vec2(43.6f,65.0f));
|
||||
EXPECT_EQ(element.getVec2(), vec2(43.6f,65.0f));
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec2Value) {
|
||||
fluorine::Variant element(ivec2(43,65));
|
||||
EXPECT_EQ(element.getIVec2(), ivec2(43,65));
|
||||
}
|
||||
|
||||
TEST(constructor, testVec3Value) {
|
||||
fluorine::Variant element(vec3(43.6f, 65.0f, 333.6f));
|
||||
EXPECT_EQ(element.getVec3(), vec3(43.6f, 65.0f, 333.6f));
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec3Value) {
|
||||
fluorine::Variant element(ivec3(43, 65, 333));
|
||||
EXPECT_EQ(element.getIVec3(), ivec3(43, 65, 333));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TEST(constructor, testBooleanValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = false;
|
||||
EXPECT_EQ(element.getBoolean(), false);
|
||||
element = true;
|
||||
EXPECT_EQ(element.getBoolean(), true);
|
||||
}
|
||||
|
||||
TEST(constructor, testIntValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = int_t(-9123456789LL);
|
||||
EXPECT_EQ(element.getInt(), int_t(-9123456789LL));
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testUnsignedIntValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = uint_t(9123456789UL);
|
||||
EXPECT_EQ(element.getUInt(), uint_t(9123456789UL));
|
||||
}
|
||||
|
||||
TEST(constructor, testFloatValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = float_t(76543.7654);
|
||||
EXPECT_EQ(element.getFloat(), float_t(76543.7654));
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testRawPointerValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = (void*)654321;
|
||||
EXPECT_EQ(element.getRawPointer(), (void*)654321);
|
||||
}
|
||||
|
||||
|
||||
TEST(constructor, testString_1ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = "HGFDSQ";
|
||||
EXPECT_EQ(element.getString(), "HGFDSQ");
|
||||
}
|
||||
|
||||
TEST(constructor, testString_2ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = etk::String("HGFDSQ");
|
||||
EXPECT_EQ(element.getString(), "HGFDSQ");
|
||||
}
|
||||
|
||||
TEST(constructor, testColorValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = etk::Color<>(55,55,55,65);
|
||||
EXPECT_EQ(element.getColor(), etk::Color<>(55,55,55,65));
|
||||
}
|
||||
|
||||
TEST(constructor, testVec2ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = vec2(43.6f,65.0f);
|
||||
EXPECT_EQ(element.getVec2(), vec2(43.6f,65.0f));
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec2ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = ivec2(43,65);
|
||||
EXPECT_EQ(element.getIVec2(), ivec2(43,65));
|
||||
}
|
||||
|
||||
TEST(constructor, testVec3ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = vec3(43.6f, 65.0f, 333.6f);
|
||||
EXPECT_EQ(element.getVec3(), vec3(43.6f, 65.0f, 333.6f));
|
||||
}
|
||||
|
||||
TEST(constructor, testIVec3ValueOperator) {
|
||||
fluorine::Variant element;
|
||||
EXPECT_EQ(element.isUndefined(), true);
|
||||
element = ivec3(43, 65, 333);
|
||||
EXPECT_EQ(element.getIVec3(), ivec3(43, 65, 333));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user