Skip to content
Commits on Source (4)
......@@ -28,6 +28,7 @@ qtc-gdbmacros/
*.o
*.a
moc_*
build/
*.cmake
CMakeFiles/
......
......@@ -2,7 +2,7 @@
# setup version numbers
set(VERSION_MAJOR 0)
set(VERSION_MINOR 8)
set(VERSION_PATCH 1)
set(VERSION_PATCH 2)
set(VERSION_STR "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("Project version: ${VERSION_STR}")
......
camp (0.8.2-1) UNRELEASED; urgency=medium
* New upstream version 0.8.2. Closes: #876147
* d/patches: Remove obsolete hide_boost_from_qt4moc.patch
-- Flavien Bridault <fbridault@ircad.fr> Mon, 16 Apr 2018 13:52:38 +0000
camp (0.8.1-2) unstable; urgency=medium
* d/control: Add proper conflicts/replaces with 0.7 versions. Closes: #876130
......
Description: Hide boost includes from qt4 moc.
This prevents FTBFS with 'Parse error at "BOOST_JOIN"'
Author: Robert Bruce Park <robert.park@canonical.com>
--- camp.orig/include/camp/arraymapper.hpp
+++ camp/include/camp/arraymapper.hpp
@@ -36,7 +36,9 @@
#include <camp/config.hpp>
#include <camp/detail/yesnotype.hpp>
+#ifndef Q_MOC_RUN
#include <boost/array.hpp>
+#endif
#include <list>
#include <vector>
--- camp.orig/include/camp/detail/functionimpl.hpp
+++ camp/include/camp/detail/functionimpl.hpp
@@ -38,9 +38,11 @@
#include <camp/value.hpp>
#include <camp/errors.hpp>
#include <camp/detail/callhelper.hpp>
+#ifndef Q_MOC_RUN
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/assign/list_of.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/detail/functiontraits.hpp
+++ camp/include/camp/detail/functiontraits.hpp
@@ -35,9 +35,11 @@
#include <camp/detail/yesnotype.hpp>
+#ifndef Q_MOC_RUN
#include <boost/utility/enable_if.hpp>
#include <boost/function_types/is_callable_builtin.hpp>
#include <boost/function_types/result_type.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/detail/getter.hpp
+++ camp/include/camp/detail/getter.hpp
@@ -35,8 +35,10 @@
#include <camp/userobject.hpp>
+#ifndef Q_MOC_RUN
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/detail/issmartpointer.hpp
+++ camp/include/camp/detail/issmartpointer.hpp
@@ -35,7 +35,9 @@
#include <camp/detail/yesnotype.hpp>
+#ifndef Q_MOC_RUN
#include <boost/utility/enable_if.hpp>
+#endif
#include <type_traits>
namespace camp
--- camp.orig/include/camp/detail/objecttraits.hpp
+++ camp/include/camp/detail/objecttraits.hpp
@@ -36,9 +36,11 @@
#include <camp/detail/rawtype.hpp>
#include <camp/detail/issmartpointer.hpp>
+#ifndef Q_MOC_RUN
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/utility/enable_if.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/detail/propertyfactory.hpp
+++ camp/include/camp/detail/propertyfactory.hpp
@@ -40,10 +40,12 @@
#include <camp/detail/enumpropertyimpl.hpp>
#include <camp/detail/userpropertyimpl.hpp>
#include <camp/detail/functiontraits.hpp>
+#ifndef Q_MOC_RUN
#include <boost/function.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/type_traits/is_void.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/detail/typeid.hpp
+++ camp/include/camp/detail/typeid.hpp
@@ -36,7 +36,9 @@
#include <camp/detail/objecttraits.hpp>
#include <camp/detail/yesnotype.hpp>
+#ifndef Q_MOC_RUN
#include <boost/utility/enable_if.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/detail/valueimpl.hpp
+++ camp/include/camp/detail/valueimpl.hpp
@@ -36,7 +36,9 @@
#include <camp/type.hpp>
#include <camp/valuemapper.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/variant/static_visitor.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/enumbuilder.hpp
+++ camp/include/camp/enumbuilder.hpp
@@ -35,7 +35,9 @@
#include <camp/config.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/enumobject.hpp
+++ camp/include/camp/enumobject.hpp
@@ -36,9 +36,11 @@
#include <camp/config.hpp>
#include <camp/enumget.hpp>
+#ifndef Q_MOC_RUN
#include <boost/type_traits.hpp>
#include <boost/operators.hpp>
#include <boost/utility/enable_if.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/error.hpp
+++ camp/include/camp/error.hpp
@@ -35,8 +35,10 @@
#include <camp/config.hpp>
+#ifndef Q_MOC_RUN
#include <boost/current_function.hpp>
#include <boost/lexical_cast.hpp>
+#endif
#include <exception>
#include <string>
--- camp.orig/include/camp/tagholder.hpp
+++ camp/include/camp/tagholder.hpp
@@ -37,7 +37,9 @@
#include <camp/config.hpp>
#include <camp/detail/getter.hpp>
#include <camp/value.hpp>
+#ifndef Q_MOC_RUN
#include <boost/shared_ptr.hpp>
+#endif
#include <map>
--- camp.orig/include/camp/userobject.hpp
+++ camp/include/camp/userobject.hpp
@@ -39,10 +39,12 @@
#include <camp/errors.hpp>
#include <camp/detail/objecttraits.hpp>
#include <camp/detail/objectholder.hpp>
+#ifndef Q_MOC_RUN
#include <boost/operators.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/utility/enable_if.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/value.hpp
+++ camp/include/camp/value.hpp
@@ -40,7 +40,9 @@
#include <camp/userobject.hpp>
#include <camp/valuemapper.hpp>
#include <camp/detail/valueimpl.hpp>
+#ifndef Q_MOC_RUN
#include <boost/operators.hpp>
+#endif
#include <iosfwd>
#include <string>
--- camp.orig/include/camp/valuemapper.hpp
+++ camp/include/camp/valuemapper.hpp
@@ -39,9 +39,11 @@
#include <camp/userobject.hpp>
#include <camp/arraymapper.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/lexical_cast.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
+#endif
namespace camp_ext
--- camp.orig/include/camp/valuevisitor.hpp
+++ camp/include/camp/valuevisitor.hpp
@@ -34,7 +34,9 @@
#define CAMP_VALUEVISITOR_HPP
+#ifndef Q_MOC_RUN
#include <boost/variant/static_visitor.hpp>
+#endif
namespace camp
--- camp.orig/test/arrayproperty.cpp
+++ camp/test/arrayproperty.cpp
@@ -31,7 +31,9 @@
#include <camp/classget.hpp>
#include <camp/errors.hpp>
#include <camp/arrayproperty.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace ArrayPropertyTest;
--- camp.orig/test/arrayproperty.hpp
+++ camp/test/arrayproperty.hpp
@@ -32,7 +32,9 @@
#include <camp/camptype.hpp>
#include <camp/class.hpp>
+#ifndef Q_MOC_RUN
#include <boost/array.hpp>
+#endif
#include <list>
#include <vector>
--- camp.orig/test/class.cpp
+++ camp/test/class.cpp
@@ -30,7 +30,9 @@
#include "class.hpp"
#include <camp/classget.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace ClassTest;
--- camp.orig/test/classvisitor.cpp
+++ camp/test/classvisitor.cpp
@@ -29,7 +29,9 @@
#include "classvisitor.hpp"
#include <camp/classget.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace ClassVisitorTest;
--- camp.orig/test/constructor.cpp
+++ camp/test/constructor.cpp
@@ -30,7 +30,9 @@
#include "constructor.hpp"
#include <camp/classget.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace ConstructorTest;
--- camp.orig/test/enum.cpp
+++ camp/test/enum.cpp
@@ -30,7 +30,9 @@
#include "enum.hpp"
#include <camp/enumget.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace EnumTest;
--- camp.orig/test/enumobject.cpp
+++ camp/test/enumobject.cpp
@@ -31,7 +31,9 @@
#include <camp/enumget.hpp>
#include <camp/enumobject.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace EnumObjectTest;
--- camp.orig/test/enumproperty.cpp
+++ camp/test/enumproperty.cpp
@@ -32,7 +32,9 @@
#include <camp/enumget.hpp>
#include <camp/errors.hpp>
#include <camp/enumproperty.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace EnumPropertyTest;
--- camp.orig/test/enumproperty.hpp
+++ camp/test/enumproperty.hpp
@@ -33,7 +33,9 @@
#include <camp/camptype.hpp>
#include <camp/enum.hpp>
#include <camp/class.hpp>
+#ifndef Q_MOC_RUN
#include <boost/array.hpp>
+#endif
#include <list>
#include <vector>
--- camp.orig/test/function.cpp
+++ camp/test/function.cpp
@@ -32,7 +32,9 @@
#include <camp/enumget.hpp>
#include <camp/function.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace FunctionTest;
--- camp.orig/test/functionaccess.cpp
+++ camp/test/functionaccess.cpp
@@ -31,7 +31,9 @@
#include <camp/classget.hpp>
#include <camp/function.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace FunctionAccessTest;
--- camp.orig/test/inheritance.cpp
+++ camp/test/inheritance.cpp
@@ -31,7 +31,9 @@
#include <camp/class.hpp>
#include <camp/classget.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace InheritanceTest;
--- camp.orig/test/main.cpp
+++ camp/test/main.cpp
@@ -34,4 +34,6 @@
// so that we don't need to link to it as an external library.
// Note: to disable that and link to boost.test as a library,
// simply remove "/included" from the header path below.
+#ifndef Q_MOC_RUN
#include <boost/test/included/unit_test.hpp>
+#endif
--- camp.orig/test/mapper.cpp
+++ camp/test/mapper.cpp
@@ -29,7 +29,9 @@
#include "mapper.hpp"
#include <camp/classget.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace MapperTest;
--- camp.orig/test/property.cpp
+++ camp/test/property.cpp
@@ -32,7 +32,9 @@
#include <camp/enumget.hpp>
#include <camp/property.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace PropertyTest;
--- camp.orig/test/property.hpp
+++ camp/test/property.hpp
@@ -33,7 +33,9 @@
#include <camp/camptype.hpp>
#include <camp/class.hpp>
#include <camp/enum.hpp>
+#ifndef Q_MOC_RUN
#include <boost/shared_ptr.hpp>
+#endif
#include <string>
namespace PropertyTest
--- camp.orig/test/propertyaccess.cpp
+++ camp/test/propertyaccess.cpp
@@ -31,7 +31,9 @@
#include <camp/classget.hpp>
#include <camp/property.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace PropertyAccessTest;
--- camp.orig/test/qt/functionmapping.cpp
+++ camp/test/qt/functionmapping.cpp
@@ -31,7 +31,9 @@
#include "logger.hpp"
#include <camp/class.hpp>
#include <camp/classget.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace FunctionMappingTest;
--- camp.orig/test/qt/main.cpp
+++ camp/test/qt/main.cpp
@@ -34,4 +34,6 @@
// so that we don't need to link to it as an external library.
// Note: to disable that and link to boost.test as a library,
// simply remove "/included" from the header path below.
+#ifndef Q_MOC_RUN
#include <boost/test/included/unit_test.hpp>
+#endif
--- camp.orig/test/qt/propertymapping.cpp
+++ camp/test/qt/propertymapping.cpp
@@ -30,7 +30,9 @@
#include "propertymapping.hpp"
#include <camp/class.hpp>
#include <camp/classget.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace PropertyMappingTest;
--- camp.orig/test/qt/qstringmapping.cpp
+++ camp/test/qt/qstringmapping.cpp
@@ -29,7 +29,9 @@
#include <camp/value.hpp>
#include <camp/qt/qt.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
#include <QString>
// To make the boost.test logger happy
--- camp.orig/test/tagholder.cpp
+++ camp/test/tagholder.cpp
@@ -30,7 +30,9 @@
#include "tagholder.hpp"
#include <camp/classget.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace TagHolderTest;
--- camp.orig/test/userobject.cpp
+++ camp/test/userobject.cpp
@@ -31,7 +31,9 @@
#include <camp/classget.hpp>
#include <camp/errors.hpp>
#include <camp/userobject.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace UserObjectTest;
--- camp.orig/test/userobject.hpp
+++ camp/test/userobject.hpp
@@ -32,7 +32,9 @@
#include <camp/camptype.hpp>
#include <camp/class.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
+#endif
#include <ostream>
namespace UserObjectTest
--- camp.orig/test/userproperty.cpp
+++ camp/test/userproperty.cpp
@@ -30,7 +30,9 @@
#include "userproperty.hpp"
#include <camp/classget.hpp>
#include <camp/userproperty.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace UserPropertyTest;
--- camp.orig/test/value.cpp
+++ camp/test/value.cpp
@@ -30,7 +30,9 @@
#include "value.hpp"
#include <camp/value.hpp>
#include <camp/errors.hpp>
+#ifndef Q_MOC_RUN
#include <boost/test/unit_test.hpp>
+#endif
using namespace ValueTest;
--- camp.orig/include/camp/class.hpp
+++ camp/include/camp/class.hpp
@@ -45,12 +45,14 @@
#include <camp/userobject.hpp>
#include <camp/detail/classmanager.hpp>
#include <camp/detail/typeid.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
//#include <boost/shared_ptr.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/classbuilder.hpp
+++ camp/include/camp/classbuilder.hpp
@@ -40,9 +40,11 @@
#include <camp/detail/functiontraits.hpp>
#include <camp/detail/constructorimpl.hpp>
#include <camp/detail/propertyfactory.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
#include <boost/mpl/if.hpp>
#include <boost/function_types/function_type.hpp>
+#endif
#include <cassert>
#include <string>
--- camp.orig/include/camp/detail/arraypropertyimpl.hpp
+++ camp/include/camp/detail/arraypropertyimpl.hpp
@@ -37,7 +37,9 @@
#include <camp/arrayproperty.hpp>
#include <camp/arraymapper.hpp>
#include <camp/detail/valueprovider.hpp>
+#ifndef Q_MOC_RUN
#include <boost/type_traits/remove_reference.hpp>
+#endif
namespace camp
--- camp.orig/include/camp/enum.hpp
+++ camp/include/camp/enum.hpp
@@ -39,11 +39,13 @@
#include <camp/enumget.hpp>
#include <camp/detail/enummanager.hpp>
#include <camp/detail/typeid.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index/random_access_index.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/detail/enummanager.hpp
+++ camp/include/camp/detail/enummanager.hpp
@@ -36,11 +36,13 @@
#include <camp/config.hpp>
#include <camp/detail/observernotifier.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
+#endif
#include <string>
--- camp.orig/include/camp/detail/classmanager.hpp
+++ camp/include/camp/detail/classmanager.hpp
@@ -36,12 +36,14 @@
#include <camp/config.hpp>
#include <camp/detail/observernotifier.hpp>
+#ifndef Q_MOC_RUN
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
+#endif
#include <string>
remove_licences_files.patch
hide_boost_from_qt4moc.patch
......@@ -86,7 +86,7 @@ public:
case 1:
{
QVariant arg1 = QtHelper::valueToVariant(args[0]);
const auto arg1 = QtHelper::argumentToVariant(args[0], m_metaMethod.parameterType(0));
m_metaMethod.invoke(object.get<T*>(), Qt::DirectConnection, ret
, QGenericArgument(arg1.typeName(), arg1.data()));
break;
......@@ -94,8 +94,8 @@ public:
case 2:
{
QVariant arg1 = QtHelper::valueToVariant(args[0]);
QVariant arg2 = QtHelper::valueToVariant(args[1]);
const auto arg1 = QtHelper::argumentToVariant(args[0], m_metaMethod.parameterType(0));
const auto arg2 = QtHelper::argumentToVariant(args[1], m_metaMethod.parameterType(1));
m_metaMethod.invoke(object.get<T*>(), Qt::DirectConnection, ret
, QGenericArgument(arg1.typeName(), arg1.data())
, QGenericArgument(arg2.typeName(), arg2.data()));
......@@ -104,9 +104,9 @@ public:
case 3:
{
QVariant arg1 = QtHelper::valueToVariant(args[0]);
QVariant arg2 = QtHelper::valueToVariant(args[1]);
QVariant arg3 = QtHelper::valueToVariant(args[2]);
const auto arg1 = QtHelper::argumentToVariant(args[0], m_metaMethod.parameterType(0));
const auto arg2 = QtHelper::argumentToVariant(args[1], m_metaMethod.parameterType(1));
const auto arg3 = QtHelper::argumentToVariant(args[2], m_metaMethod.parameterType(2));
m_metaMethod.invoke(object.get<T*>(), Qt::DirectConnection, ret
, QGenericArgument(arg1.typeName(), arg1.data())
, QGenericArgument(arg2.typeName(), arg2.data())
......@@ -116,10 +116,10 @@ public:
case 4:
{
QVariant arg1 = QtHelper::valueToVariant(args[0]);
QVariant arg2 = QtHelper::valueToVariant(args[1]);
QVariant arg3 = QtHelper::valueToVariant(args[2]);
QVariant arg4 = QtHelper::valueToVariant(args[3]);
const auto arg1 = QtHelper::argumentToVariant(args[0], m_metaMethod.parameterType(0));
const auto arg2 = QtHelper::argumentToVariant(args[1], m_metaMethod.parameterType(1));
const auto arg3 = QtHelper::argumentToVariant(args[2], m_metaMethod.parameterType(2));
const auto arg4 = QtHelper::argumentToVariant(args[3], m_metaMethod.parameterType(3));
m_metaMethod.invoke(object.get<T*>(), Qt::DirectConnection, ret
, QGenericArgument(arg1.typeName(), arg1.data())
, QGenericArgument(arg2.typeName(), arg2.data())
......@@ -130,11 +130,11 @@ public:
case 5:
{
QVariant arg1 = QtHelper::valueToVariant(args[0]);
QVariant arg2 = QtHelper::valueToVariant(args[1]);
QVariant arg3 = QtHelper::valueToVariant(args[2]);
QVariant arg4 = QtHelper::valueToVariant(args[3]);
QVariant arg5 = QtHelper::valueToVariant(args[4]);
const auto arg1 = QtHelper::argumentToVariant(args[0], m_metaMethod.parameterType(0));
const auto arg2 = QtHelper::argumentToVariant(args[1], m_metaMethod.parameterType(1));
const auto arg3 = QtHelper::argumentToVariant(args[2], m_metaMethod.parameterType(2));
const auto arg4 = QtHelper::argumentToVariant(args[3], m_metaMethod.parameterType(3));
const auto arg5 = QtHelper::argumentToVariant(args[4], m_metaMethod.parameterType(4));
m_metaMethod.invoke(object.get<T*>(), Qt::DirectConnection, ret
, QGenericArgument(arg1.typeName(), arg1.data())
, QGenericArgument(arg2.typeName(), arg2.data())
......
......@@ -105,11 +105,11 @@ public:
case QMetaType::QString: return QVariant::String;
case QMetaType::QByteArray: return QVariant::ByteArray;
case QMetaType::VoidStar: return QVariant::Invalid;
case QMetaType::Long: return QVariant::Int;
case QMetaType::Long: return (sizeof(int) == sizeof(long)) ? QVariant::Int : QVariant::LongLong;
case QMetaType::LongLong: return QVariant::LongLong;
case QMetaType::Short: return QVariant::Int;
case QMetaType::Char: return QVariant::Char;
case QMetaType::ULong: return QVariant::UInt;
case QMetaType::ULong: return (sizeof(int) == sizeof(long)) ? QVariant::UInt : QVariant::ULongLong;
case QMetaType::ULongLong: return QVariant::ULongLong;
case QMetaType::UShort: return QVariant::UInt;
case QMetaType::UChar: return QVariant::Char;
......@@ -166,12 +166,18 @@ public:
*/
static QVariant valueToVariant(const camp::Value& value)
{
auto toInt = [](const camp::Value& value)
{
return value.to<long>() > static_cast<long>(std::numeric_limits<int>::max())
? QVariant(value.to<long long>())
: QVariant(value.to<int>());
};
switch (value.type())
{
default:
case camp::noType: return QVariant();
case camp::boolType: return QVariant(value.to<bool>());
case camp::intType: return QVariant(value.to<int>());
case camp::intType: return toInt(value);
case camp::realType: return QVariant(value.to<double>());
case camp::stringType: return QVariant(value.to<QString>());
case camp::enumType: return QVariant(value.to<int>());
......@@ -179,6 +185,38 @@ public:
}
}
/**
* \brief Convert a CAMP value to a QGenericArgument
*
* \param value Source camp::Value to convert
*
* \return \a value converted to a QGenericArgument
*/
static QVariant argumentToVariant(const camp::Value& value, int metaType)
{
switch (metaType)
{
default:
case QMetaType::Void: return QVariant();
case QMetaType::Bool: return value.to<bool>();
case QMetaType::Int: return value.to<int>();
case QMetaType::UInt: return value.to<unsigned int>();
case QMetaType::Double: return value.to<double>();
case QMetaType::QChar: return value.to<char>();
case QMetaType::QString: return value.to<QString>();
case QMetaType::Long: return sizeof(int) == sizeof(long) ? value.to<int>(): value.to<long long>();
case QMetaType::LongLong: return value.to<long long>();
case QMetaType::Short: return value.to<short>();
case QMetaType::Char: return value.to<char>();
case QMetaType::ULong: return sizeof(int) == sizeof(long) ? value.to<unsigned int>(): value.to<unsigned long long>();
case QMetaType::ULongLong: return value.to<unsigned long long>();;
case QMetaType::UShort: return value.to<unsigned short>();;
case QMetaType::UChar: return value.to<unsigned char>();;
case QMetaType::Float: return value.to<float>();
}
}
/**
* \brief Convert a QVariant to a CAMP value
*
......
......@@ -40,8 +40,8 @@
#include <camp/arraymapper.hpp>
#include <camp/errors.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
#include <type_traits>
namespace camp_ext
......@@ -124,7 +124,9 @@ struct ValueMapper
static camp::UserObject to(const T& source) {return camp::UserObject(source);}
static T from(bool) {CAMP_ERROR(camp::BadType(camp::boolType, camp::mapType<T>()));}
static T from(int) {CAMP_ERROR(camp::BadType(camp::intType, camp::mapType<T>()));}
static T from(long) {CAMP_ERROR(camp::BadType(camp::intType, camp::mapType<T>()));}
static T from(long long) {CAMP_ERROR(camp::BadType(camp::intType, camp::mapType<T>()));}
static T from(double) {CAMP_ERROR(camp::BadType(camp::realType, camp::mapType<T>()));}
static T from(const std::string&) {CAMP_ERROR(camp::BadType(camp::stringType, camp::mapType<T>()));}
static T from(const camp::EnumObject&) {CAMP_ERROR(camp::BadType(camp::enumType, camp::mapType<T>()));}
......@@ -135,7 +137,7 @@ struct ValueMapper
* Specialization of ValueMapper for abstract types
*/
template <typename T>
struct ValueMapper<T, typename boost::enable_if<boost::is_abstract<T> >::type>
struct ValueMapper<T, typename std::enable_if<std::is_abstract<T>::value >::type>
{
static const int type = camp::userType;
static camp::UserObject to(const T& source) {return camp::UserObject(source);}
......@@ -152,6 +154,7 @@ struct ValueMapper<bool>
static bool from(bool source) {return source;}
static bool from(long source) {return source != 0;}
static bool from(long long source) {return source != 0;}
static bool from(double source) {return source != 0.;}
static bool from(const std::string& source)
{
......@@ -178,16 +181,18 @@ struct ValueMapper<bool>
* Specialization of ValueMapper for integers
*/
template <typename T>
struct ValueMapper<T, typename boost::enable_if_c<boost::is_integral<T>::value
&& !boost::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !boost::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
struct ValueMapper<T, typename std::enable_if<std::is_integral<T>::value
&& !std::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !std::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
>::type>
{
static const int type = camp::intType;
static long to(T source) {return static_cast<long>(source);}
static T from(bool source) {return static_cast<T>(source);}
static T from(int source) {return static_cast<T>(source);}
static T from(long source) {return static_cast<T>(source);}
static T from(long long ) {CAMP_ERROR(camp::BadType(camp::userType, camp::intType));}
static T from(double source) {return static_cast<T>(source);}
static T from(const std::string& source) {return boost::lexical_cast<T>(source);}
static T from(const camp::EnumObject& source) {return static_cast<T>(source.value());}
......@@ -198,16 +203,19 @@ struct ValueMapper<T, typename boost::enable_if_c<boost::is_integral<T>::value
* Specialization of ValueMapper for reals
*/
template <typename T>
struct ValueMapper<T, typename boost::enable_if_c<boost::is_float<T>::value
&& !boost::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !boost::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
struct ValueMapper<T, typename std::enable_if<std::is_floating_point<T>::value
&& !std::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !std::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
>::type>
{
static const int type = camp::realType;
static double to(T source) {return static_cast<double>(source);}
static T from(bool source) {return static_cast<T>(source);}
static T from(int source) {return static_cast<T>(source);}
static T from(long source) {return static_cast<T>(source);}
static T from(long long source) {return static_cast<T>(source);}
static T from(float source) {return static_cast<T>(source);}
static T from(double source) {return static_cast<T>(source);}
static T from(const std::string& source) {return boost::lexical_cast<T>(source);}
static T from(const camp::EnumObject& source) {return static_cast<T>(source.value());}
......@@ -224,7 +232,9 @@ struct ValueMapper<std::string>
static const std::string& to(const std::string& source) {return source;}
static std::string from(bool source) {return boost::lexical_cast<std::string>(source);}
static std::string from(int source) {return boost::lexical_cast<std::string>(source);}
static std::string from(long source) {return boost::lexical_cast<std::string>(source);}
static std::string from(long long source) {return boost::lexical_cast<std::string>(source);}
static std::string from(double source) {return boost::lexical_cast<std::string>(source);}
static std::string from(const std::string& source) {return source;}
static std::string from(const camp::EnumObject& source) {return source.name();}
......@@ -238,9 +248,9 @@ struct ValueMapper<std::string>
* Warning: special case for char[] and const char[], they are strings not arrays
*/
template <typename T>
struct ValueMapper<T, typename boost::enable_if_c<camp::detail::IsArray<T>::value
&& !boost::is_same<typename camp_ext::ArrayMapper<T>::ElementType, char>::value
&& !boost::is_same<typename camp_ext::ArrayMapper<T>::ElementType, const char>::value
struct ValueMapper<T, typename std::enable_if<camp::detail::IsArray<T>::value
&& !std::is_same<typename camp_ext::ArrayMapper<T>::ElementType, char>::value
&& !std::is_same<typename camp_ext::ArrayMapper<T>::ElementType, const char>::value
>::type>
{
static const int type = camp::arrayType;
......@@ -267,16 +277,18 @@ struct ValueMapper<const char[N]>
* Specialization of ValueMapper for enum types
*/
template <typename T>
struct ValueMapper<T, typename boost::enable_if_c<boost::is_enum<T>::value
&& !boost::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !boost::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
struct ValueMapper<T, typename std::enable_if<std::is_enum<T>::value
&& !std::is_const<T>::value // to avoid conflict with ValueMapper<const T>
&& !std::is_reference<T>::value // to avoid conflict with ValueMapper<T&>
>::type>
{
static const int type = camp::enumType;
static camp::EnumObject to(T source) {return camp::EnumObject(source);}
static T from(bool source) {return static_cast<T>(static_cast<long>(source));}
static T from(int source) {return static_cast<T>(source);}
static T from(long source) {return static_cast<T>(source);}
static T from(long long source) {return static_cast<T>(source);}
static T from(double source) {return static_cast<T>(static_cast<long>(source));}
static T from(const camp::EnumObject& source) {return static_cast<T>(source.value());}
static T from(const camp::UserObject&) {CAMP_ERROR(camp::BadType(camp::userType, camp::enumType));}
......@@ -313,7 +325,9 @@ struct ValueMapper<camp::EnumObject>
static const camp::EnumObject& from(const camp::EnumObject& source) {return source;}
static camp::UserObject from(bool) {CAMP_ERROR(camp::BadType(camp::boolType, camp::enumType));}
static camp::UserObject from(int) {CAMP_ERROR(camp::BadType(camp::intType, camp::enumType));}
static camp::UserObject from(long) {CAMP_ERROR(camp::BadType(camp::intType, camp::enumType));}
static camp::UserObject from(long long) {CAMP_ERROR(camp::BadType(camp::intType, camp::enumType));}
static camp::UserObject from(double) {CAMP_ERROR(camp::BadType(camp::realType, camp::enumType));}
static camp::UserObject from(const std::string&) {CAMP_ERROR(camp::BadType(camp::stringType, camp::enumType));}
static camp::UserObject from(const camp::UserObject&) {CAMP_ERROR(camp::BadType(camp::enumType, camp::enumType));}
......@@ -330,7 +344,9 @@ struct ValueMapper<camp::UserObject>
static const camp::UserObject& from(const camp::UserObject& source) {return source;}
static camp::UserObject from(bool) {CAMP_ERROR(camp::BadType(camp::boolType, camp::userType));}
static camp::UserObject from(int) {CAMP_ERROR(camp::BadType(camp::intType, camp::userType));}
static camp::UserObject from(long) {CAMP_ERROR(camp::BadType(camp::intType, camp::userType));}
static camp::UserObject from(long long) {CAMP_ERROR(camp::BadType(camp::intType, camp::userType));}
static camp::UserObject from(double) {CAMP_ERROR(camp::BadType(camp::realType, camp::userType));}
static camp::UserObject from(const std::string&) {CAMP_ERROR(camp::BadType(camp::stringType, camp::userType));}
static camp::UserObject from(const camp::EnumObject&) {CAMP_ERROR(camp::BadType(camp::enumType, camp::userType));}
......
......@@ -32,7 +32,7 @@
#include <camp/camptype.hpp>
#include <camp/class.hpp>
#include <boost/array.hpp>
#include <array>
#include <list>
#include <vector>
......@@ -76,7 +76,7 @@ namespace ArrayPropertyTest
}
bool bools[2];
boost::array<int, 3> ints;
std::array<int, 3> ints;
std::vector<std::string> strings;
std::list<MyType> objects;
};
......
......@@ -32,6 +32,8 @@
#include <camp/classget.hpp>
#include <boost/test/unit_test.hpp>
#include <numeric>
using namespace PropertyMappingTest;
//-----------------------------------------------------------------------------
......@@ -43,7 +45,7 @@ struct PropertyMappingFixture
object.setBool(true);
object.setInt(-10);
object.setULong(20);
object.setULong(std::numeric_limits<unsigned long>::max() - 1);
object.setDouble(0.55);
object.setString("hello");
object.setEnum(MyClass::two);
......@@ -91,7 +93,7 @@ BOOST_AUTO_TEST_CASE(get)
{
BOOST_CHECK_EQUAL(metaclass->property("m_bool_read").get(object).to<bool>(), true);
BOOST_CHECK_EQUAL(metaclass->property("m_int_read").get(object).to<int>(), -10);
BOOST_CHECK_EQUAL(metaclass->property("m_ulong_read").get(object).to<unsigned long>(), 20);
BOOST_CHECK_EQUAL(metaclass->property("m_ulong_read").get(object).to<unsigned long>(), std::numeric_limits<unsigned long>::max() - 1);
BOOST_CHECK_CLOSE(metaclass->property("m_double_read").get(object).to<double>(), 0.55, 1E-5);
BOOST_CHECK_EQUAL(metaclass->property("m_string_read").get(object).to<QString>(), "hello");
BOOST_CHECK_EQUAL(metaclass->property("m_enum_read").get(object).to<MyClass::Enum>(), MyClass::two);
......@@ -102,14 +104,14 @@ BOOST_AUTO_TEST_CASE(set)
{
metaclass->property("m_bool").set(object, false);
metaclass->property("m_int").set(object, -2);
metaclass->property("m_ulong").set(object, 50);
metaclass->property("m_ulong").set(object, std::numeric_limits<unsigned long>::max() - 1);
metaclass->property("m_double").set(object, -8.8);
metaclass->property("m_string").set(object, "bonjour");
metaclass->property("m_enum").set(object, MyClass::three);
BOOST_CHECK_EQUAL(metaclass->property("m_bool").get(object).to<bool>(), false);
BOOST_CHECK_EQUAL(metaclass->property("m_int").get(object).to<int>(), -2);
BOOST_CHECK_EQUAL(metaclass->property("m_ulong").get(object).to<unsigned long>(), 50);
BOOST_CHECK_EQUAL(metaclass->property("m_ulong").get(object).to<unsigned long>(), std::numeric_limits<unsigned long>::max() - 1);
BOOST_CHECK_CLOSE(metaclass->property("m_double").get(object).to<double>(), -8.8, 1E-5);
BOOST_CHECK_EQUAL(metaclass->property("m_string").get(object).to<QString>(), "bonjour");
BOOST_CHECK_EQUAL(metaclass->property("m_enum").get(object).to<MyClass::Enum>(), MyClass::three);
......