From eb4600b58d79fda9572bbc860044c711cfd01509 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Wed, 10 Jun 2015 20:13:22 +0200
Subject: [PATCH] simplify includes in regexps

---
 acast2/src/cast/RegExpCastVisitor.cpp         |  2 ++
 .../transform/RegExpConcatenateTest.cpp       |  1 +
 alib2data/src/XmlApi.cpp                      |  1 +
 alib2data/src/object/ObjectBase.h             |  9 +-------
 alib2data/src/regexp/RegExp.h                 | 14 ++++++++++-
 alib2data/src/regexp/RegExpAlphabetGetter.cpp |  2 ++
 alib2data/src/regexp/RegExpAlphabetGetter.h   |  4 +---
 alib2data/src/regexp/RegExpClasses.h          | 14 +++++++++++
 alib2data/src/regexp/RegExpFeatures.h         | 23 +++++++++++++++++++
 alib2data/src/regexp/RegExpFromStringLexer.h  |  2 +-
 .../src/regexp/RegExpFromStringParser.cpp     |  8 +++----
 alib2data/src/regexp/RegExpFromStringParser.h |  8 +++----
 alib2data/src/regexp/RegExpFromXMLParser.cpp  |  7 +++++-
 alib2data/src/regexp/RegExpFromXMLParser.h    |  8 +------
 .../src/regexp/RegExpToStringComposer.cpp     |  8 ++++---
 alib2data/src/regexp/RegExpToStringComposer.h |  4 ++--
 alib2data/src/regexp/RegExpToXMLComposer.cpp  |  6 ++++-
 alib2data/src/regexp/RegExpToXMLComposer.h    |  4 ++--
 alib2data/src/string/StringAlphabetGetter.cpp |  4 +---
 .../src/string/StringFromStringParser.cpp     |  4 +---
 alib2data/test-src/regexp/RegExpTest.cpp      |  2 ++
 21 files changed, 91 insertions(+), 44 deletions(-)
 create mode 100644 alib2data/src/regexp/RegExpClasses.h

diff --git a/acast2/src/cast/RegExpCastVisitor.cpp b/acast2/src/cast/RegExpCastVisitor.cpp
index 262af9adac..f09cc12843 100644
--- a/acast2/src/cast/RegExpCastVisitor.cpp
+++ b/acast2/src/cast/RegExpCastVisitor.cpp
@@ -6,6 +6,8 @@
  */
 
 #include "RegExpCastVisitor.h"
+#include "regexp/RegExpClasses.h"
+
 #include "../CastVisitorBase.hpp"
 
 typedef cast_base_helper< regexp::VisitableRegExpBase::const_visitor_type, regexp::RegExpBase, alib::RegExpTypes, regexp::RegExp, alib::RegExpTypes > RegExpCastVisitorType;
diff --git a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
index 2537ba7a67..d50d8d4079 100644
--- a/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
+++ b/alib2algo/test-src/regexp/transform/RegExpConcatenateTest.cpp
@@ -3,6 +3,7 @@
 #include "regexp/transform/RegExpConcatenate.h"
 
 #include <regexp/RegExp.h>
+#include <regexp/formal/FormalRegExpElements.h>
 
 #include <factory/StringDataFactory.hpp>
 
diff --git a/alib2data/src/XmlApi.cpp b/alib2data/src/XmlApi.cpp
index 5c1f6c80dd..a1b1060270 100644
--- a/alib2data/src/XmlApi.cpp
+++ b/alib2data/src/XmlApi.cpp
@@ -16,6 +16,7 @@
 #include "automaton/AutomatonClasses.h"
 #include "container/ContainerClasses.h"
 #include "grammar/GrammarClasses.h"
+#include "regexp/RegExpClasses.h"
 
 namespace alib {
 
diff --git a/alib2data/src/object/ObjectBase.h b/alib2data/src/object/ObjectBase.h
index 24ca799a4f..2af6fb36da 100644
--- a/alib2data/src/object/ObjectBase.h
+++ b/alib2data/src/object/ObjectBase.h
@@ -28,14 +28,7 @@ class UndirectedGraph;
 }
 
 #include "../label/LabelFeatures.h"
-
-namespace regexp {
-
-class UnboundedRegExp;
-class FormalRegExp;
-
-}
-
+#include "../regexp/RegExpFeatures.h"
 #include "../string/StringFeatures.h"
 #include "../alphabet/SymbolFeatures.h"
 #include "../container/ContainerFeatures.h"
diff --git a/alib2data/src/regexp/RegExp.h b/alib2data/src/regexp/RegExp.h
index f36003ba6a..7fc0106986 100644
--- a/alib2data/src/regexp/RegExp.h
+++ b/alib2data/src/regexp/RegExp.h
@@ -10,6 +10,7 @@
 
 #include "../common/wrapper.hpp"
 #include "RegExpBase.h"
+
 #include "../alphabet/Symbol.h"
 #include "../string/LinearString.h"
 #include <string>
@@ -19,7 +20,18 @@ namespace regexp {
 /**
  * Wrapper around automata.
  */
-typedef alib::wrapper<RegExpBase> RegExp;
+class RegExp : public alib::wrapper<RegExpBase> {
+public:
+	explicit RegExp(RegExpBase* data) : alib::wrapper<RegExpBase>(data) {
+	}
+
+	explicit RegExp(const RegExpBase& data) : alib::wrapper<RegExpBase>(data.clone()) {
+	}
+
+	explicit RegExp(RegExpBase&& data) : alib::wrapper<RegExpBase>(std::move(data).plunder()) {
+	}
+
+};
 
 regexp::RegExp regexpFrom( const std::string& string );
 
diff --git a/alib2data/src/regexp/RegExpAlphabetGetter.cpp b/alib2data/src/regexp/RegExpAlphabetGetter.cpp
index bfe71ea9af..02cbc4c8d8 100644
--- a/alib2data/src/regexp/RegExpAlphabetGetter.cpp
+++ b/alib2data/src/regexp/RegExpAlphabetGetter.cpp
@@ -6,6 +6,8 @@
  */
 
 #include "RegExpAlphabetGetter.h"
+#include "RegExp.h"
+#include "RegExpClasses.h"
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpAlphabetGetter.h b/alib2data/src/regexp/RegExpAlphabetGetter.h
index e7e83eb2c6..49d570c59a 100644
--- a/alib2data/src/regexp/RegExpAlphabetGetter.h
+++ b/alib2data/src/regexp/RegExpAlphabetGetter.h
@@ -8,11 +8,9 @@
 #ifndef REG_EXP_ALPHABET_GETTER_H_
 #define REG_EXP_ALPHABET_GETTER_H_
 
+#include "RegExpBase.h"
 #include <set>
-#include "RegExp.h"
 #include "../alphabet/Symbol.h"
-#include "unbounded/UnboundedRegExp.h"
-#include "formal/FormalRegExp.h"
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpClasses.h b/alib2data/src/regexp/RegExpClasses.h
new file mode 100644
index 0000000000..aa1167ac9e
--- /dev/null
+++ b/alib2data/src/regexp/RegExpClasses.h
@@ -0,0 +1,14 @@
+/*
+ * RegExpClasses.h
+ *
+ *  Created on: Jun 19, 2014
+ *      Author: Jan Travnicek
+ */
+
+#ifndef REG_EXP_CLASSES_H_
+#define REG_EXP_CLASSES_H_
+
+#include "unbounded/UnboundedRegExp.h"
+#include "formal/FormalRegExp.h"
+
+#endif /* REG_EXP_CLASSES_H_ */
diff --git a/alib2data/src/regexp/RegExpFeatures.h b/alib2data/src/regexp/RegExpFeatures.h
index 0cf15f29bd..71d3d5e687 100644
--- a/alib2data/src/regexp/RegExpFeatures.h
+++ b/alib2data/src/regexp/RegExpFeatures.h
@@ -15,6 +15,29 @@ enum class FEATURES {
 	UNBOUNDED
 };
 
+class RegExp;
+
+class UnboundedRegExp;
+
+class UnboundedRegExpElement;
+class UnboundedRegExpAlternation;
+class UnboundedRegExpConcatenation;
+class UnboundedRegExpIteration;
+class UnboundedRegExpSymbol;
+class UnboundedRegExpEmpty;
+class UnboundedRegExpEpsilon;
+
+
+class FormalRegExp;
+
+class FormalRegExpElement;
+class FormalRegExpAlternation;
+class FormalRegExpConcatenation;
+class FormalRegExpIteration;
+class FormalRegExpSymbol;
+class FormalRegExpEmpty;
+class FormalRegExpEpsilon;
+
 } /* namespace regexp */
 
 #endif /* REG_EXP_FEATURES_H_ */
diff --git a/alib2data/src/regexp/RegExpFromStringLexer.h b/alib2data/src/regexp/RegExpFromStringLexer.h
index 748c3fca7e..8697d19c73 100644
--- a/alib2data/src/regexp/RegExpFromStringLexer.h
+++ b/alib2data/src/regexp/RegExpFromStringLexer.h
@@ -9,7 +9,7 @@
 #define REG_EXP_FROM_STRING_LEXER_H_
 
 #include <string>
-#include <sstream>
+#include <istream>
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpFromStringParser.cpp b/alib2data/src/regexp/RegExpFromStringParser.cpp
index c525ea9123..8eca7ff088 100644
--- a/alib2data/src/regexp/RegExpFromStringParser.cpp
+++ b/alib2data/src/regexp/RegExpFromStringParser.cpp
@@ -6,13 +6,13 @@
  */
 
 #include "RegExpFromStringParser.h"
-#include "../sax/ParserException.h"
 #include "../exception/AlibException.h"
+#include "RegExpClasses.h"
 
-#include "../StringApi.hpp"
+#include "unbounded/UnboundedRegExpElements.h"
+#include "formal/FormalRegExpElements.h"
 
-#include "unbounded/UnboundedRegExp.h"
-#include "formal/FormalRegExp.h"
+#include "../StringApi.hpp"
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpFromStringParser.h b/alib2data/src/regexp/RegExpFromStringParser.h
index 962595375e..b98d6f6741 100644
--- a/alib2data/src/regexp/RegExpFromStringParser.h
+++ b/alib2data/src/regexp/RegExpFromStringParser.h
@@ -8,12 +8,10 @@
 #ifndef REG_EXP_FROM_STRING_PARSER_H_
 #define REG_EXP_FROM_STRING_PARSER_H_
 
-#include "RegExp.h"
-#include "unbounded/UnboundedRegExpElements.h"
-#include "formal/FormalRegExpElements.h"
-
-#include "RegExpFromStringLexer.h"
 #include "RegExpFeatures.h"
+#include "RegExpFromStringLexer.h"
+
+#include <set>
 
 namespace alib {
 
diff --git a/alib2data/src/regexp/RegExpFromXMLParser.cpp b/alib2data/src/regexp/RegExpFromXMLParser.cpp
index 73462bd934..0924675f56 100644
--- a/alib2data/src/regexp/RegExpFromXMLParser.cpp
+++ b/alib2data/src/regexp/RegExpFromXMLParser.cpp
@@ -7,9 +7,14 @@
 
 #include "RegExpFromXMLParser.h"
 #include "../sax/ParserException.h"
-
 #include "../XmlApi.hpp"
 
+#include "RegExp.h"
+#include "RegExpClasses.h"
+
+#include "unbounded/UnboundedRegExpElements.h"
+#include "formal/FormalRegExpElements.h"
+
 namespace regexp {
 
 RegExp RegExpFromXMLParser::parseRegExp(std::deque<sax::Token>::iterator& input) const {
diff --git a/alib2data/src/regexp/RegExpFromXMLParser.h b/alib2data/src/regexp/RegExpFromXMLParser.h
index 16811c9b90..b4669a96af 100644
--- a/alib2data/src/regexp/RegExpFromXMLParser.h
+++ b/alib2data/src/regexp/RegExpFromXMLParser.h
@@ -9,14 +9,8 @@
 #define REG_EXP_FROM_XML_PARSER_H_
 
 #include "../sax/FromXMLParserHelper.h"
-#include "RegExp.h"
+#include <set>
 #include "RegExpFeatures.h"
-#include "unbounded/UnboundedRegExp.h"
-#include "unbounded/UnboundedRegExpElements.h"
-#include "formal/FormalRegExp.h"
-#include "formal/FormalRegExpElements.h"
-#include "../sax/Token.h"
-#include "../alphabet/Symbol.h"
 
 namespace alib {
 
diff --git a/alib2data/src/regexp/RegExpToStringComposer.cpp b/alib2data/src/regexp/RegExpToStringComposer.cpp
index 310ac72aa8..b9883a0c2d 100644
--- a/alib2data/src/regexp/RegExpToStringComposer.cpp
+++ b/alib2data/src/regexp/RegExpToStringComposer.cpp
@@ -5,11 +5,13 @@
  *      Author: Martin Zak
  */
 
-#include <algorithm>
 #include "RegExpToStringComposer.h"
+#include "RegExpClasses.h"
+
+#include "unbounded/UnboundedRegExpElements.h"
+#include "formal/FormalRegExpElements.h"
+
 #include "../StringApi.hpp"
-#include "unbounded/UnboundedRegExp.h"
-#include "formal/FormalRegExp.h"
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpToStringComposer.h b/alib2data/src/regexp/RegExpToStringComposer.h
index 18d4b5c5cc..959404e202 100644
--- a/alib2data/src/regexp/RegExpToStringComposer.h
+++ b/alib2data/src/regexp/RegExpToStringComposer.h
@@ -10,8 +10,8 @@
 
 #include <string>
 #include "RegExp.h"
-#include "unbounded/UnboundedRegExpElements.h"
-#include "formal/FormalRegExpElements.h"
+#include "unbounded/UnboundedRegExpElement.h"
+#include "formal/FormalRegExpElement.h"
 
 namespace regexp {
 
diff --git a/alib2data/src/regexp/RegExpToXMLComposer.cpp b/alib2data/src/regexp/RegExpToXMLComposer.cpp
index 9f5175893a..3d76f27050 100644
--- a/alib2data/src/regexp/RegExpToXMLComposer.cpp
+++ b/alib2data/src/regexp/RegExpToXMLComposer.cpp
@@ -6,9 +6,13 @@
  */
 
 #include "RegExpToXMLComposer.h"
-
 #include "../XmlApi.hpp"
 
+#include "RegExpClasses.h"
+
+#include "unbounded/UnboundedRegExpElements.h"
+#include "formal/FormalRegExpElements.h"
+
 namespace regexp {
 
 void RegExpToXMLComposer::Visit(void* userData, const UnboundedRegExpAlternation& alternation) const {
diff --git a/alib2data/src/regexp/RegExpToXMLComposer.h b/alib2data/src/regexp/RegExpToXMLComposer.h
index 815706e63b..314cf322ef 100644
--- a/alib2data/src/regexp/RegExpToXMLComposer.h
+++ b/alib2data/src/regexp/RegExpToXMLComposer.h
@@ -10,8 +10,8 @@
 
 #include <deque>
 #include "RegExp.h"
-#include "unbounded/UnboundedRegExpElements.h"
-#include "formal/FormalRegExpElements.h"
+#include "unbounded/UnboundedRegExpElement.h"
+#include "formal/FormalRegExpElement.h"
 #include "../sax/Token.h"
 
 namespace alib {
diff --git a/alib2data/src/string/StringAlphabetGetter.cpp b/alib2data/src/string/StringAlphabetGetter.cpp
index 0061bfbf43..4e1c718a16 100644
--- a/alib2data/src/string/StringAlphabetGetter.cpp
+++ b/alib2data/src/string/StringAlphabetGetter.cpp
@@ -7,9 +7,7 @@
 
 #include "StringAlphabetGetter.h"
 #include "String.h"
-#include "Epsilon.h"
-#include "LinearString.h"
-#include "CyclicString.h"
+#include "StringClasses.h"
 
 namespace string {
 
diff --git a/alib2data/src/string/StringFromStringParser.cpp b/alib2data/src/string/StringFromStringParser.cpp
index a86d81be4c..008f4048ea 100644
--- a/alib2data/src/string/StringFromStringParser.cpp
+++ b/alib2data/src/string/StringFromStringParser.cpp
@@ -7,9 +7,7 @@
 
 #include "StringFromStringParser.h"
 #include "../exception/AlibException.h"
-#include "Epsilon.h"
-#include "LinearString.h"
-#include "CyclicString.h"
+#include "StringClasses.h"
 #include <vector>
 
 #include "../StringApi.hpp"
diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp
index c0e00ceedc..b450ffab75 100644
--- a/alib2data/test-src/regexp/RegExpTest.cpp
+++ b/alib2data/test-src/regexp/RegExpTest.cpp
@@ -5,7 +5,9 @@
 #include "sax/SaxComposeInterface.h"
 
 #include "regexp/unbounded/UnboundedRegExp.h"
+#include "regexp/unbounded/UnboundedRegExpElements.h"
 #include "regexp/formal/FormalRegExp.h"
+#include "regexp/formal/FormalRegExpElements.h"
 
 #include "factory/XmlDataFactory.hpp"
 #include "factory/StringDataFactory.hpp"
-- 
GitLab