// // NamedTuple.h // // Library: Foundation // Package: Core // Module: NamedTuple // // Definition of the NamedTuple class. // // Copyright (c) 2007, Applied Informatics Software Engineering GmbH. // and Contributors. // // SPDX-License-Identifier: BSL-1.0 // #ifndef Foundation_NamedTuple_INCLUDED #define Foundation_NamedTuple_INCLUDED #include "Poco/DynamicAny.h" #include "Poco/Format.h" #include "Poco/Foundation.h" #include "Poco/SharedPtr.h" #include "Poco/Tuple.h" #include "Poco/TypeList.h" namespace Poco { template < class T0, class T1 = NullTypeList, class T2 = NullTypeList, class T3 = NullTypeList, class T4 = NullTypeList, class T5 = NullTypeList, class T6 = NullTypeList, class T7 = NullTypeList, class T8 = NullTypeList, class T9 = NullTypeList, class T10 = NullTypeList, class T11 = NullTypeList, class T12 = NullTypeList, class T13 = NullTypeList, class T14 = NullTypeList, class T15 = NullTypeList, class T16 = NullTypeList, class T17 = NullTypeList, class T18 = NullTypeList, class T19 = NullTypeList> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), typename TypeWrapper::CONSTTYPE & t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), typename TypeWrapper::CONSTTYPE & t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), const std::string & n15 = "P", typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), const std::string & n16 = "Q", typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), const std::string & n17 = "R", typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), const std::string & n18 = "S", typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), const std::string & n19 = "T", typename TypeWrapper::CONSTTYPE & t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); case 15: return TupleType::template get<15>(); case 16: return TupleType::template get<16>(); case 17: return TupleType::template get<17>(); case 18: return TupleType::template get<18>(); case 19: return TupleType::template get<19>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O", const std::string & n15 = "P", const std::string & n16 = "Q", const std::string & n17 = "R", const std::string & n18 = "S", const std::string & n19 = "T") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); _pNames->push_back(n15); _pNames->push_back(n16); _pNames->push_back(n17); _pNames->push_back(n18); _pNames->push_back(n19); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16, class T17, class T18> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), const std::string & n15 = "P", typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), const std::string & n16 = "Q", typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), const std::string & n17 = "R", typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), const std::string & n18 = "S", typename TypeWrapper::CONSTTYPE & t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); case 15: return TupleType::template get<15>(); case 16: return TupleType::template get<16>(); case 17: return TupleType::template get<17>(); case 18: return TupleType::template get<18>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O", const std::string & n15 = "P", const std::string & n16 = "Q", const std::string & n17 = "R", const std::string & n18 = "S") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); _pNames->push_back(n15); _pNames->push_back(n16); _pNames->push_back(n17); _pNames->push_back(n18); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16, class T17> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), const std::string & n15 = "P", typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), const std::string & n16 = "Q", typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), const std::string & n17 = "R", typename TypeWrapper::CONSTTYPE & t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); case 15: return TupleType::template get<15>(); case 16: return TupleType::template get<16>(); case 17: return TupleType::template get<17>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O", const std::string & n15 = "P", const std::string & n16 = "Q", const std::string & n17 = "R") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); _pNames->push_back(n15); _pNames->push_back(n16); _pNames->push_back(n17); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), const std::string & n15 = "P", typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), const std::string & n16 = "Q", typename TypeWrapper::CONSTTYPE & t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); case 15: return TupleType::template get<15>(); case 16: return TupleType::template get<16>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O", const std::string & n15 = "P", const std::string & n16 = "Q") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); _pNames->push_back(n15); _pNames->push_back(n16); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), const std::string & n15 = "P", typename TypeWrapper::CONSTTYPE & t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); case 15: return TupleType::template get<15>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O", const std::string & n15 = "P") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); _pNames->push_back(n15); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), const std::string & n14 = "O", typename TypeWrapper::CONSTTYPE & t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); case 14: return TupleType::template get<14>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N", const std::string & n14 = "O") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); _pNames->push_back(n14); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), const std::string & n13 = "N", typename TypeWrapper::CONSTTYPE & t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); case 13: return TupleType::template get<13>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M", const std::string & n13 = "N") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); _pNames->push_back(n13); } } NameVecPtr _pNames; }; template < class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12> struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), const std::string & n12 = "M", typename TypeWrapper::CONSTTYPE & t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); case 12: return TupleType::template get<12>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L", const std::string & n12 = "M") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); _pNames->push_back(n12); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), const std::string & n11 = "L", typename TypeWrapper::CONSTTYPE & t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); case 11: return TupleType::template get<11>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K", const std::string & n11 = "L") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); _pNames->push_back(n11); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), const std::string & n10 = "K", typename TypeWrapper::CONSTTYPE & t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); case 10: return TupleType::template get<10>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J", const std::string & n10 = "K") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); _pNames->push_back(n10); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), const std::string & n9 = "J", typename TypeWrapper::CONSTTYPE & t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8, n9); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); case 9: return TupleType::template get<9>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I", const std::string & n9 = "J") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); _pNames->push_back(n9); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), const std::string & n8 = "I", typename TypeWrapper::CONSTTYPE & t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7, t8), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7, n8); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); case 8: return TupleType::template get<8>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H", const std::string & n8 = "I") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); _pNames->push_back(n8); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), const std::string & n7 = "H", typename TypeWrapper::CONSTTYPE & t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)) : TupleType(t0, t1, t2, t3, t4, t5, t6, t7), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6, n7); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); case 7: return TupleType::template get<7>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G", const std::string & n7 = "H") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); _pNames->push_back(n7); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)) : TupleType(t0, t1, t2, t3, t4, t5, t6), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)) : TupleType(t0, t1, t2, t3, t4, t5, t6) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), const std::string & n6 = "G", typename TypeWrapper::CONSTTYPE & t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)) : TupleType(t0, t1, t2, t3, t4, t5, t6), _pNames(0) { init(n0, n1, n2, n3, n4, n5, n6); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); case 6: return TupleType::template get<6>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F", const std::string & n6 = "G") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); _pNames->push_back(n6); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)) : TupleType(t0, t1, t2, t3, t4, t5), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)) : TupleType(t0, t1, t2, t3, t4, t5) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), const std::string & n5 = "F", typename TypeWrapper::CONSTTYPE & t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)) : TupleType(t0, t1, t2, t3, t4, t5), _pNames(0) { init(n0, n1, n2, n3, n4, n5); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); case 5: return TupleType::template get<5>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E", const std::string & n5 = "F") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); _pNames->push_back(n5); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)) : TupleType(t0, t1, t2, t3, t4), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)) : TupleType(t0, t1, t2, t3, t4) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), const std::string & n4 = "E", typename TypeWrapper::CONSTTYPE & t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)) : TupleType(t0, t1, t2, t3, t4), _pNames(0) { init(n0, n1, n2, n3, n4); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); case 4: return TupleType::template get<4>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init( const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D", const std::string & n4 = "E") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); _pNames->push_back(n4); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)) : TupleType(t0, t1, t2, t3), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)) : TupleType(t0, t1, t2, t3) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), const std::string & n3 = "D", typename TypeWrapper::CONSTTYPE & t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)) : TupleType(t0, t1, t2, t3), _pNames(0) { init(n0, n1, n2, n3); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); case 3: return TupleType::template get<3>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init(const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C", const std::string & n3 = "D") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); _pNames->push_back(n3); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)) : TupleType(t0, t1, t2), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)) : TupleType(t0, t1, t2) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), const std::string & n2 = "C", typename TypeWrapper::CONSTTYPE & t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)) : TupleType(t0, t1, t2), _pNames(0) { init(n0, n1, n2); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); case 2: return TupleType::template get<2>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init(const std::string & n0 = "A", const std::string & n1 = "B", const std::string & n2 = "C") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); _pNames->push_back(n2); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple(typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)) : TupleType(t0, t1), _pNames(0) { init(); } NamedTuple( const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0, typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)) : TupleType(t0, t1) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple( const std::string & n0, typename TypeWrapper::CONSTTYPE & t0, const std::string & n1 = "B", typename TypeWrapper::CONSTTYPE & t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)) : TupleType(t0, t1), _pNames(0) { init(n0, n1); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); case 1: return TupleType::template get<1>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init(const std::string & n0 = "A", const std::string & n1 = "B") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); _pNames->push_back(n1); } } NameVecPtr _pNames; }; template struct NamedTuple : public Tuple { typedef Tuple TupleType; typedef typename Tuple::Type Type; typedef std::vector NameVec; typedef SharedPtr NameVecPtr; NamedTuple() : _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple(typename TypeWrapper::CONSTTYPE & t0) : TupleType(t0), _pNames(0) { init(); } NamedTuple(const NameVecPtr & rNames, typename TypeWrapper::CONSTTYPE & t0) : TupleType(t0) { if (rNames->size() != TupleType::length) throw InvalidArgumentException("Wrong names vector length."); _pNames = rNames; } NamedTuple(const std::string & n0, typename TypeWrapper::CONSTTYPE & t0) : TupleType(t0), _pNames(0) { init(n0); } const DynamicAny get(const std::string & name) const { NameVec::const_iterator it = _pNames->begin(); NameVec::const_iterator itEnd = _pNames->end(); for (std::size_t counter = 0; it != itEnd; ++it, ++counter) { if (name == *it) { switch (counter) { case 0: return TupleType::template get<0>(); default: throw RangeException(); } } } throw NotFoundException("Name not found: " + name); } const DynamicAny operator[](const std::string & name) const { return get(name); } template typename TypeGetter::ConstHeadType & get() const { return TupleType::template get(); } template typename TypeGetter::HeadType & get() { return TupleType::template get(); } template void set(typename TypeGetter::ConstHeadType & val) { return TupleType::template set(val); } const NameVecPtr & names() { return _pNames; } void setName(std::size_t index, const std::string & name) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); (*_pNames)[index] = name; } const std::string & getName(std::size_t index) { if (index >= _pNames->size()) throw InvalidArgumentException(format("Invalid index: %z", index)); return (*_pNames)[index]; } bool operator==(const NamedTuple & other) const { return TupleType(*this) == TupleType(other) && _pNames == other._pNames; } bool operator!=(const NamedTuple & other) const { return !(*this == other); } bool operator<(const NamedTuple & other) const { TupleType th(*this); TupleType oth(other); return (th < oth && _pNames == other._pNames) || (th == oth && _pNames < other._pNames) || (th < oth && _pNames < other._pNames); } private: void init(const std::string & n0 = "A") { if (!_pNames) { _pNames = new NameVec; _pNames->push_back(n0); } } NameVecPtr _pNames; }; } // namespace Poco #endif // Foundation_Tuple_INCLUDED