Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2016-01-19 20:42:11 +01:00
commit f50c9c0866
15 changed files with 134 additions and 166 deletions

View file

@ -280,40 +280,6 @@ inline bool fromString(const std::string &str, bool &val)
return true;
}
inline bool fromString(const char *str, uint32 &val) { if (strstr(str, "-") != NULL) { val = 0; return false; } char *end; unsigned long v; errno = 0; v = strtoul(str, &end, 10); if (errno || v > UINT_MAX || end == str) { val = 0; return false; } else { val = (uint32)v; return true; } }
inline bool fromString(const char *str, sint32 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > INT_MAX || v < INT_MIN || end == str) { val = 0; return false; } else { val = (sint32)v; return true; } }
inline bool fromString(const char *str, uint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > UCHAR_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint8)v; return true; } }
inline bool fromString(const char *str, sint8 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SCHAR_MAX || v < SCHAR_MIN || end == str) { val = 0; return false; } else { val = (sint8)v; return true; } }
inline bool fromString(const char *str, uint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > USHRT_MAX || v < 0 || end == str) { val = 0; return false; } else { val = (uint16)v; return true; } }
inline bool fromString(const char *str, sint16 &val) { char *end; long v; errno = 0; v = strtol(str, &end, 10); if (errno || v > SHRT_MAX || v < SHRT_MIN || end == str) { val = 0; return false; } else { val = (sint16)v; return true; } }
inline bool fromString(const char *str, uint64 &val) { bool ret = sscanf(str, "%" NL_I64 "u", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, sint64 &val) { bool ret = sscanf(str, "%" NL_I64 "d", &val) == 1; if (!ret) val = 0; return ret; }
inline bool fromString(const char *str, float &val) { bool ret = sscanf(str, "%f", &val) == 1; if (!ret) val = 0.0f; return ret; }
inline bool fromString(const char *str, double &val) { bool ret = sscanf(str, "%lf", &val) == 1; if (!ret) val = 0.0; return ret; }
inline bool fromString(const char *str, bool &val)
{
switch (str[0])
{
case '1':
case 't':
case 'y':
case 'T':
case 'Y':
val = true;
return true;
case '0':
case 'f':
case 'n':
case 'F':
case 'N':
val = false;
return true;
}
return false;
}
inline bool fromString(const std::string &str, std::string &val) { val = str; return true; }
// stl vectors of bool use bit reference and not real bools, so define the operator for bit reference

View file

@ -25,8 +25,8 @@
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include <nel/3d/fxaa.h>
#include "std3d.h"
#include "nel/3d/fxaa.h"
// STL includes
@ -34,14 +34,14 @@
// #include <nel/misc/debug.h>
// Project includes
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include <nel/3d/render_target_manager.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
#include "nel/3d/render_target_manager.h"
using namespace std;
// using namespace NLMISC;

View file

@ -23,9 +23,9 @@
#include "std3d.h"
#include <nel/3d/geometry_program.h>
#include "nel/3d/geometry_program.h"
#include <nel/3d/driver.h>
#include "nel/3d/driver.h"
namespace NL3D
{

View file

@ -25,18 +25,19 @@
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include <nel/3d/gpu_program_params.h>
#include "std3d.h"
#include "nel/misc/types_nl.h"
#include "nel/3d/gpu_program_params.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/misc/vector.h>
#include <nel/misc/matrix.h>
#include "nel/misc/vector.h"
#include "nel/misc/matrix.h"
// Project includes
#include <nel/3d/driver.h>
#include "nel/3d/driver.h"
using namespace std;
// using namespace NLMISC;

View file

@ -23,9 +23,9 @@
#include "std3d.h"
#include <nel/3d/pixel_program.h>
#include "nel/3d/pixel_program.h"
#include <nel/3d/driver.h>
#include "nel/3d/driver.h"
namespace NL3D
{

View file

@ -25,17 +25,19 @@
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include <nel/3d/program.h>
#include "std3d.h"
#include "nel/misc/types_nl.h"
#include "nel/3d/program.h"
// STL includes
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/misc/string_mapper.h>
#include "nel/misc/string_mapper.h"
// Project includes
#include <nel/3d/driver.h>
#include "nel/3d/driver.h"
using namespace std;
// using namespace NLMISC;

View file

@ -25,21 +25,21 @@
* <http://www.gnu.org/licenses/>.
*/
#include <nel/misc/types_nl.h>
#include <nel/3d/render_target_manager.h>
#include "std3d.h"
#include "nel/3d/render_target_manager.h"
// STL includes
#include <sstream>
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
// Project includes

View file

@ -27,7 +27,7 @@
#if !FINAL_VERSION
#include "std3d.h"
#include <nel/3d/stereo_debugger.h>
#include "nel/3d/stereo_debugger.h"
// STL includes
@ -35,14 +35,14 @@
// #include <nel/misc/debug.h>
// Project includes
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include <nel/3d/render_target_manager.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
#include "nel/3d/render_target_manager.h"
using namespace std;
// using namespace NLMISC;

View file

@ -26,7 +26,7 @@
*/
#include "std3d.h"
#include <nel/3d/stereo_display.h>
#include "nel/3d/stereo_display.h"
// STL includes
@ -34,10 +34,10 @@
// #include <nel/misc/debug.h>
// Project includes
#include <nel/3d/stereo_ovr.h>
#include <nel/3d/stereo_ovr_04.h>
#include <nel/3d/stereo_libvr.h>
#include <nel/3d/stereo_debugger.h>
#include "nel/3d/stereo_ovr.h"
#include "nel/3d/stereo_ovr_04.h"
#include "nel/3d/stereo_libvr.h"
#include "nel/3d/stereo_debugger.h"
using namespace std;
// using namespace NLMISC;

View file

@ -26,7 +26,7 @@
*/
#include "std3d.h"
#include <nel/3d/stereo_hmd.h>
#include "nel/3d/stereo_hmd.h"
// STL includes

View file

@ -28,8 +28,8 @@
#ifdef HAVE_LIBVR
#include "std3d.h"
#include <nel/misc/time_nl.h>
#include <nel/3d/stereo_libvr.h>
#include "nel/misc/time_nl.h"
#include "nel/3d/stereo_libvr.h"
// STL includes
#include <sstream>
@ -41,13 +41,13 @@ extern "C" {
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
// Project includes

View file

@ -44,7 +44,7 @@
#ifdef HAVE_LIBOVR_02
#include "std3d.h"
#include <nel/3d/stereo_ovr.h>
#include "nel/3d/stereo_ovr.h"
// STL includes
#include <sstream>
@ -55,13 +55,13 @@
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
// Project includes

View file

@ -44,7 +44,7 @@
#ifdef HAVE_LIBOVR
#include "std3d.h"
#include <nel/3d/stereo_ovr_04.h>
#include "nel/3d/stereo_ovr_04.h"
// STL includes
#include <sstream>
@ -55,13 +55,13 @@
// NeL includes
// #include <nel/misc/debug.h>
#include <nel/3d/u_camera.h>
#include <nel/3d/u_driver.h>
#include <nel/3d/material.h>
#include <nel/3d/texture_bloom.h>
#include <nel/3d/texture_user.h>
#include <nel/3d/driver_user.h>
#include <nel/3d/u_texture.h>
#include "nel/3d/u_camera.h"
#include "nel/3d/u_driver.h"
#include "nel/3d/material.h"
#include "nel/3d/texture_bloom.h"
#include "nel/3d/texture_user.h"
#include "nel/3d/driver_user.h"
#include "nel/3d/u_texture.h"
// Project includes

View file

@ -17,6 +17,7 @@
#ifndef UT_MISC_STRING_COMMON
#define UT_MISC_STRING_COMMON
#include <limits>
#include <nel/misc/string_common.h>
struct CUTMiscStringCommon : public Test::Suite
@ -63,11 +64,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("-128", val);
TEST_ASSERT(ret && val == -128);
TEST_ASSERT(ret && val == std::numeric_limits<sint8>::min());
// max limit
ret = NLMISC::fromString("127", val);
TEST_ASSERT(ret && val == 127);
TEST_ASSERT(ret && val == std::numeric_limits<sint8>::max());
// min limit -1
ret = NLMISC::fromString("-129", val);
@ -123,11 +124,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("0", val);
TEST_ASSERT(ret && val == 0);
TEST_ASSERT(ret && val == std::numeric_limits<uint8>::min());
// max limit
ret = NLMISC::fromString("255", val);
TEST_ASSERT(ret && val == 255);
TEST_ASSERT(ret && val == std::numeric_limits<uint8>::max());
// min limit -1
ret = NLMISC::fromString("-1", val);
@ -187,11 +188,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("-32768", val);
TEST_ASSERT(ret && val == -32768);
TEST_ASSERT(ret && val == std::numeric_limits<sint16>::min());
// max limit
ret = NLMISC::fromString("32767", val);
TEST_ASSERT(ret && val == 32767);
TEST_ASSERT(ret && val == std::numeric_limits<sint16>::max());
// min limit -1
ret = NLMISC::fromString("-32769", val);
@ -247,11 +248,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("0", val);
TEST_ASSERT(ret && val == 0);
TEST_ASSERT(ret && val == std::numeric_limits<uint16>::min());
// max limit
ret = NLMISC::fromString("65535", val);
TEST_ASSERT(ret && val == 65535);
TEST_ASSERT(ret && val == std::numeric_limits<uint16>::max());
// min limit -1
ret = NLMISC::fromString("-1", val);
@ -311,11 +312,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("-2147483648", val);
TEST_ASSERT(ret && val == INT_MIN);
TEST_ASSERT(ret && val == std::numeric_limits<sint32>::min());
// max limit
ret = NLMISC::fromString("2147483647", val);
TEST_ASSERT(ret && val == INT_MAX);
TEST_ASSERT(ret && val == std::numeric_limits<sint32>::max());
// min limit -1
ret = NLMISC::fromString("-2147483649", val);
@ -371,11 +372,11 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("0", val);
TEST_ASSERT(ret && val == 0);
TEST_ASSERT(ret && val == std::numeric_limits<uint32>::min());
// max limit
ret = NLMISC::fromString("4294967295", val);
TEST_ASSERT(ret && val == 4294967295);
TEST_ASSERT(ret && val == std::numeric_limits<uint32>::max());
// min limit -1
ret = NLMISC::fromString("-1", val);
@ -435,21 +436,19 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("-9223372036854775808", val);
TEST_ASSERT(ret && val == LLONG_MIN);
TEST_ASSERT(ret && val == std::numeric_limits<sint64>::min());
// max limit
ret = NLMISC::fromString("9223372036854775807", val);
TEST_ASSERT(ret && val == LLONG_MAX);
TEST_ASSERT(ret && val == std::numeric_limits<sint64>::max());
// min limit -1
// min limit -1, unable to compare with minimum value because no lower type
ret = NLMISC::fromString("-9223372036854775809", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(LLONG_MIN == val);
TEST_ASSERT(ret && val == std::numeric_limits<sint64>::max());
// max limit +1
// max limit +1, unable to compare with maximum value because no higher type
ret = NLMISC::fromString("9223372036854775808", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(LLONG_MAX == val);
TEST_ASSERT(ret && val == std::numeric_limits<sint64>::min());
// with period
ret = NLMISC::fromString("1.2", val);
@ -497,22 +496,19 @@ struct CUTMiscStringCommon : public Test::Suite
// min limit
ret = NLMISC::fromString("0", val);
TEST_ASSERT(ret && val == 0);
TEST_ASSERT(ret && val == std::numeric_limits<uint64>::min());
// max limit
ret = NLMISC::fromString("18446744073709551615", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(ULLONG_MAX == val);
TEST_ASSERT(ret && val == std::numeric_limits<uint64>::max());
// min limit -1
// min limit -1, unable to compare with minimum value because no lower type
ret = NLMISC::fromString("-1", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(ULLONG_MAX == val);
TEST_ASSERT(ret && val == std::numeric_limits<uint64>::max());
// max limit +1
// max limit +1, unable to compare with maximum value because no higher type
ret = NLMISC::fromString("18446744073709551616", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(ULLONG_MAX == val);
TEST_ASSERT(ret && val == std::numeric_limits<uint64>::min());
// with period
ret = NLMISC::fromString("1.2", val);
@ -548,64 +544,67 @@ struct CUTMiscStringCommon : public Test::Suite
// positive value
ret = NLMISC::fromString("1", val);
TEST_ASSERT(ret && val == 1);
TEST_ASSERT(ret && val == 1.f);
// negative value
ret = NLMISC::fromString("-1", val);
TEST_ASSERT(ret && val == -1);
TEST_ASSERT(ret && val == -1.f);
// bad character
ret = NLMISC::fromString("a", val);
TEST_ASSERT(!ret && val == 0);
TEST_ASSERT(!ret && val == 0.f);
// right character and bad character
ret = NLMISC::fromString("1a", val);
TEST_ASSERT(ret && val == 1);
TEST_ASSERT(ret && val == 1.f);
// min limit
ret = NLMISC::fromString("-2147483648", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(INT_MIN == val);
ret = NLMISC::fromString("-3.4028235e+038", val);
TEST_ASSERT(ret && val == -std::numeric_limits<float>::max());
// min limit towards 0
ret = NLMISC::fromString("1.1754944e-038", val);
TEST_ASSERT(ret && val == std::numeric_limits<float>::min());
// max limit
ret = NLMISC::fromString("2147483647", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(INT_MAX == val);
ret = NLMISC::fromString("3.4028235e+038", val);
TEST_ASSERT(ret && val == std::numeric_limits<float>::max());
// min limit -1
ret = NLMISC::fromString("-2147483649", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(INT_MIN == val);
ret = NLMISC::fromString("-3.4028235e+048", val);
TEST_ASSERT(ret && val == -std::numeric_limits<float>::infinity());
// min limit towards 0 -1
ret = NLMISC::fromString("1.1754944e-048", val);
TEST_ASSERT(ret && val == 0.f);
// max limit +1
ret = NLMISC::fromString("2147483648", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(INT_MAX == val);
ret = NLMISC::fromString("3.4028235e+048", val);
TEST_ASSERT(ret && val == std::numeric_limits<float>::infinity());
// with period
ret = NLMISC::fromString("1.2", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(1.2f == val);
TEST_ASSERT(ret && val == 1.2f);
// with coma
ret = NLMISC::fromString("1,2", val);
TEST_ASSERT(ret && val == 1);
TEST_ASSERT(ret && val == 1.f);
// with spaces before
ret = NLMISC::fromString(" 10", val);
TEST_ASSERT(ret && val == 10);
TEST_ASSERT(ret && val == 10.f);
// with spaces after
ret = NLMISC::fromString("10 ", val);
TEST_ASSERT(ret && val == 10);
TEST_ASSERT(ret && val == 10.f);
// with 0s before
ret = NLMISC::fromString("001", val);
TEST_ASSERT(ret && val == 1);
TEST_ASSERT(ret && val == 1.f);
// with + before
ret = NLMISC::fromString("+1", val);
TEST_ASSERT(ret && val == 1);
TEST_ASSERT(ret && val == 1.f);
}
void fromStringDouble()
@ -632,24 +631,24 @@ struct CUTMiscStringCommon : public Test::Suite
TEST_ASSERT(ret && val == 1.0);
// min limit
ret = NLMISC::fromString("-1.7976931348623158e+308", val);
TEST_ASSERT(ret && val == -std::numeric_limits<double>::max());
// min limit towards 0
ret = NLMISC::fromString("2.2250738585072014e-308", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(DBL_MIN == val);
TEST_ASSERT(ret && val == std::numeric_limits<double>::min());
// max limit
ret = NLMISC::fromString("1.7976931348623158e+308", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(DBL_MAX == val);
TEST_ASSERT(ret && val == std::numeric_limits<double>::max());
// min limit -1
ret = NLMISC::fromString("3e-408", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(0 == val);
TEST_ASSERT(ret && val == 0.0);
// max limit +1
ret = NLMISC::fromString("2e+308", val);
TEST_ASSERT_MSG(ret, "should succeed");
TEST_ASSERT(INFINITY == val);
TEST_ASSERT(ret && val == std::numeric_limits<double>::infinity());
// with period
ret = NLMISC::fromString("1.2", val);