Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ObjectsSet.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/set>
9#include <core/stringApi.hpp>
10
12
13namespace core {
14
15template<class ValueType >
16struct stringApi < ext::set < ValueType > > {
17 static ext::set < ValueType > parse ( ext::istream & input );
18 static bool first ( ext::istream & input );
19 static void compose ( ext::ostream & output, const ext::set < ValueType > & container );
20};
21
22template<class ValueType >
24 container::ContainerFromStringLexer::Token token = container::ContainerFromStringLexer::next ( input );
26 throw exception::CommonException("Expected SET_BEGIN token.");
27
29
30 ext::set<ValueType> objectsSet;
33 ValueType innerObject = stringApi < ValueType >::parse ( input );
34 objectsSet.insert ( std::move ( innerObject ) );
35
38 break;
39
41 }
42
44 throw exception::CommonException("Expected SET_END token.");
45 return objectsSet;
46}
47
48template<class ValueType >
50 container::ContainerFromStringLexer::Token token = container::ContainerFromStringLexer::next ( input );
53 return res;
54}
55
56template<class ValueType >
58 output << '{';
59 bool first = true;
60 for(const ValueType & innerObject : container) {
61 if(!first)
62 output << ", ";
63 else
64 first = false;
65 stringApi < ValueType >::compose ( output, innerObject );
66 }
67 output << '}';
68}
69
70} /* namespace core */
71
static Token next(ext::istream &input)
Definition: ContainerFromStringLexer.cpp:10
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
static void putback(ext::istream &input, const Token &token)
Definition: lexer.hpp:61
Definition: istream.h:32
Definition: ostream.h:14
Definition: set.hpp:44
return res
Definition: MinimizeByPartitioning.h:145
Definition: ContainerFromStringLexer.cpp:8
Definition: normalize.hpp:10
Definition: sigHandler.cpp:20
Definition: stringApi.hpp:26