diff --git a/aintrospection2/makefile.conf b/aintrospection2/makefile.conf index 213b4f1c2e629608d7e2e3f6e2471cd0bc204b50..323d19933d16e13843897ef68c4da1953a5cfcc1 100644 --- a/aintrospection2/makefile.conf +++ b/aintrospection2/makefile.conf @@ -1,6 +1,6 @@ EXECUTABLE:=aintrospection2 -LINK_PATHS=../alib2cli/ ../alib2elgo/ ../alib2algo_experimental/ ../alib2algo/ ../alib2raw/ ../alib2raw/ ../alib2str_experimental/ ../alib2str/ ../alib2data_experimental/ ../alib2data/ ../alib2xml/ ../alib2measure/ ../alib2common/ ../alib2std/ -LINK_LIBRARIES=alib2cli alib2elgo alib2algo_experimental alib2algo alib2raw alib2str_experimental alib2str alib2data_experimental alib2data alib2xml alib2measure alib2common alib2std xml2 +LINK_PATHS=../alib2cli/ ../alib2elgo/ ../alib2algo_experimental/ ../alib2algo/ ../alib2raw/ ../alib2raw/ ../alib2str/ ../alib2data_experimental/ ../alib2data/ ../alib2xml/ ../alib2measure/ ../alib2common/ ../alib2std/ +LINK_LIBRARIES=alib2cli alib2elgo alib2algo_experimental alib2algo alib2raw alib2str alib2data_experimental alib2data alib2xml alib2measure alib2common alib2std xml2 INCLUDE_PATHS=\ \$$(SOURCES_BASE_DIR)/../../alib2cli/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2elgo/src/ \ @@ -8,7 +8,6 @@ INCLUDE_PATHS=\ \$$(SOURCES_BASE_DIR)/../../alib2algo/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2aux/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2raw/src/ \ - \$$(SOURCES_BASE_DIR)/../../alib2str_experimental/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2str/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2data_experimental/src/ \ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \ diff --git a/alib2algo_experimental/makefile.conf b/alib2algo_experimental/makefile.conf index e2ff4fbee46a8b9b80ecef1d4a82e2564f450e28..37608460f760b0197b20f56b41813236553e9dad 100644 --- a/alib2algo_experimental/makefile.conf +++ b/alib2algo_experimental/makefile.conf @@ -1,5 +1,5 @@ LIBRARY:=alib2algo_experimental TESTBIN:=alib2test -LINK_PATHS=../alib2algo/ ../alib2str_experimental/ ../alib2str/ ../alib2data_experimental/ ../alib2data/ ../alib2xml/ ../alib2measure/ ../alib2common/ ../alib2std/ -LINK_LIBRARIES=alib2algo alib2str_experimental alib2str alib2data_experimental alib2data alib2xml alib2measure alib2common alib2std xml2 -INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2algo/src/ \$$(SOURCES_BASE_DIR)/../../alib2str_experimental/src/ \$$(SOURCES_BASE_DIR)/../../alib2str/src/ \$$(SOURCES_BASE_DIR)/../../alib2data_experimental/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2xml/src/ \$$(SOURCES_BASE_DIR)/../../alib2measure/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ +LINK_PATHS=../alib2algo/ ../alib2str/ ../alib2data_experimental/ ../alib2data/ ../alib2xml/ ../alib2measure/ ../alib2common/ ../alib2std/ +LINK_LIBRARIES=alib2algo alib2str alib2data_experimental alib2data alib2xml alib2measure alib2common alib2std xml2 +INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2algo/src/ \$$(SOURCES_BASE_DIR)/../../alib2str/src/ \$$(SOURCES_BASE_DIR)/../../alib2data_experimental/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2xml/src/ \$$(SOURCES_BASE_DIR)/../../alib2measure/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ diff --git a/alib2str_experimental/makefile b/alib2str_experimental/makefile deleted file mode 100644 index 0b886940386c0839f59d2d1b395d4292060b6d4e..0000000000000000000000000000000000000000 --- a/alib2str_experimental/makefile +++ /dev/null @@ -1,3 +0,0 @@ --include makefile.conf --include ../build.conf --include ../makefile-library diff --git a/alib2str_experimental/makefile.conf b/alib2str_experimental/makefile.conf deleted file mode 100644 index 66ce4ebd4b2dc005713114be3ed7ae6e6025f96a..0000000000000000000000000000000000000000 --- a/alib2str_experimental/makefile.conf +++ /dev/null @@ -1,5 +0,0 @@ -LIBRARY:=alib2str_experimental -TESTBIN:=alib2test -LINK_PATHS=../alib2str/ ../alib2data_experimental/ ../alib2data/ ../alib2xml/ ../alib2measure/ ../alib2common/ ../alib2std/ -LINK_LIBRARIES=alib2str alib2data_experimental alib2data alib2xml alib2measure alib2common alib2std xml2 -INCLUDE_PATHS=\$$(SOURCES_BASE_DIR)/../../alib2str/src/ \$$(SOURCES_BASE_DIR)/../../alib2data_experimental/src/ \$$(SOURCES_BASE_DIR)/../../alib2data/src/ \$$(SOURCES_BASE_DIR)/../../alib2xml/src/ \$$(SOURCES_BASE_DIR)/../../alib2measure/src/ \$$(SOURCES_BASE_DIR)/../../alib2common/src/ \$$(SOURCES_BASE_DIR)/../../alib2std/src/ /usr/include/libxml2/ diff --git a/alib2str_experimental/src/graph/GraphFromStringLexer.cpp b/alib2str_experimental/src/graph/GraphFromStringLexer.cpp deleted file mode 100644 index a0d13b415328163f534fdd91c9f84bd79854c21e..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphFromStringLexer.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * GraphFromStringLexer.cpp - * - * Created on: Jun 19, 2014 - * Author: David Rosca - */ - -#include "GraphFromStringLexer.h" - -namespace graph { - -GraphFromStringLexer::Token GraphFromStringLexer::next(std::istream &in) -{ - Token token; - token.type = TokenType::ERROR; - char character; - -L0: - character = in.get(); - - if (in.eof()) { - token.type = TokenType::TEOF; - return token; - } else if (isspace(character)) { - token.raw += character; - goto L0; - } else if (character == '(') { - token.type = TokenType::LPAR; - token.value += character; - token.raw += character; - return token; - } else if (character == ')') { - token.type = TokenType::RPAR; - token.value += character; - token.raw += character; - return token; - } else if (character == ':') { - token.type = TokenType::COLON; - token.value += character; - token.raw += character; - return token; - } else if (character == ',') { - token.type = TokenType::COMMA; - token.value += character; - token.raw += character; - return token; - } else if (character == '=') { - token.type = TokenType::EQUAL; - token.value += character; - token.raw += character; - return token; - } else if (character >= '0' && character <= '9') { - token.type = TokenType::INTEGER; - token.value += character; - token.raw += character; - goto L1; - } else { - in.putback(character); - putback(in, std::move(token)); - token.type = TokenType::ERROR; - return token; - } - -L1: - character = in.get(); - if (in.eof()) { - return token; - } else if (character >= '0' && character <= '9') { - token.value += character; - token.raw += character; - goto L1; - } else { - in.unget(); - return token; - } -} - -GraphFromStringLexer::Token GraphFromStringLexer::peek(std::istream &in) -{ - Token token = next(in); - putback(in, token); - return token; -} - -void GraphFromStringLexer::putback(std::istream &input, GraphFromStringLexer::Token token) -{ - while (!token.raw.empty()) { - input.putback(token.raw.back()); - token.raw.pop_back(); - } - input.clear(); -} - -std::string GraphFromStringLexer::getString(std::istream &input) -{ - std::string str; - char character; - - while (input >> character) { - if (character == ':') { - input.putback(character); - return str; - } - str += character; - } - - return std::string(); -} - -} // namespace graph - diff --git a/alib2str_experimental/src/graph/GraphFromStringLexer.h b/alib2str_experimental/src/graph/GraphFromStringLexer.h deleted file mode 100644 index ac5318aacb5b6b901d0ece4964e8fd37b9fbc614..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphFromStringLexer.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GraphFromStringLexer.h - * - * Created on: Jun 19, 2014 - * Author: David Rosca - */ - -#ifndef GRAPH_FROM_STRING_LEXER_H_ -#define GRAPH_FROM_STRING_LEXER_H_ - -#include <string> -#include <istream> - -namespace graph { - -class GraphFromStringLexer -{ -public: - enum class TokenType { - LPAR, - RPAR, - COLON, - COMMA, - EQUAL, - INTEGER, - TEOF, - ERROR - }; - - struct Token { - TokenType type; - std::string value; - std::string raw; - }; - - static Token next(std::istream &input); - static Token peek(std::istream &input); - static void putback(std::istream &input, Token token); - - static std::string getString(std::istream &input); -}; - -} // namespace graph - -#endif // GRAPH_FROM_STRING_LEXER_H_ diff --git a/alib2str_experimental/src/graph/GraphFromStringParser.cpp b/alib2str_experimental/src/graph/GraphFromStringParser.cpp deleted file mode 100644 index 47605762a0e45df455cbf73799176e7b143b6211..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphFromStringParser.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * GraphFromStringParser.cpp - * - * Created on: Jun 19, 2014 - * Author: David Rosca - * Modified by: Jan Broz - */ - -#include "GraphFromStringParser.h" -#include "exception/CommonException.h" -#include "graph/GraphClasses.h" - -#include <StringApi.hpp> -#include <label/LabelStringApi.hpp> - -namespace graph { - -Graph GraphFromStringParser::parseGraph(std::istream &input) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::LPAR) { - throw exception::CommonException("Invalid input. Expected LPAR"); - } - - const std::string &str = GraphFromStringLexer::getString(input); - if (str == "AdjacencyListDirectedGraph") { - parseDelimiter(input); // : - Graph graph{parseDirectedGraph<AdjacencyListDirectedGraph>(input)}; - if (GraphFromStringLexer::next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::CommonException("Invalid input. Expected RPAR"); - } - return graph; - } else if (str == "AdjacencyMatrixDirectedGraph") { - parseDelimiter(input); // : - Graph graph{parseDirectedGraph<AdjacencyMatrixDirectedGraph>(input)}; - if (GraphFromStringLexer::next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::CommonException("Invalid input. Expected RPAR"); - } - return graph; - } else if (str == "AdjacencyListUndirectedGraph") { - parseDelimiter(input); // : - Graph graph{parseUndirectedGraph<AdjacencyListUndirectedGraph>(input)}; - if (GraphFromStringLexer::next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::CommonException("Invalid input. Expected RPAR"); - } - return graph; - } else if (str == "AdjacencyMatrixUndirectedGraph") { - parseDelimiter(input); // : - Graph graph{parseUndirectedGraph<AdjacencyMatrixUndirectedGraph>(input)}; - if (GraphFromStringLexer::next(input).type != GraphFromStringLexer::TokenType::RPAR) { - throw exception::CommonException("Invalid input. Expected RPAR"); - } - return graph; - } - - throw exception::CommonException("Invalid graph type"); -} - -template<typename GraphType> -GraphType GraphFromStringParser::parseDirectedGraph(std::istream &input) -{ - GraphType graph; - parseNodes(input, graph); - parseDelimiter(input); // : - parseDirectedEdges(input, graph); - parseDelimiter(input); // : - parseNodeValues(input, graph); - parseDelimiter(input); // : - parseDirectedEdgeValues(input, graph); - return graph; -} -/* -AdjacencyMatrixDirectedGraph GraphFromStringParser::parseAMDirectedGraph(std::istream &input) -{ - AdjacencyMatrixDirectedGraph graph; - parseNodes(input, graph); - parseDelimiter(input); // : - parseDirectedEdges(input, graph); - parseDelimiter(input); // : - parseNodeValues(input, graph); - parseDelimiter(input); // : - parseDirectedEdgeValues(input, graph); - return graph; -} -*/ -template<typename GraphType> -GraphType GraphFromStringParser::parseUndirectedGraph(std::istream &input) -{ - GraphType graph; - parseNodes(input, graph); - parseDelimiter(input); // : - parseUndirectedEdges(input, graph); - parseDelimiter(input); // : - parseNodeValues(input, graph); - parseDelimiter(input); // : - parseUndirectedEdgeValues(input, graph); - return graph; -} -/* -AdjacencyMatrixUndirectedGraph GraphFromStringParser::parseAMUndirectedGraph(std::istream &input) -{ - AdjacencyMatrixUndirectedGraph graph; - parseNodes(input, graph); - parseDelimiter(input); // : - parseUndirectedEdges(input, graph); - parseDelimiter(input); // : - parseNodeValues(input, graph); - parseDelimiter(input); // : - parseUndirectedEdgeValues(input, graph); - return graph; -} -*/ -REPRESENTATION GraphFromStringParser::parseRepresentation(std::istream &input) -{ - std::string representation = GraphFromStringLexer::getString(input); - if (representation.empty()) { - throw exception::CommonException("Invalid representation"); - } - return representationFromString(representation); -} - -Node GraphFromStringParser::parseNode(std::istream &input) -{ - return Node(alib::stringApi<label::Label>::parse(input)); -} - -DirectedEdge GraphFromStringParser::parseDirectedEdge(std::istream &input) -{ - Node from = parseNode(input); - label::Label name = alib::stringApi<label::Label>::parse(input); - Node to = parseNode(input); - return DirectedEdge(from, to, name); -} - -UndirectedEdge GraphFromStringParser::parseUndirectedEdge(std::istream &input) -{ - Node first = parseNode(input); - label::Label name = alib::stringApi<label::Label>::parse(input); - Node second = parseNode(input); - return UndirectedEdge(first, second, name); -} - -template<typename T> -void GraphFromStringParser::parseNodes(std::istream &input, T &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - - // Empty nodes? - if (token.type == GraphFromStringLexer::TokenType::COLON) { - return; - } - GraphFromStringLexer::putback(input, token); - - while (true) { - graph.addNode(parseNode(input)); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -void GraphFromStringParser::parseDirectedEdges(std::istream &input, DirectedGraph &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - - // Empty edges? - if (token.type == GraphFromStringLexer::TokenType::COLON) { - return; - } - GraphFromStringLexer::putback(input, token); - - while (true) { - graph.addEdge(parseDirectedEdge(input)); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -void GraphFromStringParser::parseUndirectedEdges(std::istream &input, UndirectedGraph &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - - // Empty edges? - if (token.type == GraphFromStringLexer::TokenType::COLON) { - return; - } - GraphFromStringLexer::putback(input, token); - - while (true) { - graph.addEdge(parseUndirectedEdge(input)); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -void GraphFromStringParser::parseDelimiter(std::istream &input) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COLON) { - throw exception::CommonException("Invalid input. Expected COLON"); - } -} - -int GraphFromStringParser::parseValue(std::istream &input) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::EQUAL) { - throw exception::CommonException("Invalid input. Expected EQUAL"); - } - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::INTEGER) { - throw exception::CommonException("Invalid input. Expected INTEGER"); - } - - return ext::from_string < int > (token.value); -} - -template<typename T> -void GraphFromStringParser::parseNodeValues(std::istream &input, T &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::peek(input); - - // Empty values? - if (token.type == GraphFromStringLexer::TokenType::COLON) { - return; - } - - while (true) { - graph::Node node = parseNode(input); - int value = parseValue(input); - graph.setNodeValue(node, value); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -void GraphFromStringParser::parseDirectedEdgeValues(std::istream &input, DirectedGraph &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::peek(input); - - // Empty values? - if (token.type == GraphFromStringLexer::TokenType::RPAR) { - return; - } - - while (true) { - graph::DirectedEdge node = parseDirectedEdge(input); - int value = parseValue(input); - graph.setEdgeValue(node, value); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -void GraphFromStringParser::parseUndirectedEdgeValues(std::istream &input, UndirectedGraph &graph) -{ - GraphFromStringLexer::Token token = GraphFromStringLexer::peek(input); - - // Empty values? - if (token.type == GraphFromStringLexer::TokenType::RPAR) { - return; - } - - while (true) { - graph::UndirectedEdge node = parseUndirectedEdge(input); - int value = parseValue(input); - graph.setEdgeValue(node, value); - - token = GraphFromStringLexer::next(input); - if (token.type != GraphFromStringLexer::TokenType::COMMA) { - GraphFromStringLexer::putback(input, token); - return; - } - } -} - -} // namespace graph diff --git a/alib2str_experimental/src/graph/GraphFromStringParser.h b/alib2str_experimental/src/graph/GraphFromStringParser.h deleted file mode 100644 index 4949009595f370dcc1afb6fc47a631d1dd67c691..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphFromStringParser.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * GraphFromStringParser.h - * - * Created on: Jun 19, 2014 - * Author: David Rosca - */ - -#ifndef GRAPH_FROM_STRING_PARSER_H_ -#define GRAPH_FROM_STRING_PARSER_H_ - -#include "graph/GraphClasses.h" -#include "GraphFromStringLexer.h" - -namespace graph { - -class GraphFromStringParser -{ -public: - static Graph parseGraph(std::istream &input); - template<typename GraphType> - static GraphType parseDirectedGraph(std::istream &input); - template<typename GraphType> - static GraphType parseUndirectedGraph(std::istream &input); - - static REPRESENTATION parseRepresentation(std::istream &input); - static Node parseNode(std::istream &input); - static DirectedEdge parseDirectedEdge(std::istream &input); - static UndirectedEdge parseUndirectedEdge(std::istream &input); - - template<typename T> - static void parseNodes(std::istream &input, T &graph); - static void parseDirectedEdges(std::istream &input, DirectedGraph &graph); - static void parseUndirectedEdges(std::istream &input, UndirectedGraph &graph); - static void parseDelimiter(std::istream &input); - static int parseValue(std::istream &input); - - template<typename T> - static void parseNodeValues(std::istream &input, T &graph); - static void parseDirectedEdgeValues(std::istream &input, DirectedGraph &graph); - static void parseUndirectedEdgeValues(std::istream &input, UndirectedGraph &graph); -}; - -} // namespace graph - -#endif // GRAPH_FROM_STRING_PARSER_H_ diff --git a/alib2str_experimental/src/graph/GraphStringApi.cpp b/alib2str_experimental/src/graph/GraphStringApi.cpp deleted file mode 100644 index d678c53174d86cc947c40fbf065b77fbeb78d192..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphStringApi.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * GraphStringApi.cpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#include "GraphStringApi.hpp" -#include "graph/GraphFromStringParser.h" -#include "graph/GraphToStringComposer.h" - -namespace alib { - -graph::Graph stringApi < graph::Graph >::parse ( std::istream & input ) { - return graph::GraphFromStringParser::parseGraph ( input ); -} - -void stringApi < graph::Graph >::compose ( std::ostream & output, const graph::Graph & data ) { - return graph::GraphToStringComposer::compose ( output, data ); -} - -} /* namespace alib */ diff --git a/alib2str_experimental/src/graph/GraphStringApi.hpp b/alib2str_experimental/src/graph/GraphStringApi.hpp deleted file mode 100644 index cc2f5d0ba49f03bf80ca7a5bf81e655a3519b67f..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphStringApi.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * GraphStringApi.hpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#ifndef GRAPH_STRING_API_HPP_ -#define GRAPH_STRING_API_HPP_ - -#include <StringApi.hpp> -#include <graph/Graph.h> - -namespace alib { - -template < > -struct stringApi < graph::Graph > { - static graph::Graph parse ( std::istream & input ); - static void compose ( std::ostream & output, const graph::Graph & data ); -}; - -} /* namespace alib */ - -#endif /* STRING_API_HPP_ */ diff --git a/alib2str_experimental/src/graph/GraphToStringComposer.cpp b/alib2str_experimental/src/graph/GraphToStringComposer.cpp deleted file mode 100644 index 1b84b07bd1e800c5975f2fb0d46c6cf13ca05203..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphToStringComposer.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * GraphToStringComposer.cpp - * - * Created on: Jun 19, 2014 - * Author: David Rosca - * Modified by: Jan Broz - */ - -#include "GraphToStringComposer.h" -#include "graph/GraphClasses.h" -#include <StringApi.hpp> -#include <label/LabelStringApi.hpp> - -#include <registration/AlgoRegistration.hpp> - -namespace graph { - -void GraphToStringComposer::compose(std::ostream &out, const Graph &graph) -{ - out << "("; - dispatch(out, graph.getData()); - out << ")"; -} - -void GraphToStringComposer::compose(std::ostream& out, const DirectedGraph &graph) -{ - out << graph.className(); - //composeRepresentation(out, graph.getRepresentation()); - out << ":"; - composeNodes(out, graph.getNodes()); - out << ":"; - composeDirectedEdges(out, graph.getEdges()); - out << ":"; - composeNodeValues(out, graph); - out << ":"; - composeEdgeValues(out, graph); -} - -//auto GraphToStringComposerDirectedGraph = registration::OverloadRegister < GraphToStringComposer, void, DirectedGraph>(GraphToStringComposer::compose); - -void GraphToStringComposer::compose(std::ostream& out, const UndirectedGraph &graph) -{ - out << graph.className(); - //composeRepresentation(out, graph.getRepresentation()); - out << ":"; - composeNodes(out, graph.getNodes()); - out << ":"; - composeUndirectedEdges(out, graph.getEdges()); - out << ":"; - composeNodeValues(out, graph); - out << ":"; - composeEdgeValues(out, graph); -} - -//auto> GraphToStringComposerUndirectedGraph = registration::OverloadRegister < GraphToStringComposer, void, UndirectedGraph>(GraphToStringComposer::compose); - - -// !! add graph types/representations -void composeALDG(std::ostream & out, const AdjacencyListDirectedGraph & graph) { - GraphToStringComposer::compose(out, graph); -} - -auto GraphToStringComposerALDG = registration::OverloadRegister < GraphToStringComposer, void, AdjacencyListDirectedGraph>(composeALDG); - -void composeAMDG(std::ostream & out, const AdjacencyMatrixDirectedGraph & graph) { - GraphToStringComposer::compose(out, graph); -} - -auto GraphToStringComposerAMDG = registration::OverloadRegister < GraphToStringComposer, void, AdjacencyMatrixDirectedGraph>(composeAMDG); - -void composeALUG(std::ostream & out, const AdjacencyListUndirectedGraph & graph) { - GraphToStringComposer::compose(out, graph); -} - -auto GraphToStringComposerALUG = registration::OverloadRegister < GraphToStringComposer, void, AdjacencyListUndirectedGraph>(composeALUG); - -void composeAMUG(std::ostream & out, const AdjacencyMatrixUndirectedGraph & graph) { - GraphToStringComposer::compose(out, graph); -} - -auto GraphToStringComposerAMUG = registration::OverloadRegister < GraphToStringComposer, void, AdjacencyMatrixUndirectedGraph>(composeAMUG); - - - -void GraphToStringComposer::composeNode(std::ostream& out, const Node &node) -{ - alib::stringApi<label::Label>::compose(out, node.getName()); -} - -void GraphToStringComposer::composeEdge(std::ostream& out, const DirectedEdge &edge) -{ - composeNode(out, edge.getFromNode()); - alib::stringApi<label::Label>::compose(out, edge.getName()); - composeNode(out, edge.getToNode()); -} - -void GraphToStringComposer::composeEdge(std::ostream& out, const UndirectedEdge &edge) -{ - composeNode(out, edge.getFirstNode()); - alib::stringApi<label::Label>::compose(out, edge.getName()); - composeNode(out, edge.getSecondNode()); -} - -void GraphToStringComposer::composeRepresentation(std::ostream &out, REPRESENTATION representation) -{ - out << representationToString(representation); -} - -void GraphToStringComposer::composeNodes(std::ostream &out, const ext::set<Node> &nodes) -{ - bool first = true; - - for (const Node &node : nodes) { - if (first) { - first = false; - } else { - out << ","; - } - composeNode(out, node); - } -} - -void GraphToStringComposer::composeDirectedEdges(std::ostream &out, const ext::set<DirectedEdge> &edges) -{ - bool first = true; - - for (const DirectedEdge &edge : edges) { - if (first) { - first = false; - } else { - out << ","; - } - composeEdge(out, edge); - } -} - -void GraphToStringComposer::composeUndirectedEdges(std::ostream &out, const ext::set<UndirectedEdge> &edges) -{ - bool first = true; - - for (const UndirectedEdge &edge : edges) { - if (first) { - first = false; - } else { - out << ","; - } - composeEdge(out, edge); - } -} - -template<typename T> -void GraphToStringComposer::composeNodeValues(std::ostream &out, const T &graph) -{ - bool first = true; - - for (auto i : graph.nodeValues) { - if (first) { - first = false; - } else { - out << ","; - } - composeNode(out, i.first); - out << "=" << i.second; - } -} - -template<typename T> -void GraphToStringComposer::composeEdgeValues(std::ostream &out, const T &graph) -{ - bool first = true; - - for (auto i : graph.edgeValues) { - if (first) { - first = false; - } else { - out << ","; - } - composeEdge(out, i.first); - out << "=" << i.second; - } -} - -} // namespace graph diff --git a/alib2str_experimental/src/graph/GraphToStringComposer.h b/alib2str_experimental/src/graph/GraphToStringComposer.h deleted file mode 100644 index f5817bfb36cc470b09551a9a810f3f80079be89c..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/graph/GraphToStringComposer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * GraphToStringComposer.h - * - * Created on: Jun 19, 2014 - * Author: David Rosca - */ - -#ifndef GRAPH_TO_STRING_COMPOSER_H_ -#define GRAPH_TO_STRING_COMPOSER_H_ - -#include <set> -#include <core/multipleDispatch.hpp> -#include "graph/GraphClasses.h" - -namespace graph { - -class GraphToStringComposer : public alib::SingleDispatchFirstStaticParam<GraphToStringComposer, void, std::ostream&, const GraphBase &> { -private: - static void composeNode(std::ostream& out, const Node &node); - static void composeEdge(std::ostream& out, const DirectedEdge &edge); - static void composeEdge(std::ostream& out, const UndirectedEdge &edge); - - static void composeRepresentation(std::ostream &out, REPRESENTATION representation); - static void composeNodes(std::ostream &out, const ext::set<Node> &nodes); - static void composeDirectedEdges(std::ostream &out, const ext::set<DirectedEdge> &edges); - static void composeUndirectedEdges(std::ostream &out, const ext::set<UndirectedEdge> &edges); - - template<typename T> - static void composeNodeValues(std::ostream &out, const T &graph); - template<typename T> - static void composeEdgeValues(std::ostream &out, const T &graph); - -public: - static void compose(std::ostream& out, const Graph& graph); - - static void compose(std::ostream& out, const DirectedGraph& graph); - static void compose(std::ostream& out, const UndirectedGraph& graph); -}; - -} // namespace graph - -#endif // GRAPH_TO_STRING_COMPOSER_H_ diff --git a/alib2str_experimental/src/label/LabelFromStringLexer.cpp b/alib2str_experimental/src/label/LabelFromStringLexer.cpp deleted file mode 100644 index 3a0d5c367d88093b533d55b37a2ab524c2510133..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelFromStringLexer.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * LabelFromStringLexer.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "LabelFromStringLexer.h" - -namespace label { - -LabelFromStringLexer::Token LabelFromStringLexer::next(std::istream& in) { - LabelFromStringLexer::Token token; - token.type = TokenType::ERROR; - token.value = ""; - token.raw = ""; - char character; - -L0: - character = in.get(); - if(in.eof()) { - token.type = TokenType::TEOF; - return token; - } else if(character == ' ' || character == '\n' || character == '\t') { - token.raw += character; - goto L0; - } else { - in.putback(character); - putback(in, std::move(token)); - token.type = TokenType::ERROR; - return token; - } -} - -void LabelFromStringLexer::putback(std::istream& in, LabelFromStringLexer::Token token) { - while(!token.raw.empty()) { - in.putback(token.raw.back()); - token.raw.pop_back(); - } - in.clear(); -} - -} /* namespace label */ diff --git a/alib2str_experimental/src/label/LabelFromStringLexer.h b/alib2str_experimental/src/label/LabelFromStringLexer.h deleted file mode 100644 index 6d1029d814a50dd6d539975cb5024729e381700e..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelFromStringLexer.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * LabelFromStringLexer.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#ifndef LABEL_FROM_STRING_LEXER_H_ -#define LABEL_FROM_STRING_LEXER_H_ - -#include <string> -#include <istream> - -namespace label { - -class LabelFromStringLexer { -public: - enum class TokenType { - TEOF, - ERROR - }; - - struct Token { - TokenType type; - std::string value; - std::string raw; - }; - - static Token next(std::istream& input); - static void putback(std::istream& input, Token token); -}; - -} /* namespace label */ - -#endif /* LABEL_FROM_STRING_LEXER_H_ */ diff --git a/alib2str_experimental/src/label/LabelFromStringParser.cpp b/alib2str_experimental/src/label/LabelFromStringParser.cpp deleted file mode 100644 index 27bc25173152f9a546b651a5c87a883115b3d1ac..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelFromStringParser.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * LabelFromStringParser.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "LabelFromStringParser.h" -#include "exception/CommonException.h" -#include "label/PrimitiveLabel.h" -#include "label/ObjectLabel.h" -#include <label/Label.h> - -#include <StringApi.hpp> - -namespace label { - -Label LabelFromStringParser::parseLabel(std::istream& input) { - return parseLabel(input, ext::set<FEATURES>({FEATURES::PRIMITIVE, FEATURES::HEXAVIGESIMAL, FEATURES::OBJECT, FEATURES::UNIQUE_LABEL})); -} - -Label LabelFromStringParser::parseLabel(std::istream& input, const ext::set<FEATURES>& features) { - LabelFromStringLexer::Token token = LabelFromStringLexer::next(input); - switch(token.type) { - case LabelFromStringLexer::TokenType::TEOF: - throw exception::CommonException("Unexpected end of file"); - case LabelFromStringLexer::TokenType::ERROR: - if(!features.count(FEATURES::PRIMITIVE)) throw exception::CommonException("Disabled formalism PrimitiveLabel"); - LabelFromStringLexer::putback(input, token); - return Label(PrimitiveLabel(alib::stringApi<primitive::Primitive>::parse(input))); - } - throw exception::CommonException("Unrecognised input \"" + token.value + "\""); -} - -} /* namespace label */ diff --git a/alib2str_experimental/src/label/LabelFromStringParser.h b/alib2str_experimental/src/label/LabelFromStringParser.h deleted file mode 100644 index 4aabaa42a3a78e4bc98985ea3b5ef0ce55b30f27..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelFromStringParser.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * LabelFromStringParser.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#ifndef LABEL_FROM_STRING_PARSER_H_ -#define LABEL_FROM_STRING_PARSER_H_ - -#include "LabelFromStringLexer.h" -#include "label/LabelFeatures.h" -#include <set> - -namespace label { - -class LabelFromStringParser { -public: - static Label parseLabel(std::istream&, const ext::set<FEATURES>&); - static Label parseLabel(std::istream&); -}; - -} /* namespace label */ - -#endif /* LABEL_FROM_STRING_PARSER_H_ */ diff --git a/alib2str_experimental/src/label/LabelStringApi.cpp b/alib2str_experimental/src/label/LabelStringApi.cpp deleted file mode 100644 index a12f9dc45f4267e289a1900f72435ae7f1a8cb55..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelStringApi.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * LabelStringApi.cpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#include "LabelStringApi.hpp" -#include "label/LabelFromStringParser.h" -#include "label/LabelToStringComposer.h" - -namespace alib { - -label::Label stringApi < label::Label >::parse ( std::istream & input ) { - return label::LabelFromStringParser::parseLabel ( input ); -} - -void stringApi < label::Label >::compose ( std::ostream & output, const label::Label & data ) { - return label::LabelToStringComposer::compose ( output, data ); -} - -} /* namespace alib */ diff --git a/alib2str_experimental/src/label/LabelStringApi.hpp b/alib2str_experimental/src/label/LabelStringApi.hpp deleted file mode 100644 index 8f77fabe3d318768d45c06bf276bd6e9ffc983db..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelStringApi.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * LabelStringApi.hpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#ifndef LABEL_STRING_API_HPP_ -#define LABEL_STRING_API_HPP_ - -#include <StringApi.hpp> -#include <label/Label.h> - -namespace alib { - -template < > -struct stringApi < label::Label > { - static label::Label parse ( std::istream & input ); - - static void compose ( std::ostream & output, const label::Label & data ); -}; - -} /* namespace alib */ - -#endif /* STRING_API_HPP_ */ diff --git a/alib2str_experimental/src/label/LabelToStringComposer.cpp b/alib2str_experimental/src/label/LabelToStringComposer.cpp deleted file mode 100644 index 8445aabaa74cd575908bacd9ac48e3dc5598f15e..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelToStringComposer.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * LabelToStringComposer.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include <object/ObjectToStringComposer.h> - -#include "LabelToStringComposer.h" -#include "label/PrimitiveLabel.h" -#include "label/HexavigesimalLabel.h" -#include "label/ObjectLabel.h" -#include "label/UniqueLabel.h" -#include "label/InitialStateLabel.h" -#include "label/FinalStateLabel.h" -#include "label/FailStateLabel.h" - -#include <StringApi.hpp> - -#include <registration/AlgoRegistration.hpp> - -namespace label { - -void LabelToStringComposer::compose(std::ostream& out, const PrimitiveLabel& label) { - alib::stringApi<primitive::Primitive>::compose(out, label.getData()); -} - -auto LabelToStringComposerPrimitiveLabel = registration::OverloadRegister < LabelToStringComposer, void, PrimitiveLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const HexavigesimalLabel& label) { - out << (std::string) label; -} - -auto LabelToStringComposerHexavigesimalLabel = registration::OverloadRegister < LabelToStringComposer, void, HexavigesimalLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const ObjectLabel& label) { - out << (std::string) label; -} - -auto LabelToStringComposerObjectLabel = registration::OverloadRegister < LabelToStringComposer, void, ObjectLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const UniqueLabel& label) { - out << '<'; - dispatch(out, label.getLabel().getData()); - out << ", "; - alib::stringApi<primitive::Primitive>::compose(out, primitive::Primitive(label.getId())); - out << '>'; -} - -auto LabelToStringComposerUniqueLabel = registration::OverloadRegister < LabelToStringComposer, void, UniqueLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const FailStateLabel& label) { - out << (std::string) label; -} - -auto LabelToStringComposerFailStateLabel = registration::OverloadRegister < LabelToStringComposer, void, FailStateLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const InitialStateLabel& label) { - out << (std::string) label; -} - -auto LabelToStringComposerInitialStateLabel = registration::OverloadRegister < LabelToStringComposer, void, InitialStateLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& out, const FinalStateLabel& label) { - out << (std::string) label; -} - -auto LabelToStringComposerFinalStateLabel = registration::OverloadRegister < LabelToStringComposer, void, FinalStateLabel>(LabelToStringComposer::compose); - -void LabelToStringComposer::compose(std::ostream& output, const Label& label) { - dispatch(output, label.getData()); -} - -} /* namespace label */ diff --git a/alib2str_experimental/src/label/LabelToStringComposer.h b/alib2str_experimental/src/label/LabelToStringComposer.h deleted file mode 100644 index 0a0c88dcfbf9323eb74547ca79ff18bbdaaf4559..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/label/LabelToStringComposer.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * LabelToStringComposer.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnciek - */ - -#ifndef LABEL_TO_STRING_COMPOSER_H_ -#define LABEL_TO_STRING_COMPOSER_H_ - -#include <ostream> -#include <core/multipleDispatch.hpp> -#include "label/Label.h" -#include "label/LabelFeatures.h" - -namespace label { - -/** - * This class contains methods to print XML representation of string to the output stream. - */ -class LabelToStringComposer : public alib::SingleDispatchFirstStaticParam<LabelToStringComposer, void, std::ostream&, const LabelBase &> { -public: - static void compose(std::ostream&, const PrimitiveLabel& label); - static void compose(std::ostream&, const HexavigesimalLabel& label); - static void compose(std::ostream&, const ObjectLabel& label); - static void compose(std::ostream&, const UniqueLabel& label); - static void compose(std::ostream&, const FailStateLabel& label); - static void compose(std::ostream&, const InitialStateLabel& label); - static void compose(std::ostream&, const FinalStateLabel& label); - - /** - * Prints text representation of Label to the output stream. - * @param string String to print - * @param out output stream to which print the String - */ - static void compose(std::ostream& output, const Label& string); -}; - -} /* namespace label */ - -#endif /* LABEL_TO_STRING_COMPOSER_H_ */ diff --git a/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.cpp b/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.cpp deleted file mode 100644 index 029510c0b0f6177811afa02f2041b62d5ebb1b7c..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * PrimitiveFromStringLexer.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "PrimitiveFromStringLexer.h" - -namespace primitive { - -PrimitiveFromStringLexer::Token PrimitiveFromStringLexer::next(std::istream& in) { - PrimitiveFromStringLexer::Token token; - token.type = TokenType::ERROR; - token.value = ""; - token.raw = ""; - char character; - -L0: - character = in.get(); - if(in.eof()) { - token.type = TokenType::TEOF; - return token; - } else if(character == ' ' || character == '\n' || character == '\t') { - token.raw += character; - goto L0; - } else if((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z')) { - token.type = TokenType::CHAR; - token.value += character; - token.raw += character; - return token; - } else if(character >= '0' && character <= '9') { - token.type = TokenType::INTEGER; - token.value += character; - token.raw += character; - goto L1; - } else if(character == '\'') { - token.type = TokenType::STRING; - token.raw += character; - goto L3; - } else { - in.putback(character); - putback(in, std::move(token)); - token.type = TokenType::ERROR; - return token; - } -L1: - character = in.get(); - if(in.eof()) { - return token; - } else if(character >= '0' && character <= '9') { - token.value += character; - token.raw += character; - goto L1; - } else { - in.unget(); - return token; - } -L3: - character = in.get(); - if(in.eof()) { - token.type = TokenType::TEOF; - return token; - } else if(character == '\'') { - token.raw += character; - return token; - } else if(character == '\\') { - token.raw += character; - goto L4; - } else { - token.value += character; - token.raw += character; - goto L3; - } -L4: - character = in.get(); - if(in.eof()) { - token.type = TokenType::TEOF; - return token; - } else if(character == '\'' || character == '\\') { - token.value += character; - token.raw += character; - goto L3; - } else { - in.putback(character); - putback(in, std::move(token)); - token.type = TokenType::ERROR; - return token; - } -} - -void PrimitiveFromStringLexer::putback(std::istream& in, PrimitiveFromStringLexer::Token token) { - while(!token.raw.empty()) { - in.putback(token.raw.back()); - token.raw.pop_back(); - } - in.clear(); -} - -} /* namespace primitive */ diff --git a/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.h b/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.h deleted file mode 100644 index 2c4cc0a208b92caedb60278f041a0aa73579f55f..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveFromStringLexer.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * PrimitiveFromStringLexer.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#ifndef PRIMITIVE_FROM_STRING_LEXER_H_ -#define PRIMITIVE_FROM_STRING_LEXER_H_ - -#include <string> -#include <istream> - -namespace primitive { - -class PrimitiveFromStringLexer { -public: - enum class TokenType { - STRING, - CHAR, - INTEGER, - TEOF, - ERROR - }; - - struct Token { - TokenType type; - std::string value; - std::string raw; - }; - - static Token next(std::istream& input); - static void putback(std::istream& input, Token token); -}; - -} /* namespace primitive */ - -#endif /* PRIMITIVE_FROM_STRING_LEXER_H_ */ diff --git a/alib2str_experimental/src/primitive/PrimitiveFromStringParser.cpp b/alib2str_experimental/src/primitive/PrimitiveFromStringParser.cpp deleted file mode 100644 index 6f5cc4bda031d25b2082b43f61ecba0d688fa1aa..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveFromStringParser.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * PrimitiveFromStringParser.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include "PrimitiveFromStringParser.h" -#include "exception/CommonException.h" -#include "primitive/Primitive.h" -#include "primitive/String.h" -#include "primitive/Integer.h" -#include "primitive/Character.h" -#include <primitive/Primitive.h> - -namespace primitive { - -Primitive PrimitiveFromStringParser::parsePrimitive(std::istream& input) { - return parsePrimitive(input, ext::set<FEATURES>({FEATURES::STRING, FEATURES::CHAR, FEATURES::INTEGER})); -} - -Primitive PrimitiveFromStringParser::parsePrimitive(std::istream& input, const ext::set<FEATURES>& features) { - PrimitiveFromStringLexer::Token token = PrimitiveFromStringLexer::next(input); - switch(token.type) { - case PrimitiveFromStringLexer::TokenType::TEOF: - throw exception::CommonException("Unexpected end of file"); - case PrimitiveFromStringLexer::TokenType::STRING: - if(!features.count(FEATURES::STRING)) throw exception::CommonException("Disabled formalism String"); - return Primitive(String(token.value)); - case PrimitiveFromStringLexer::TokenType::CHAR: - if(!features.count(FEATURES::CHAR)) throw exception::CommonException("Disabled formalism Char"); - return Primitive(Character(token.value[0])); - case PrimitiveFromStringLexer::TokenType::INTEGER: - if(!features.count(FEATURES::INTEGER)) throw exception::CommonException("Disabled formalism Integer"); - return Primitive(Integer(ext::from_string < int > (token.value))); - case PrimitiveFromStringLexer::TokenType::ERROR: - break; - } - throw exception::CommonException("Unrecognised input \"" + token.value + "...\""); -} - -} /* namespace primitive */ diff --git a/alib2str_experimental/src/primitive/PrimitiveFromStringParser.h b/alib2str_experimental/src/primitive/PrimitiveFromStringParser.h deleted file mode 100644 index 9709cbbc92b7b0e6561ebcc8d7f1fd4758d23c28..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveFromStringParser.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * PrimitiveFromStringParser.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#ifndef PRIMITIVE_FROM_STRING_PARSER_H_ -#define PRIMITIVE_FROM_STRING_PARSER_H_ - -#include "PrimitiveFromStringLexer.h" -#include "primitive/PrimitiveFeatures.h" -#include <set> - -namespace primitive { - -class PrimitiveFromStringParser { -public: - static Primitive parsePrimitive(std::istream&, const ext::set<FEATURES>&); - static Primitive parsePrimitive(std::istream&); -}; - -} /* namespace primitive */ - -#endif /* PRIMITIVE_FROM_STRING_PARSER_H_ */ diff --git a/alib2str_experimental/src/primitive/PrimitiveStringApi.cpp b/alib2str_experimental/src/primitive/PrimitiveStringApi.cpp deleted file mode 100644 index bfd2f2dd3d2eaaf1bc5d07c10e5eb301c8611287..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveStringApi.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * PrimitiveStringApi.cpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#include "PrimitiveStringApi.hpp" -#include "primitive/PrimitiveFromStringParser.h" -#include "primitive/PrimitiveToStringComposer.h" - -namespace alib { - -primitive::Primitive stringApi < primitive::Primitive >::parse ( std::istream & input ) { - return primitive::PrimitiveFromStringParser::parsePrimitive ( input ); -} - -void stringApi < primitive::Primitive >::compose ( std::ostream & output, const primitive::Primitive & data ) { - return primitive::PrimitiveToStringComposer::compose ( output, data ); -} - -} /* namespace alib */ diff --git a/alib2str_experimental/src/primitive/PrimitiveStringApi.hpp b/alib2str_experimental/src/primitive/PrimitiveStringApi.hpp deleted file mode 100644 index 9c7cc028c35638359890245c67325e92fbe0af35..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveStringApi.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * PrimitiveStringApi.hpp - * - * Created on: Oct 12, 2016 - * Author: Jan Travnicek - */ - -#ifndef PRIMITIVE_STRING_API_HPP_ -#define PRIMITIVE_STRING_API_HPP_ - -#include <StringApi.hpp> -#include <primitive/Primitive.h> - -namespace alib { - -template < > -struct stringApi < primitive::Primitive > { - static primitive::Primitive parse ( std::istream & input ); - static void compose ( std::ostream & output, const primitive::Primitive & data ); -}; - -} /* namespace alib */ - -#endif /* STRING_API_HPP_ */ diff --git a/alib2str_experimental/src/primitive/PrimitiveToStringComposer.cpp b/alib2str_experimental/src/primitive/PrimitiveToStringComposer.cpp deleted file mode 100644 index 8985c268a1706ed08a4cb583a414047efb99f45f..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveToStringComposer.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * PrimitiveToStringComposer.cpp - * - * Created on: Nov 23, 2013 - * Author: Jan Travnicek - */ - -#include <object/ObjectToStringComposer.h> - -#include "PrimitiveToStringComposer.h" -#include "primitive/Integer.h" -#include "primitive/String.h" -#include "primitive/Character.h" -#include "primitive/Unsigned.h" -#include "primitive/Bool.h" - -#include <registration/AlgoRegistration.hpp> - -namespace primitive { - -void PrimitiveToStringComposer::compose(std::ostream& out, const String& primitive) { - auto replace = [](std::string& str, const std::string& what, const std::string& with) { - size_t index = 0; - while((index = str.find(what, index)) != std::string::npos) { - str.replace(index, what.length(), with); - index += with.length(); - } - }; - - std::string tmp = primitive.getData(); - replace(tmp, "'", "\\'" ); - out << '\'' << tmp << '\''; -} - -auto PrimitiveToStringComposerString = registration::OverloadRegister < PrimitiveToStringComposer, void, String>(PrimitiveToStringComposer::compose); - -void PrimitiveToStringComposer::compose(std::ostream& out, const Character& primitive) { - out << primitive.getData(); -} - -auto PrimitiveToStringComposerCharacter = registration::OverloadRegister < PrimitiveToStringComposer, void, Character>(PrimitiveToStringComposer::compose); - -void PrimitiveToStringComposer::compose(std::ostream& out, const Integer& primitive) { - out << primitive.getData(); -} - -auto PrimitiveToStringComposerInteger = registration::OverloadRegister < PrimitiveToStringComposer, void, Integer>(PrimitiveToStringComposer::compose); - -void PrimitiveToStringComposer::compose(std::ostream& out, const Unsigned& primitive) { - out << primitive.getData(); -} - -auto PrimitiveToStringComposerUnsigned = registration::OverloadRegister < PrimitiveToStringComposer, void, Unsigned>(PrimitiveToStringComposer::compose); - -void PrimitiveToStringComposer::compose(std::ostream& out, const Bool& primitive) { - out << (primitive.getData() ? "true" : "false"); -} - -auto PrimitiveToStringComposerBool = registration::OverloadRegister < PrimitiveToStringComposer, void, Bool>(PrimitiveToStringComposer::compose); - -void PrimitiveToStringComposer::compose(std::ostream& out, const Primitive& primitive) { - dispatch(out, primitive.getData()); -} - -} /* namespace primitive */ diff --git a/alib2str_experimental/src/primitive/PrimitiveToStringComposer.h b/alib2str_experimental/src/primitive/PrimitiveToStringComposer.h deleted file mode 100644 index e98e527eb5d5c0298fa9dcd7bf617e53e377f969..0000000000000000000000000000000000000000 --- a/alib2str_experimental/src/primitive/PrimitiveToStringComposer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * PrimitiveToStringComposer.h - * - * Created on: Nov 23, 2013 - * Author: Jan Travnciek - */ - -#ifndef PRIMITIVE_TO_STRING_COMPOSER_H_ -#define PRIMITIVE_TO_STRING_COMPOSER_H_ - -#include <ostream> -#include <core/multipleDispatch.hpp> -#include "primitive/Primitive.h" -#include "primitive/PrimitiveFeatures.h" - -namespace primitive { - -/** - * This class contains methods to print XML representation of string to the output stream. - */ -class PrimitiveToStringComposer : public alib::SingleDispatchFirstStaticParam<PrimitiveToStringComposer, void, std::ostream&, const PrimitiveBase &> { -public: - static void compose(std::ostream&, const Integer& primitive); - static void compose(std::ostream&, const String& primitive); - static void compose(std::ostream&, const Character& primitive); - static void compose(std::ostream&, const Unsigned& primitive); - static void compose(std::ostream&, const Bool& primitive); - - /** - * Prints text representation of Primitive to the output stream. - * @param string String to print - * @param out output stream to which print the String - */ - static void compose(std::ostream& out, const Primitive& string); -}; - -} /* namespace primitive */ - -#endif /* PRIMITIVE_TO_STRING_COMPOSER_H_ */ diff --git a/alib2str_experimental/test-src/graph/GraphTest.cpp b/alib2str_experimental/test-src/graph/GraphTest.cpp deleted file mode 100644 index ce9ecd4b5786c22d3ad73f49e16c113f7f03fb1f..0000000000000000000000000000000000000000 --- a/alib2str_experimental/test-src/graph/GraphTest.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * GraphTest.cpp - * - * Created on: Jun 19, 2014 - * Author: David Rosca - * Modified by: Jan Broz - */ - -#include "GraphTest.h" - -#include "sax/SaxParseInterface.h" -#include "sax/SaxComposeInterface.h" - -#include "factory/StringDataFactory.hpp" - - -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GraphTest, "graph" ); -CPPUNIT_TEST_SUITE_REGISTRATION( GraphTest ); - - -template< typename UndirectedGraphImpl, typename DirectedGraphImpl > -void testStringParser_impl() -{ - // Common - graph::Node n1("n1"); - graph::Node n2("n2"); - graph::Node n3("n3"); - - // Directed - DirectedGraphImpl dg; - dg.addNode(n1); - dg.addNode(n2); - dg.addNode(n3); - dg.addEdge(graph::DirectedEdge(n1, n2)); - dg.addEdge(graph::DirectedEdge(n1, n3)); - - graph::Graph dg1(dg); - std::string tmp = alib::StringDataFactory::toString(dg1); - graph::Graph dg2 = alib::StringDataFactory::fromString (tmp); - std::string tmp2 = alib::StringDataFactory::toString(dg2); - CPPUNIT_ASSERT(dg1 == dg2); - - dg.setEdgeValue(graph::DirectedEdge(n1, n2), 1); - dg.setEdgeValue(graph::DirectedEdge(n1, n3), 2); - - graph::Graph dg1_2(dg); - tmp = alib::StringDataFactory::toString(dg1_2); - graph::Graph dg2_2 = alib::StringDataFactory::fromString (tmp); - CPPUNIT_ASSERT(dg1_2 == dg2_2); - - // Undirected - UndirectedGraphImpl ug; - ug.addNode(n1); - ug.addNode(n2); - ug.addNode(n3); - ug.addEdge(graph::UndirectedEdge(n1, n2)); - ug.addEdge(graph::UndirectedEdge(n1, n3)); - - graph::Graph ug1(ug); - tmp = alib::StringDataFactory::toString(ug1); - graph::Graph ug2 = alib::StringDataFactory::fromString (tmp); - CPPUNIT_ASSERT(ug1 == ug2); - - ug.setEdgeValue(graph::UndirectedEdge(n1, n2), 1); - ug.setEdgeValue(graph::UndirectedEdge(n1, n3), 2); - - graph::Graph ug1_2(ug); - tmp = alib::StringDataFactory::toString(ug1_2); - graph::Graph ug2_2 = alib::StringDataFactory::fromString (tmp); - CPPUNIT_ASSERT(ug1_2 == ug2_2); -} - - -#define TEST_REPRESENTATIONS(t) {\ - std::cout << "ADJACENCY_LIST" << std::endl;\ - t< graph::AdjacencyListUndirectedGraph, graph::AdjacencyListDirectedGraph >();\ - std::cout << "ADJACENCY_MATRIX" << std::endl;\ - t< graph::AdjacencyMatrixUndirectedGraph, graph::AdjacencyMatrixDirectedGraph >();\ -} - -void GraphTest::testStringParser() -{ - TEST_REPRESENTATIONS(testStringParser_impl); -} diff --git a/alib2str_experimental/test-src/graph/GraphTest.h b/alib2str_experimental/test-src/graph/GraphTest.h deleted file mode 100644 index af9fe1114c362f9e7bf0422efaa0f75c6ee4e951..0000000000000000000000000000000000000000 --- a/alib2str_experimental/test-src/graph/GraphTest.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * GraphTest.h - * - * Created on: Jun 19, 2014 - * Author: David Rosca - */ - -#ifndef GRAPH_TEST_H_ -#define GRAPH_TEST_H_ - -#include <cppunit/extensions/HelperMacros.h> - -#include "graph/GraphClasses.h" - -class GraphTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(GraphTest); - CPPUNIT_TEST(testStringParser); - CPPUNIT_TEST_SUITE_END(); - -public: - void testStringParser(); -}; - -#endif // GRAPH_TEST_H_ diff --git a/alib2str_experimental/test-src/main.cpp b/alib2str_experimental/test-src/main.cpp deleted file mode 100644 index fd442ebd124cc1580de43b2e1846e5063fefde68..0000000000000000000000000000000000000000 --- a/alib2str_experimental/test-src/main.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include <tclap/CmdLine.h> - -#include <cppunit/CompilerOutputter.h> -#include <cppunit/extensions/TestFactoryRegistry.h> -#include <cppunit/ui/text/TestRunner.h> -#include <cppunit/TestResultCollector.h> -#include <cppunit/TestResult.h> -#include <cppunit/XmlOutputter.h> - -#include <cppunit/Test.h> -#include <cppunit/TestFailure.h> -#include <cppunit/portability/Stream.h> -#include <cppunit/TestListener.h> -#include <cppunit/SourceLine.h> -#include <cppunit/Exception.h> - -#include <exception/CommonException.h> - -CPPUNIT_NS_BEGIN - -class CPPUNIT_API TestProgressListener : public TestListener -{ -public: - TestProgressListener(); - - virtual ~TestProgressListener(); - - void startTest( Test *test ); - - void addFailure( const TestFailure &failure ); - - void endTest( Test *test ); - - int getResult() const; - - void printResults() const; - -private: - TestProgressListener( const TestProgressListener © ); - - void operator =( const TestProgressListener © ); - -private: - int m_Failures; - int m_Tests; - int m_Assertions; - bool m_lastTestFailed; -}; - -TestProgressListener::TestProgressListener() : m_Failures( 0 ), m_Tests(0), m_Assertions(0), m_lastTestFailed( false ) -{ -} - -TestProgressListener::~TestProgressListener() -{ -} - -void TestProgressListener::startTest( Test * test ) -{ - stdCOut() << test->getName() << ":" << "\n"; - stdCOut().flush(); - - m_lastTestFailed = false; - m_Tests++; -} - -void TestProgressListener::addFailure( const TestFailure &failure ) -{ - stdCOut() << (failure.isError() ? "error" : "assertion") << " : " << failure.failedTestName() << " : " << failure.sourceLine().lineNumber() << "\n"; - stdCOut() << "Exception " << failure.thrownException()->message().details(); - - m_lastTestFailed = true; - if(failure.isError()) m_Failures++; else m_Assertions++; -} - -void TestProgressListener::endTest( Test * test) -{ - stdCOut() << "Result (" << test->getName() << ")"; - stdCOut().flush(); - - if ( !m_lastTestFailed ) - stdCOut() << " : OK"; - else - stdCOut() << " : Fail"; - stdCOut() << "\n\n"; -} - -int TestProgressListener::getResult() const { - return m_Failures + m_Assertions; -} - -void TestProgressListener::printResults() const { - stdCOut() << "Overal result: Tests: " << m_Tests << " Assertions: " << m_Assertions << " Failures: " << m_Failures << "\n"; -} - -CPPUNIT_NS_END - -int main(int argc, char* argv[]) { - try { - TCLAP::CmdLine cmd("Main test binary.", ' ', "0.01"); - - TCLAP::MultiArg<std::string> testPathSegments("p", "path", "test path", false, "string" ); - cmd.add( testPathSegments ); - - cmd.parse(argc, argv); - - CppUnit::TestResult controller; - - CppUnit::TestResultCollector result; - controller.addListener( &result ); - - CppUnit::TestProgressListener progressListener; - controller.addListener( &progressListener ); - - CppUnit::Test *suite = NULL; - std::string testPath = ""; - if(testPathSegments.getValue().size() == 0) { - // Get the top level suite from the registry - suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); - } else if(testPathSegments.getValue().size() == 1) { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); - } else { - suite = CppUnit::TestFactoryRegistry::getRegistry(testPathSegments.getValue()[0]).makeTest(); - bool first = true; - for(const std::string& path : testPathSegments.getValue()) { - if(first) { - first = false; - continue; - } - testPath += path + "/"; - } - testPath.pop_back(); - } - - // Adds the test to the list of test to run - CppUnit::TextUi::TestRunner runner; - runner.addTest( suite ); - - // Change the default outputter to a compiler error format outputter - runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); - // Run the tests. - runner.run( controller, testPath ); - - progressListener.printResults(); - - std::ofstream xmlFileResults("CppUnitTestResults.xml"); - CppUnit::XmlOutputter xmlOut(&result, xmlFileResults); - xmlOut.write(); - - return progressListener.getResult(); - } catch(const exception::CommonException& exception) { - std::cerr << exception.getCause() << std::endl; - return 1; - } catch(const TCLAP::ArgException& exception) { - std::cerr << exception.error() << std::endl; - return 2; - } catch (const std::exception& exception) { - std::cerr << "Exception caught: " << exception.what() << std::endl; - return 3; - } catch(...) { - std::cerr << "Unknown exception caught." << std::endl; - return 127; - } -} diff --git a/makefile b/makefile index 8bc92c0a69b14249472079d326845690c0789bdb..79a5b5abea0a8b048571e3ad82ccb1213d686df0 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,6 @@ SUBDIRS_LIBS = alib2std \ alib2data \ alib2data_experimental \ alib2str \ - alib2str_experimental \ alib2raw \ alib2aux \ alib2algo \