diff --git a/alib2common/src/container/ContainerFeatures.h b/alib2common/src/container/ContainerFeatures.h index fffa8346b74159aaf42d67772f587b0c68482ef1..7d25fa118fd21a8f4bff8df4c6c45da304112026 100644 --- a/alib2common/src/container/ContainerFeatures.h +++ b/alib2common/src/container/ContainerFeatures.h @@ -28,7 +28,7 @@ template < class ElementType = alib::Object > class ObjectsList; template < class KeyType = alib::Object, class ValueType = alib::Object > class ObjectsMap; -template < class KeyType = alib::Object, class ValueType = alib::Object > +template < class FirstType = alib::Object, class SecondType = alib::Object > class ObjectsPair; template < class ElementType = alib::Object > class ObjectsSet; diff --git a/alib2common/src/container/ObjectsPair.h b/alib2common/src/container/ObjectsPair.h index 13cb8a5e20e77b6546497309022892a36c706845..df35115e50e1aa59749741120fb87e7cda5633f5 100644 --- a/alib2common/src/container/ObjectsPair.h +++ b/alib2common/src/container/ObjectsPair.h @@ -24,11 +24,11 @@ namespace container { * Basic container from which are derived all other containers. * Contains reason why the container occured. */ -template < class KeyType, class ValueType > -class ObjectsPair : public std::pair < KeyType, ValueType >, public ContainerBase { +template < class FirstType, class SecondType > +class ObjectsPair : public std::pair < FirstType, SecondType >, public ContainerBase { public: - explicit ObjectsPair ( alib::Object first, alib::Object second ); - explicit ObjectsPair ( std::pair < KeyType, ValueType > ); + explicit ObjectsPair ( FirstType firstObject, SecondType secondObject ); + explicit ObjectsPair ( std::pair < FirstType, SecondType > ); virtual ContainerBase * clone ( ) const; @@ -53,86 +53,86 @@ public: } static ObjectsPair parse ( std::deque < sax::Token >::iterator & input ); - static std::pair < KeyType, ValueType > parseRaw ( std::deque < sax::Token >::iterator & input ); + static std::pair < FirstType, SecondType > parseRaw ( std::deque < sax::Token >::iterator & input ); void compose ( std::deque < sax::Token > & out ) const; - static void compose ( std::deque < sax::Token > & out, const std::pair < KeyType, ValueType > & input ); + static void compose ( std::deque < sax::Token > & out, const std::pair < FirstType, SecondType > & input ); virtual alib::ObjectBase * inc ( ) &&; }; -template < class KeyType, class ValueType > -ObjectsPair < KeyType, ValueType >::ObjectsPair(std::pair<KeyType, ValueType> raw) : std::pair<KeyType, ValueType>(std::move(raw)) { +template < class FirstType, class SecondType > +ObjectsPair < FirstType, SecondType >::ObjectsPair(std::pair<FirstType, SecondType> raw) : std::pair<FirstType, SecondType>(std::move(raw)) { } -template < class KeyType, class ValueType > -ObjectsPair < KeyType, ValueType >::ObjectsPair(alib::Object first, alib::Object second) : std::pair<KeyType, ValueType>(std::move(first), std::move(second)) { +template < class FirstType, class SecondType > +ObjectsPair < FirstType, SecondType >::ObjectsPair(FirstType firstObject, SecondType secondObject) : std::pair<FirstType, SecondType>(std::move(firstObject), std::move(secondObject)) { } -template < class KeyType, class ValueType > -ContainerBase* ObjectsPair < KeyType, ValueType >::clone() const { +template < class FirstType, class SecondType > +ContainerBase* ObjectsPair < FirstType, SecondType >::clone() const { return new ObjectsPair(*this); } -template < class KeyType, class ValueType > -ContainerBase* ObjectsPair < KeyType, ValueType >::plunder() && { +template < class FirstType, class SecondType > +ContainerBase* ObjectsPair < FirstType, SecondType >::plunder() && { return new ObjectsPair(std::move(*this)); } -template < class KeyType, class ValueType > -int ObjectsPair < KeyType, ValueType >::compare(const ObjectsPair& other) const { - std::compare<std::pair<KeyType, ValueType>> comp; - return comp(static_cast<const std::pair<KeyType, ValueType>>(*this), static_cast<const std::pair<KeyType, ValueType>>(other)); +template < class FirstType, class SecondType > +int ObjectsPair < FirstType, SecondType >::compare(const ObjectsPair& other) const { + std::compare<std::pair<FirstType, SecondType>> comp; + return comp(static_cast<const std::pair<FirstType, SecondType>>(*this), static_cast<const std::pair<FirstType, SecondType>>(other)); } -template < class KeyType, class ValueType > -void ObjectsPair < KeyType, ValueType >::operator>>(std::ostream& os) const { - os << "(ObjectsPair " << static_cast<const std::pair<KeyType, ValueType>>(*this) << ")"; +template < class FirstType, class SecondType > +void ObjectsPair < FirstType, SecondType >::operator>>(std::ostream& os) const { + os << "(ObjectsPair " << static_cast<const std::pair<FirstType, SecondType>>(*this) << ")"; } -template < class KeyType, class ValueType > -ObjectsPair < KeyType, ValueType >::operator std::string() const { +template < class FirstType, class SecondType > +ObjectsPair < FirstType, SecondType >::operator std::string() const { std::stringstream ss; ss << *this; return std::move(ss).str(); } -template < class KeyType, class ValueType > -ObjectsPair < KeyType, ValueType > ObjectsPair < KeyType, ValueType >::parse(std::deque<sax::Token>::iterator& input) { - return ObjectsPair < KeyType, ValueType > ( parseRaw ( input ) ); +template < class FirstType, class SecondType > +ObjectsPair < FirstType, SecondType > ObjectsPair < FirstType, SecondType >::parse(std::deque<sax::Token>::iterator& input) { + return ObjectsPair < FirstType, SecondType > ( parseRaw ( input ) ); } -template < class KeyType, class ValueType > -void ObjectsPair < KeyType, ValueType >::compose(std::deque<sax::Token>& out) const { +template < class FirstType, class SecondType > +void ObjectsPair < FirstType, SecondType >::compose(std::deque<sax::Token>& out) const { compose(out, *this); } -template < class KeyType, class ValueType > -std::pair < KeyType, ValueType > ObjectsPair < KeyType, ValueType >::parseRaw ( std::deque < sax::Token >::iterator & input ) { +template < class FirstType, class SecondType > +std::pair < FirstType, SecondType > ObjectsPair < FirstType, SecondType >::parseRaw ( std::deque < sax::Token >::iterator & input ) { sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, ObjectsPair::getXmlTagName() ); - KeyType first = alib::xmlApi < KeyType >::parse ( input ); - ValueType second = alib::xmlApi < ValueType >::parse ( input ); + FirstType first = alib::xmlApi < FirstType >::parse ( input ); + SecondType second = alib::xmlApi < SecondType >::parse ( input ); sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, ObjectsPair::getXmlTagName() ); return std::make_pair ( std::move ( first ), std::move ( second ) ); } -template < class KeyType, class ValueType > -void ObjectsPair < KeyType, ValueType >::compose ( std::deque < sax::Token > & out, const std::pair < KeyType, ValueType > & input ) { +template < class FirstType, class SecondType > +void ObjectsPair < FirstType, SecondType >::compose ( std::deque < sax::Token > & out, const std::pair < FirstType, SecondType > & input ) { out.emplace_back ( ObjectsPair::getXmlTagName(), sax::Token::TokenType::START_ELEMENT ); - alib::xmlApi < KeyType >::compose ( out, input.first ); - alib::xmlApi < ValueType >::compose ( out, input.second ); + alib::xmlApi < FirstType >::compose ( out, input.first ); + alib::xmlApi < SecondType >::compose ( out, input.second ); out.emplace_back ( ObjectsPair::getXmlTagName(), sax::Token::TokenType::END_ELEMENT ); } -template < class KeyType, class ValueType > -alib::ObjectBase* ObjectsPair < KeyType, ValueType >::inc() && { +template < class FirstType, class SecondType > +alib::ObjectBase* ObjectsPair < FirstType, SecondType >::inc() && { return new alib::UniqueObject(alib::Object(std::move(*this)), primitive::Integer(0)); }