From 4b0e23f4cb4662b6a929a4b2346016875cfd8f84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Pecka?= <peckato1@fit.cvut.cz>
Date: Sat, 22 Feb 2014 20:49:29 +0100
Subject: [PATCH] aLib: RegExp - method to check if regexp describes empty
 language

---
 alib/src/regexp/RegExp.cpp | 4 ++++
 alib/src/regexp/RegExp.h   | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/alib/src/regexp/RegExp.cpp b/alib/src/regexp/RegExp.cpp
index 5730a96c30..b35657c0d9 100644
--- a/alib/src/regexp/RegExp.cpp
+++ b/alib/src/regexp/RegExp.cpp
@@ -70,6 +70,10 @@ void RegExp::setRegExp(RegExpElement* regExp) {
 	this->regExp = regExp;
 }
 
+bool RegExp::isEmpty() const {
+	return regExp == NULL || dynamic_cast<const RegExpEmpty*>(regExp);
+}
+
 void RegExp::toXML(ostream& out) {
 	RegExpPrinter::toXML(*this, out);
 }
diff --git a/alib/src/regexp/RegExp.h b/alib/src/regexp/RegExp.h
index 19f25308bc..e31198ae94 100644
--- a/alib/src/regexp/RegExp.h
+++ b/alib/src/regexp/RegExp.h
@@ -55,6 +55,11 @@ public:
 	 */
 	void setRegExp(RegExpElement* regExp);
 
+	/**
+	 * @return true if regexp represents empty language
+	 */
+	bool isEmpty() const;
+
 	/**
 	 * Prints XML representation of the RegExp to the output stream.
 	 * @param out output stream to which print the RegExp
-- 
GitLab