Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ObjectsOptional.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <alib/optional>
10#include <core/xmlApi.hpp>
11
12namespace core {
13
14template < typename T >
15struct xmlApi < std::optional < T > > {
16 static std::optional < T > parse ( ext::deque < sax::Token >::iterator & input );
17 static bool first ( const ext::deque < sax::Token >::const_iterator & input );
18 static std::string xmlTagName ( );
19 static void compose ( ext::deque < sax::Token > & output, const std::optional < T > & input );
20};
21
22template < typename T >
23std::optional < T > xmlApi < std::optional < T > >::parse ( ext::deque < sax::Token >::iterator & input ) {
25 ++input;
27 return std::optional < T > ( );
28 } else {
29 return std::optional < T > ( core::xmlApi < T >::parse ( input ) );
30 }
31}
32
33template < typename T >
36}
37
38template < typename T >
39std::string xmlApi < std::optional < T > >::xmlTagName ( ) {
40 throw exception::CommonException ( "Optional does not have xmlTagName." );
41}
42
43template < typename T >
44void xmlApi < std::optional < T > >::compose ( ext::deque < sax::Token > & output, const std::optional < T > & input ) {
45 if ( ! input ) {
46 output.emplace_back("void", sax::Token::TokenType::START_ELEMENT);
47 output.emplace_back("void", sax::Token::TokenType::END_ELEMENT);
48 } else {
49 core::xmlApi < T >::compose ( output, input.value ( ) );
50 }
51}
52
53} /* namespace core */
54
Basic exception from which all other exceptions are derived.
Definition: CommonException.h:21
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
static void popToken(ext::deque< Token >::iterator &input, Token::TokenType type, const std::string &data)
Definition: FromXMLParserHelper.cpp:39
static bool isToken(ext::deque< Token >::const_iterator input, Token::TokenType type, const std::string &data)
Definition: FromXMLParserHelper.cpp:29
Definition: normalize.hpp:10
Definition: FordFulkerson.hpp:16
Definition: xmlApi.hpp:27