Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ObjectsVector.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/vector>
9#include <core/stringApi.hpp>
10
12
13namespace core {
14
15template<class ValueType >
16struct stringApi < ext::vector < ValueType > > {
17 static ext::vector < ValueType > parse ( ext::istream & input );
18 static bool first ( ext::istream & input );
19 static void compose ( ext::ostream & output, const ext::vector < ValueType > & container );
20};
21
22template<class ValueType >
24 container::ContainerFromStringLexer::Token token = container::ContainerFromStringLexer::next ( input );
26 throw exception::CommonException("Expected VECTOR_BEGIN token.");
27
29
30 ext::vector<ValueType> objectsVector;
33 ValueType innerObject = stringApi < ValueType >::parse ( input );
34 objectsVector.push_back ( std::move ( innerObject ) );
35
38 break;
39
41 }
42
44 throw exception::CommonException("Expected VECTOR_END token.");
45 return objectsVector;
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
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
return res
Definition: MinimizeByPartitioning.h:145
Definition: ContainerFromStringLexer.cpp:8
Definition: normalize.hpp:10
Definition: sigHandler.cpp:20
Definition: stringApi.hpp:26