Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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_ */