mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-11-15 00:07:08 +01:00
Update POCO library.
This commit is contained in:
1 parent
8d15f4b6e9
commit
233fc103f9
2521 files changed
+257092
-72789
No files matched your search
+9
-73
@@ -91,15 +91,9 @@ public:
|
||||
template <typename T>
|
||||
Var(const T& val)
|
||||
/// Creates the Var from the given value.
|
||||
#ifdef POCO_NO_SOO
|
||||
: _pHolder(new VarHolderImpl<T>(val))
|
||||
{
|
||||
}
|
||||
#else
|
||||
{
|
||||
construct(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
Var(const char* pVal);
|
||||
// Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied.
|
||||
@@ -222,7 +216,7 @@ public:
|
||||
else if (!pHolder)
|
||||
throw InvalidAccessException("Can not extract empty value.");
|
||||
else
|
||||
throw BadCastException(format("Can not convert %s to %s.",
|
||||
throw BadCastException(Poco::format("Can not convert %s to %s.",
|
||||
std::string(pHolder->type().name()),
|
||||
std::string(typeid(T).name())));
|
||||
}
|
||||
@@ -231,12 +225,8 @@ public:
|
||||
Var& operator = (const T& other)
|
||||
/// Assignment operator for assigning POD to Var
|
||||
{
|
||||
#ifdef POCO_NO_SOO
|
||||
Var tmp(other);
|
||||
swap(tmp);
|
||||
#else
|
||||
clear();
|
||||
construct(other);
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -612,79 +602,34 @@ private:
|
||||
return pStr->operator[](n);
|
||||
}
|
||||
|
||||
#ifdef POCO_NO_SOO
|
||||
|
||||
VarHolder* content() const
|
||||
{
|
||||
return _pHolder;
|
||||
}
|
||||
|
||||
void destruct()
|
||||
{
|
||||
if (!isEmpty()) delete content();
|
||||
}
|
||||
|
||||
VarHolder* _pHolder;
|
||||
|
||||
#else
|
||||
|
||||
VarHolder* content() const
|
||||
{
|
||||
return _placeholder.content();
|
||||
}
|
||||
|
||||
void destruct()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
void construct(const ValueType& value)
|
||||
{
|
||||
if (sizeof(VarHolderImpl<ValueType>) <= Placeholder<ValueType>::Size::value)
|
||||
{
|
||||
new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<ValueType>(value);
|
||||
_placeholder.setLocal(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_placeholder.pHolder = new VarHolderImpl<ValueType>(value);
|
||||
_placeholder.setLocal(false);
|
||||
}
|
||||
_placeholder.assign<VarHolderImpl<ValueType>, ValueType>(value);
|
||||
}
|
||||
|
||||
void construct(const char* value)
|
||||
{
|
||||
std::string val(value);
|
||||
if (sizeof(VarHolderImpl<std::string>) <= Placeholder<std::string>::Size::value)
|
||||
{
|
||||
new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<std::string>(val);
|
||||
_placeholder.setLocal(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_placeholder.pHolder = new VarHolderImpl<std::string>(val);
|
||||
_placeholder.setLocal(false);
|
||||
}
|
||||
_placeholder.assign<VarHolderImpl<std::string>, std::string>(val);
|
||||
}
|
||||
|
||||
void construct(const Var& other)
|
||||
{
|
||||
if (!other.isEmpty())
|
||||
other.content()->clone(&_placeholder);
|
||||
else
|
||||
_placeholder.erase();
|
||||
}
|
||||
|
||||
void destruct()
|
||||
{
|
||||
if (!isEmpty())
|
||||
{
|
||||
if (_placeholder.isLocal())
|
||||
content()->~VarHolder();
|
||||
else
|
||||
delete content();
|
||||
}
|
||||
}
|
||||
|
||||
Placeholder<VarHolder> _placeholder;
|
||||
|
||||
#endif // POCO_NO_SOO
|
||||
};
|
||||
|
||||
|
||||
@@ -699,24 +644,17 @@ private:
|
||||
|
||||
inline void Var::swap(Var& other)
|
||||
{
|
||||
#ifdef POCO_NO_SOO
|
||||
|
||||
std::swap(_pHolder, other._pHolder);
|
||||
|
||||
#else
|
||||
|
||||
if (this == &other) return;
|
||||
|
||||
if (!_placeholder.isLocal() && !other._placeholder.isLocal())
|
||||
{
|
||||
std::swap(_placeholder.pHolder, other._placeholder.pHolder);
|
||||
_placeholder.swap(other._placeholder);
|
||||
}
|
||||
else
|
||||
{
|
||||
Var tmp(*this);
|
||||
try
|
||||
{
|
||||
if (_placeholder.isLocal()) destruct();
|
||||
construct(other);
|
||||
other = tmp;
|
||||
}
|
||||
@@ -726,8 +664,6 @@ inline void Var::swap(Var& other)
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user