From: <ag...@us...> - 2010-12-29 16:30:00
|
Revision: 1835 http://zoolib.svn.sourceforge.net/zoolib/?rev=1835&view=rev Author: agreen Date: 2010-12-29 16:29:53 +0000 (Wed, 29 Dec 2010) Log Message: ----------- As we're not basing ZAny on boost::any (we need voidstar) I've reorganized and simplified it. Separate ZAny coercion functions into own file. Modified Paths: -------------- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp trunk/zoolib/source/cxx/zoolib/ZAny.cpp trunk/zoolib/source/cxx/zoolib/ZAny.h trunk/zoolib/source/cxx/zoolib/ZVal_Any.h Added Paths: ----------- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h Modified: trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp =================================================================== --- trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/more/zoolib/zra/ZRA_AsSQL.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -21,6 +21,7 @@ #include "zoolib/ZLog.h" #include "zoolib/ZStrim_Escaped.h" #include "zoolib/ZString.h" +#include "zoolib/ZUtil_Any.h" #include "zoolib/ZUtil_Strim.h" #include "zoolib/ZVisitor_Do_T.h" #include "zoolib/ZVisitor_Expr_Bool_ValPred_Any_DoToStrim.h" Modified: trunk/zoolib/source/cxx/zoolib/ZAny.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.cpp 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZAny.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -19,215 +19,3 @@ ------------------------------------------------------------------------------------------------- */ #include "zoolib/ZAny.h" -#include "zoolib/ZString.h" - -using std::string; - -// ================================================================================================= -#pragma mark - -#pragma mark * ZAnyBase, copied/reworked from boost::any - -namespace ZooLib { - -ZAnyBase::ZAnyBase() -: content(0) - {} - -ZAnyBase::ZAnyBase(const ZAnyBase& other) -: content(other.content ? other.content->clone() : 0) - {} - -ZAnyBase::~ZAnyBase() - { delete content; } - -ZAnyBase& ZAnyBase::operator=(ZAnyBase rhs) - { - rhs.swap(*this); - return *this; - } - -ZAnyBase& ZAnyBase::swap(ZAnyBase& rhs) - { - std::swap(content, rhs.content); - return *this; - } - -bool ZAnyBase::empty() const - { return !content; } - -const std::type_info& ZAnyBase::type() const - { return content ? content->type() : typeid(void); } - -const void* ZAnyBase::voidstar() const - { return content ? content->voidstar() : nullptr; } - -void* ZAnyBase::voidstar() - { return content ? content->voidstar() : nullptr; } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - -#pragma mark * ZAny - -namespace ZooLib { - -ZAny::operator operator_bool_type() const - { return operator_bool_generator_type::translate(this->type() != typeid(void)); } - -void ZAny::Clear() - { - ZAny temp; - this->swap(temp); - } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - -#pragma mark * Coercion - -namespace ZooLib { - -ZQ<bool> sQCoerceBool(const ZAny& iAny) - { - if (const bool* pBool = iAny.PGet<bool>()) - return *pBool; - - if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) - return (0 != qInt64.Get()); - - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - return (0.0 != qDouble.Get()); - - if (const string* pString = iAny.PGet<string>()) - { - if (pString->empty()) - return false; - - if (ZQ<double> qDouble = ZString::sQDouble(*pString)) - return (0.0 != qDouble.Get()); - - if (ZQ<int64> qInt64 = ZString::sQInt64(*pString)) - return (0 != qInt64.Get()); - - if (ZString::sEquali(*pString, "t") || ZString::sEquali(*pString, "true")) - return true; - - if (ZString::sEquali(*pString, "f") || ZString::sEquali(*pString, "false")) - return false; - } - return null; - } - -bool sQCoerceBool(const ZAny& iAny, bool& oVal) - { - if (ZQ<bool> qBool = sQCoerceBool(iAny)) - { - oVal = qBool.Get(); - return true; - } - return false; - } - -bool sDCoerceBool(bool iDefault, const ZAny& iAny) - { - bool result; - if (sQCoerceBool(iAny, result)) - return result; - return iDefault; - } - -bool sCoerceBool(const ZAny& iAny) - { - bool result; - if (sQCoerceBool(iAny, result)) - return result; - return false; - } - -ZQ<int64> sQCoerceInt(const ZAny& iAny) - { - if (false) - {} - else if (const char* theVal = iAny.PGet<char>()) - return *theVal; - else if (const signed char* theVal = iAny.PGet<signed char>()) - return *theVal; - else if (const unsigned char* theVal = iAny.PGet<unsigned char>()) - return *theVal; - else if (const wchar_t* theVal = iAny.PGet<wchar_t>()) - return *theVal; - else if (const short* theVal = iAny.PGet<short>()) - return *theVal; - else if (const unsigned short* theVal = iAny.PGet<unsigned short>()) - return *theVal; - else if (const int* theVal = iAny.PGet<int>()) - return *theVal; - else if (const unsigned int* theVal = iAny.PGet<unsigned int>()) - return *theVal; - else if (const long* theVal = iAny.PGet<long>()) - return *theVal; - else if (const unsigned long* theVal = iAny.PGet<unsigned long>()) - return *theVal; - else if (const int64* theVal = iAny.PGet<int64>()) - return *theVal; - else if (const uint64* theVal = iAny.PGet<uint64>()) - return *theVal; - - return null; - } - -bool sQCoerceInt(const ZAny& iAny, int64& oVal) - { - if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) - { - oVal = qInt64.Get(); - return true; - } - return false; - } - -int64 sDCoerceInt(int64 iDefault, const ZAny& iAny) - { - if (ZQ<int64> qInt = sQCoerceInt(iAny)) - return qInt.Get(); - return iDefault; - } - -int64 sCoerceInt(const ZAny& iAny) - { return sDCoerceInt(0, iAny); } - -ZQ<double> sQCoerceReal(const ZAny& iAny) - { - if (false) - {} - else if (const float* theVal = iAny.PGet<float>()) - return *theVal; - else if (const double* theVal = iAny.PGet<double>()) - return *theVal; - - return null; - } - -bool sQCoerceReal(const ZAny& iAny, double& oVal) - { - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - { - oVal = qDouble.Get(); - return true; - } - return false; - } - -double sDCoerceReal(double iDefault, const ZAny& iAny) - { - if (ZQ<double> qDouble = sQCoerceReal(iAny)) - return qDouble.Get(); - return iDefault; - } - -double sCoerceReal(const ZAny& iAny) - { return sDCoerceReal(0.0, iAny); } - -} // namespace ZooLib Modified: trunk/zoolib/source/cxx/zoolib/ZAny.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZAny.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -21,190 +21,100 @@ #ifndef __ZAny__ #define __ZAny__ #include "zconfig.h" -#include "zoolib/ZCONFIG_SPI.h" -#include "zoolib/ZCompat_algorithm.h" // For swap +#include "zoolib/ZCompat_algorithm.h" // For std::swap #include "zoolib/ZCompat_operator_bool.h" #include "zoolib/ZQ.h" -#include "zoolib/ZStdInt.h" // For int64 #include <typeinfo> // ================================================================================================= #pragma mark - -#pragma mark * ZAnyBase, copied/reworked from boost::any - -// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. -// -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - #if ZCONFIG(Compiler, CodeWarrior) - #if __MWERKS__ <= 0x3206 - #define BOOST_NO_MEMBER_TEMPLATE_FRIENDS - #endif - #endif -#endif - -namespace ZooLib { - -class ZAnyBase - { -public: - ZAnyBase(); - ZAnyBase(const ZAnyBase& other); - ~ZAnyBase(); - ZAnyBase& operator=(ZAnyBase rhs); - - template<typename ValueType> - ZAnyBase(const ValueType & value) - : content(new holder<ValueType>(value)) - {} - - template<typename ValueType> - ZAnyBase& operator=(const ValueType & rhs) - { - ZAnyBase(rhs).swap(*this); - return *this; - } - - ZAnyBase& swap(ZAnyBase& rhs); - - bool empty() const; - const std::type_info & type() const; - const void* voidstar() const; - void* voidstar(); - -private: - class placeholder - { - public: - virtual ~placeholder() {} - - virtual const std::type_info& type() const = 0; - virtual placeholder* clone() const = 0; - virtual void* voidstar() = 0; - }; - - template<typename ValueType> - class holder : public placeholder - { - public: - holder(const ValueType& value) : held(value) {} - - virtual const std::type_info& type() const - { return typeid(ValueType); } - - virtual placeholder* clone() const - { return new holder(held); } - - virtual void* voidstar() - { return &held; } - - ValueType held; - - private: // intentionally left unimplemented - holder& operator=(const holder&); - }; - -#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS - public: // so ZAnyBaseCast can be non-friend -#else - private: - template<typename ValueType> - friend ValueType* ZAnyBaseCast(ZAnyBase*); - - template<typename ValueType> - friend const ValueType* ZAnyBaseCast(const ZAnyBase*); -#endif - - placeholder* content; - }; - -template<typename ValueType> -ValueType* ZAnyBaseCast(ZAnyBase* operand) - { - if (!operand || operand->type() != typeid(ValueType)) - return 0; - return &static_cast<ZAnyBase::holder<ValueType>*>(operand->content)->held; - } - -template<typename ValueType> -const ValueType* ZAnyBaseCast(const ZAnyBase* operand) - { - if (!operand || operand->type() != typeid(ValueType)) - return 0; - return &static_cast<ZAnyBase::holder<ValueType>*>(operand->content)->held; - } - -} // namespace ZooLib - -// ================================================================================================= -#pragma mark - #pragma mark * ZAny namespace ZooLib { -class ZAny : private ZAnyBase +class ZAny { public: ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZAny, operator_bool_generator_type, operator_bool_type); - operator operator_bool_type() const; + operator operator_bool_type() const + { return operator_bool_generator_type::translate(fRep); } - void swap(ZAny& rhs) - { ZAnyBase::swap((ZAnyBase&)rhs); } - - const std::type_info& Type() const - { return ZAnyBase::type(); } - - const void* VoidStar() const - { return ZAnyBase::voidstar(); } - - void* VoidStar() - { return ZAnyBase::voidstar(); } - ZAny() + : fRep(0) {} - ZAny(const ZAny& other) - : ZAnyBase((const ZAnyBase&)other) + ZAny(const ZAny& iOther) + : fRep(iOther.fRep ? iOther.fRep->Clone() : 0) {} - + ~ZAny() - {} + { delete fRep; } - ZAny& operator=(const ZAny& rhs) + ZAny& operator=(ZAny iOther) { - ZAnyBase::operator=((const ZAnyBase&)rhs); + this->swap(iOther); return *this; } template <class S> explicit ZAny(const S& iVal) - : ZAnyBase(iVal) + : fRep(new Rep_T<S>(iVal)) {} template <class S> ZAny& operator=(const S& iVal) { - ZAnyBase::operator=(iVal); + ZAny(iVal).swap(*this); return *this; } + void swap(ZAny& ioOther) + { std::swap(fRep, ioOther.fRep); } + + const std::type_info& Type() const + { + if (fRep) + return fRep->Type(); + return typeid(void); + } + + const void* VoidStar() const + { + if (fRep) + return fRep->VoidStar(); + return 0; + } + + void* VoidStar() + { + if (fRep) + return fRep->VoidStar(); + return 0; + } + // ZVal protocol, for use by ZVal derivatives - void Clear(); + void Clear() + { ZAny().swap(*this); } template <class S> S* PGet() - { return ZAnyBaseCast<S>(this); } + { + if (!fRep || fRep->Type() != typeid(S)) + return 0; + return &static_cast<Rep_T<S>*>(fRep)->fValue; + } template <class S> const S* PGet() const - { return ZAnyBaseCast<S>(this); } + { + if (!fRep || fRep->Type() != typeid(S)) + return 0; + return &static_cast<Rep_T<S>*>(fRep)->fValue; + } template <class S> ZQ<S> QGet() const @@ -232,40 +142,50 @@ template <class S> void Set(const S& iVal) - { ZAnyBase::operator=(iVal); } + { ZAny(iVal).swap(*this); } // Our protocol template <class S> bool Is() const { return this->PGet<S>(); } - }; -inline void swap(ZAny& a, ZAny& b) - { a.swap(b); } +private: + class RepBase + { + public: + virtual ~RepBase() {} -} // namespace ZooLib + virtual const std::type_info& Type() const = 0; + virtual RepBase* Clone() const = 0; + virtual void* VoidStar() = 0; + }; -// ================================================================================================= -#pragma mark - -#pragma mark * ZAny coercion + template<typename S> + class Rep_T : public RepBase + { + public: + Rep_T(const S& iValue) + : fValue(iValue) + {} -namespace ZooLib { + virtual const std::type_info& Type() const + { return typeid(S); } -ZQ<bool> sQCoerceBool(const ZAny& iAny); -bool sQCoerceBool(const ZAny& iAny, bool& oVal); -bool sDCoerceBool(bool iDefault, const ZAny& iAny); -bool sCoerceBool(const ZAny& iAny); + virtual RepBase* Clone() const + { return new Rep_T(fValue); } -ZQ<int64> sQCoerceInt(const ZAny& iAny); -bool sQCoerceInt(const ZAny& iAny, int64& oVal); -int64 sDCoerceInt(int64 iDefault, const ZAny& iAny); -int64 sCoerceInt(const ZAny& iAny); + virtual void* VoidStar() + { return &fValue; } -ZQ<double> sQCoerceReal(const ZAny& iAny); -bool sQCoerceReal(const ZAny& iAny, double& oVal); -double sDCoerceReal(double iDefault, const ZAny& iAny); -double sCoerceReal(const ZAny& iAny); + S fValue; + }; + RepBase* fRep; + }; + +inline void swap(ZAny& a, ZAny& b) + { a.swap(b); } + } // namespace ZooLib #endif // __ZAny__ Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Any.cpp 2010-12-29 16:29:53 UTC (rev 1835) @@ -0,0 +1,173 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2009 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#include "zoolib/ZUtil_Any.h" +#include "zoolib/ZString.h" + +using std::string; + +// ================================================================================================= +#pragma mark - +#pragma mark * Coercion + +namespace ZooLib { + +ZQ<bool> sQCoerceBool(const ZAny& iAny) + { + if (const bool* pBool = iAny.PGet<bool>()) + return *pBool; + + if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) + return (0 != qInt64.Get()); + + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + return (0.0 != qDouble.Get()); + + if (const string* pString = iAny.PGet<string>()) + { + if (pString->empty()) + return false; + + if (ZQ<double> qDouble = ZString::sQDouble(*pString)) + return (0.0 != qDouble.Get()); + + if (ZQ<int64> qInt64 = ZString::sQInt64(*pString)) + return (0 != qInt64.Get()); + + if (ZString::sEquali(*pString, "t") || ZString::sEquali(*pString, "true")) + return true; + + if (ZString::sEquali(*pString, "f") || ZString::sEquali(*pString, "false")) + return false; + } + return null; + } + +bool sQCoerceBool(const ZAny& iAny, bool& oVal) + { + if (ZQ<bool> qBool = sQCoerceBool(iAny)) + { + oVal = qBool.Get(); + return true; + } + return false; + } + +bool sDCoerceBool(bool iDefault, const ZAny& iAny) + { + bool result; + if (sQCoerceBool(iAny, result)) + return result; + return iDefault; + } + +bool sCoerceBool(const ZAny& iAny) + { + bool result; + if (sQCoerceBool(iAny, result)) + return result; + return false; + } + +ZQ<int64> sQCoerceInt(const ZAny& iAny) + { + if (false) + {} + else if (const char* theVal = iAny.PGet<char>()) + return *theVal; + else if (const signed char* theVal = iAny.PGet<signed char>()) + return *theVal; + else if (const unsigned char* theVal = iAny.PGet<unsigned char>()) + return *theVal; + else if (const wchar_t* theVal = iAny.PGet<wchar_t>()) + return *theVal; + else if (const short* theVal = iAny.PGet<short>()) + return *theVal; + else if (const unsigned short* theVal = iAny.PGet<unsigned short>()) + return *theVal; + else if (const int* theVal = iAny.PGet<int>()) + return *theVal; + else if (const unsigned int* theVal = iAny.PGet<unsigned int>()) + return *theVal; + else if (const long* theVal = iAny.PGet<long>()) + return *theVal; + else if (const unsigned long* theVal = iAny.PGet<unsigned long>()) + return *theVal; + else if (const int64* theVal = iAny.PGet<int64>()) + return *theVal; + else if (const uint64* theVal = iAny.PGet<uint64>()) + return *theVal; + + return null; + } + +bool sQCoerceInt(const ZAny& iAny, int64& oVal) + { + if (ZQ<int64> qInt64 = sQCoerceInt(iAny)) + { + oVal = qInt64.Get(); + return true; + } + return false; + } + +int64 sDCoerceInt(int64 iDefault, const ZAny& iAny) + { + if (ZQ<int64> qInt = sQCoerceInt(iAny)) + return qInt.Get(); + return iDefault; + } + +int64 sCoerceInt(const ZAny& iAny) + { return sDCoerceInt(0, iAny); } + +ZQ<double> sQCoerceReal(const ZAny& iAny) + { + if (false) + {} + else if (const float* theVal = iAny.PGet<float>()) + return *theVal; + else if (const double* theVal = iAny.PGet<double>()) + return *theVal; + + return null; + } + +bool sQCoerceReal(const ZAny& iAny, double& oVal) + { + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + { + oVal = qDouble.Get(); + return true; + } + return false; + } + +double sDCoerceReal(double iDefault, const ZAny& iAny) + { + if (ZQ<double> qDouble = sQCoerceReal(iAny)) + return qDouble.Get(); + return iDefault; + } + +double sCoerceReal(const ZAny& iAny) + { return sDCoerceReal(0.0, iAny); } + +} // namespace ZooLib Added: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h (rev 0) +++ trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -0,0 +1,51 @@ +/* ------------------------------------------------------------------------------------------------- +Copyright (c) 2010 Andrew Green +http://www.zoolib.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, +sublicense, and/or sell copies of the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES +OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------------------------- */ + +#ifndef __ZUtil_Any__ +#define __ZUtil_Any__ +#include "zconfig.h" + +#include "zoolib/ZAny.h" +#include "zoolib/ZStdInt.h" // For int64 + +// ================================================================================================= +#pragma mark - +#pragma mark * ZAny coercion + +namespace ZooLib { + +ZQ<bool> sQCoerceBool(const ZAny& iAny); +bool sQCoerceBool(const ZAny& iAny, bool& oVal); +bool sDCoerceBool(bool iDefault, const ZAny& iAny); +bool sCoerceBool(const ZAny& iAny); + +ZQ<int64> sQCoerceInt(const ZAny& iAny); +bool sQCoerceInt(const ZAny& iAny, int64& oVal); +int64 sDCoerceInt(int64 iDefault, const ZAny& iAny); +int64 sCoerceInt(const ZAny& iAny); + +ZQ<double> sQCoerceReal(const ZAny& iAny); +bool sQCoerceReal(const ZAny& iAny, double& oVal); +double sDCoerceReal(double iDefault, const ZAny& iAny); +double sCoerceReal(const ZAny& iAny); + +} // namespace ZooLib + +#endif // __ZUtil_Any__ Property changes on: trunk/zoolib/source/cxx/zoolib/ZUtil_Any.h ___________________________________________________________________ Added: svn:executable + * Modified: trunk/zoolib/source/cxx/zoolib/ZVal_Any.h =================================================================== --- trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-12-29 03:42:11 UTC (rev 1834) +++ trunk/zoolib/source/cxx/zoolib/ZVal_Any.h 2010-12-29 16:29:53 UTC (rev 1835) @@ -53,7 +53,7 @@ {} ZVal_Any(const ZVal_Any& iOther) - : ZAny(iOther.AsAny()) + : ZAny((const ZAny&)(iOther)) {} ~ZVal_Any() @@ -61,7 +61,7 @@ ZVal_Any& operator=(const ZVal_Any& iOther) { - ZAny::operator=(iOther.AsAny()); + ZAny::operator=((const ZAny&)(iOther)); return *this; } @@ -76,28 +76,48 @@ return *this; } +// Overload, so a null becomes a ZVal_Any() + ZVal_Any(const null_t&) + : ZAny() + {} + + ZVal_Any& operator=(const null_t&) + { + ZAny::Clear(); + return *this; + } + // Overload, so we can init/assign from a string constant - ZVal_Any(const char* iVal) + ZVal_Any(const UTF8* iVal) : ZAny(string8(iVal)) {} - ZVal_Any& operator=(const char* iVal) + ZVal_Any& operator=(const UTF8* iVal) { ZAny::operator=(string8(iVal)); return *this; } -// Overload, so a null becomes a ZVal_Any() - ZVal_Any(const null_t&) - : ZAny() + ZVal_Any(const UTF16* iVal) + : ZAny(string16(iVal)) {} - ZVal_Any& operator=(const null_t&) + ZVal_Any& operator=(const UTF16* iVal) { - ZAny::Clear(); + ZAny::operator=(string16(iVal)); return *this; } + ZVal_Any(const UTF32* iVal) + : ZAny(string32(iVal)) + {} + + ZVal_Any& operator=(const UTF32* iVal) + { + ZAny::operator=(string32(iVal)); + return *this; + } + // Overload, as ZAny's templated constructor is explicit. template <class S> ZVal_Any(const S& iVal) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |