Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
UnrankedPattern.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
28#include "../common/TreeFromXMLParser.h"
29#include "../common/TreeToXMLComposer.h"
30
31namespace core {
32
33template < class SymbolType >
34struct xmlApi < tree::UnrankedPattern < SymbolType > > {
42 static std::string xmlTagName() {
43 return "UnrankedPattern";
44 }
45
53 static bool first ( const ext::deque < sax::Token >::const_iterator & input ) {
55 }
56
65
72 static void compose ( ext::deque < sax::Token > & out, const tree::UnrankedPattern < SymbolType > & pattern );
73};
74
75template < class SymbolType >
78 SymbolType subtreeWildcardSymbol = tree::TreeFromXMLParser::parseWildcardSymbol < SymbolType > ( input );
79 SymbolType subtreeGapSymbol = tree::TreeFromXMLParser::parseGapSymbol < SymbolType > ( input );
80 ext::set < SymbolType > rankedAlphabet = tree::TreeFromXMLParser::parseAlphabet < SymbolType > ( input );
81 ext::tree < SymbolType > root = tree::TreeFromXMLParser::parseTreeContent < SymbolType > ( input );
82 tree::UnrankedPattern < SymbolType > tree ( std::move ( subtreeWildcardSymbol ), std::move ( subtreeGapSymbol ), std::move ( rankedAlphabet ), std::move ( root ) );
83
85 return tree;
86}
87
88template < class SymbolType >
90 out.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT );
95 out.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
96}
97
98} /* namespace core */
99
Class extending the deque class from the standard library. Original reason is to allow printing of th...
Definition: deque.hpp:44
Definition: set.hpp:44
Class introducing a tree with interface trying to be close to the interface of standard library conta...
Definition: tree.hpp:52
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
static void composeAlphabet(ext::deque< sax::Token > &out, const ext::set< SymbolType > &symbols)
Definition: TreeToXMLComposer.h:86
static void composeSubtreeGap(ext::deque< sax::Token > &out, const SymbolType &symbol)
Definition: TreeToXMLComposer.h:79
static void composeContent(ext::deque< sax::Token > &out, const ext::vector< SymbolType > &content)
Definition: TreeToXMLComposer.h:96
static void composeSubtreeWildcard(ext::deque< sax::Token > &out, const SymbolType &symbol)
Definition: TreeToXMLComposer.h:72
Tree pattern represented in its natural representation. The representation is so called unranked,...
Definition: UnrankedPattern.h:73
const ext::set< SymbolType > & getAlphabet() const &
Definition: UnrankedPattern.h:120
const ext::tree< SymbolType > & getContent() const &
Definition: UnrankedPattern.h:263
const SymbolType & getSubtreeGap() const &
Definition: UnrankedPattern.h:165
const SymbolType & getSubtreeWildcard() const &
Definition: UnrankedPattern.h:147
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
Definition: normalize.hpp:10
Definition: BackwardOccurrenceTest.h:17
static bool first(const ext::deque< sax::Token >::const_iterator &input)
Tests whether the token stream starts with this type.
Definition: UnrankedPattern.h:53
static std::string xmlTagName()
The XML tag name of class.
Definition: UnrankedPattern.h:42
Definition: xmlApi.hpp:27