diff --git a/alib2str/src/container/string/ObjectsVariant.h b/alib2str/src/container/string/ObjectsVariant.h new file mode 100644 index 0000000000000000000000000000000000000000..4ded70bfb8f23b681878f66d4dc6f46f5216f604 --- /dev/null +++ b/alib2str/src/container/string/ObjectsVariant.h @@ -0,0 +1,60 @@ +/* + * ObjectsVariant.h + * + * Created on: Sep 27, 2017 + * Author: Jan Travnicek + */ + +#ifndef _STRING_OBJECTS_VARIANT_H_ +#define _STRING_OBJECTS_VARIANT_H_ + +#include <alib/variant> +#include <core/stringApi.hpp> + +#include <container/ContainerFromStringLexer.h> + +namespace core { + +template < class ... Types > +struct stringApi < ext::variant < Types ... > > { + static ext::variant < Types ... > parse ( std::istream & input ); + static bool first ( std::istream & input ); + static void compose ( std::ostream & output, const ext::variant < Types ... > & container ); + +private: + class VariantStringApiCallback { + std::ostream & m_out; + + public: + VariantStringApiCallback ( std::ostream & out ) : m_out ( out ) { + } + + template < class ValueType > + void operator ( ) ( const ValueType & value ) { + stringApi < ValueType >::compose ( m_out, value ); + } + + void operator ( ) ( ) { + m_out << "void"; + } + }; +}; + +template < class ... Types > +ext::variant < Types ... > stringApi < ext::variant < Types ... > >::parse ( std::istream & /* input */ ) { + throw exception::CommonException("parsing BarSymbol from string not implemented"); +} + +template < class ... Types > +bool stringApi < ext::variant < Types ... > >::first ( std::istream & /* input */ ) { + return false; +} + +template < class ... Types > +void stringApi < ext::variant < Types ... > >::compose ( std::ostream & output, const ext::variant < Types ... > & container ) { + container.template call < void > ( VariantStringApiCallback ( output ) ); +} + +} /* namespace core */ + +#endif /* _STRING_OBJECTS_VARIANT_H_ */