Skip to content
Snippets Groups Projects
Commit f53c4784 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

normalization of common types

parent 20e3ee1e
No related branches found
No related tags found
No related merge requests found
Showing
with 156 additions and 0 deletions
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -59,6 +60,18 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::deque < ElementType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::deque < alib::Object > normalizeRaw ( std::deque < ElementType > && source ) {
std::deque < alib::Object > res;
for ( ElementType & element : source ) {
res.push_back ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( element ) ) ) );
}
return res;
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsDeque < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class ElementType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -59,6 +60,18 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::list < ElementType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::list < alib::Object > normalizeRaw ( std::list < ElementType > && source ) {
std::list < alib::Object > res;
for ( ElementType & element : source ) {
res.push_back ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( element ) ) ) );
}
return res;
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsList < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class ElementType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
#include "ObjectsPair.h"
 
......@@ -61,6 +62,18 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::map < KeyType, ValueType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::map < alib::Object, alib::Object > normalizeRaw ( std::map < KeyType, ValueType > && source ) {
std::map < alib::Object, alib::Object > res;
for ( std::pair < KeyType, ValueType > && element : std::make_moveable_map ( source ) ) {
res.insert ( ObjectsPair < KeyType, ValueType >::normalizeRaw ( std::move ( element ) ) );
}
return res;
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsMap < alib::Object, alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class KeyType, class ValueType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -59,6 +60,14 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::pair < FirstType, SecondType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::pair < alib::Object, alib::Object > normalizeRaw ( std::pair < FirstType, SecondType > && source ) {
return std::make_pair ( alib::Object ( alib::AnyObject < FirstType > ( std::move ( source.first ) ) ), alib::Object ( alib::AnyObject < SecondType > ( std::move ( source.second ) ) ) );
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsPair < alib::Object, alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class FirstType, class SecondType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -59,6 +60,18 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::set < ElementType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::set < alib::Object > normalizeRaw ( std::set < ElementType > && source ) {
std::set < alib::Object > res;
for ( ElementType && element : std::make_moveable_set ( source ) ) {
res.insert ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( element ) ) ) );
}
return res;
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsSet < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class ElementType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -58,6 +59,20 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::tree < ElementType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
std::tree < alib::Object > normalizeRaw ( std::tree < ElementType > && node ) {
std::vector < std::tree < alib::Object > > children;
for ( std::tree < ElementType > & child : node.getChildren ( ) ) {
children.push_back ( normalizeRaw ( std::move ( child ) ) );
}
return std::tree < alib::Object > ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( node.getData ( ) ) ) ), std::move ( children ) );
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsTree < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class ElementType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -60,6 +61,20 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::trie < KeyType, ValueType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
std::trie < alib::Object, alib::Object > normalizeRaw ( std::trie < KeyType, ValueType > && node ) {
std::map < alib::Object, std::trie < alib::Object, alib::Object > > children;
for ( std::pair < KeyType, std::trie < KeyType, ValueType > > && child : std::make_moveable_map ( node.getChildren ( ) ) ) {
children.insert ( std::make_pair ( alib::Object ( alib::AnyObject < KeyType > ( std::move ( child.first ) ) ), normalizeRaw ( std::move ( child.second ) ) ) );
}
return std::trie < alib::Object, alib::Object > ( alib::Object ( alib::AnyObject < ValueType > ( std::move ( node.getData ( ) ) ) ), std::move ( children ) );
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsTrie < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class KeyType, class ValueType >
......
......@@ -17,6 +17,7 @@
 
#include <core/xmlApi.hpp>
#include "../object/UniqueObject.h"
#include <object/AnyObject.h>
 
namespace container {
 
......@@ -59,6 +60,18 @@ public:
static void compose ( std::deque < sax::Token > & out, const std::vector < ElementType > & input );
 
virtual alib::ObjectBase * inc ( ) &&;
static std::vector < alib::Object > normalizeRaw ( std::vector < ElementType > && source ) {
std::vector < alib::Object > res;
for ( ElementType & element : source ) {
res.push_back ( alib::Object ( alib::AnyObject < ElementType > ( std::move ( element ) ) ) );
}
return res;
}
virtual ObjectBase * normalize ( ) && {
return new ObjectsVector < alib::Object > ( normalizeRaw ( std::move ( * this ) ) );
}
};
 
template < class ElementType >
......
......@@ -81,6 +81,10 @@ public:
void compose ( std::deque < sax::Token > & out ) const;
 
virtual alib::ObjectBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace exception */
......
......@@ -53,6 +53,10 @@ public:
void compose ( std::deque < sax::Token > & out ) const;
 
virtual ObjectBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
template < class T >
......
......@@ -64,6 +64,10 @@ public:
void compose ( std::deque < sax::Token > & out ) const;
 
virtual ObjectBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace alib */
......
......@@ -54,6 +54,10 @@ public:
void compose ( std::deque < sax::Token > & out ) const;
 
virtual ObjectBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace alib */
......
......@@ -68,6 +68,10 @@ public:
static void compose ( std::deque < sax::Token > & out, bool primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -68,6 +68,10 @@ public:
static void compose ( std::deque < sax::Token > & out, char primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -68,6 +68,10 @@ public:
static void compose ( std::deque < sax::Token > & out, int primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -69,6 +69,10 @@ public:
static void compose ( std::deque < sax::Token > & out, std::string primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -70,6 +70,10 @@ public:
static void compose ( std::deque < sax::Token > & out, unsigned primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -68,6 +68,10 @@ public:
static void compose ( std::deque < sax::Token > & out, unsigned long primitive );
 
virtual PrimitiveBase * inc ( ) &&;
virtual ObjectBase * normalize ( ) && {
return this;
}
};
 
} /* namespace primitive */
......
......@@ -67,6 +67,10 @@ public:
return m_data;
}
 
virtual TmpBase * normalize ( ) && {
return this;
}
};
 
class Tmp2 : public TmpBase {
......@@ -119,6 +123,10 @@ public:
return m_data;
}
 
virtual TmpBase * normalize ( ) && {
return this;
}
};
 
class Tmp3 : public TmpBase {
......@@ -174,6 +182,10 @@ public:
return m_data;
}
 
virtual TmpBase * normalize ( ) && {
return this;
}
};
 
// -------------------------------------------------------------------------------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment