From 66ea16fb7528f5670ba08ad7327d435a5e8504ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20=C4=8Capek?= <tomas@capek.io>
Date: Wed, 11 Apr 2018 14:38:04 +0200
Subject: [PATCH] Implement WildcardLinearString.

---
 alib2data/src/string/StringClasses.h          |   1 +
 alib2data/src/string/StringFeatures.h         |   3 +
 alib2data/src/string/WildcardLinearString.cpp |  24 +
 alib2data/src/string/WildcardLinearString.h   | 486 ++++++++++++++++++
 .../src/string/xml/WildcardLinearString.cpp   |  23 +
 .../src/string/xml/WildcardLinearString.h     |  60 +++
 .../xml/common/StringFromXmlParserCommon.h    |  13 +
 .../xml/common/StringToXmlComposerCommon.h    |  11 +
 8 files changed, 621 insertions(+)
 create mode 100644 alib2data/src/string/WildcardLinearString.cpp
 create mode 100644 alib2data/src/string/WildcardLinearString.h
 create mode 100644 alib2data/src/string/xml/WildcardLinearString.cpp
 create mode 100644 alib2data/src/string/xml/WildcardLinearString.h

diff --git a/alib2data/src/string/StringClasses.h b/alib2data/src/string/StringClasses.h
index 364fd52ac5..6e82ce2a40 100644
--- a/alib2data/src/string/StringClasses.h
+++ b/alib2data/src/string/StringClasses.h
@@ -10,6 +10,7 @@
 
 #include "CyclicString.h"
 #include "LinearString.h"
+#include "WildcardLinearString.h"
 #include "Epsilon.h"
 
 #endif /* STRING_CLASSES_H_ */
diff --git a/alib2data/src/string/StringFeatures.h b/alib2data/src/string/StringFeatures.h
index 84bf5bf630..90887f534b 100644
--- a/alib2data/src/string/StringFeatures.h
+++ b/alib2data/src/string/StringFeatures.h
@@ -14,6 +14,7 @@ namespace string {
 
 enum class FEATURES {
 	LINEAR,
+	WILDCARD_LINEAR,
 	CYCLIC,
 	EPSILON
 };
@@ -26,6 +27,8 @@ class Epsilon;
 template < class SymbolType = DefaultSymbolType >
 class LinearString;
 template < class SymbolType = DefaultSymbolType >
+class WildcardLinearString;
+template < class SymbolType = DefaultSymbolType >
 class CyclicString;
 
 } /* namespace string */
diff --git a/alib2data/src/string/WildcardLinearString.cpp b/alib2data/src/string/WildcardLinearString.cpp
new file mode 100644
index 0000000000..72525adfe2
--- /dev/null
+++ b/alib2data/src/string/WildcardLinearString.cpp
@@ -0,0 +1,24 @@
+/*
+ * WildcardLinearString.cpp
+ *
+ *  Created on: Nov 23, 2013
+ *      Author: Jan Travnicek
+ */
+
+#include "WildcardLinearString.h"
+
+#include <registration/ValuePrinterRegistration.hpp>
+#include <registration/CastRegistration.hpp>
+#include <registration/ComponentRegistration.hpp>
+
+namespace {
+
+static auto components = registration::ComponentRegister < string::WildcardLinearString < > > ( );
+
+static auto WildcardLinearStringFromString = registration::CastRegister < string::WildcardLinearString < char >, std::string > ( );
+static auto WildcardLinearStringFromEpsilon = registration::CastRegister < string::WildcardLinearString < >, string::Epsilon < > > ( );
+static auto WildcardLinearStringFromLinearString = registration::CastRegister < string::WildcardLinearString < >, string::LinearString < > > ( );
+
+static auto valuePrinter = registration::ValuePrinterRegister < string::WildcardLinearString < > > ( );
+
+} /* namespace */
diff --git a/alib2data/src/string/WildcardLinearString.h b/alib2data/src/string/WildcardLinearString.h
new file mode 100644
index 0000000000..d6da8f7144
--- /dev/null
+++ b/alib2data/src/string/WildcardLinearString.h
@@ -0,0 +1,486 @@
+/*
+ * WildcardLinearString.h
+ *
+ *  Created on: 10. 4. 2018
+ *      Author: Tomas Capek
+ */
+
+#ifndef WILDCARD_LINEAR_STRING_H_
+#define WILDCARD_LINEAR_STRING_H_
+
+#include <alib/set>
+#include <alib/vector>
+#include <sstream>
+#include <alib/algorithm>
+
+#include <core/components.hpp>
+#include <object/UniqueObject.h>
+
+#include "StringBase.h"
+#include "StringFeatures.h"
+#include "LinearString.h"
+#include <exception/CommonException.h>
+#include <alphabet/common/SymbolNormalize.h>
+
+#include <alphabet/WildcardSymbol.h>
+
+#include <core/normalize.hpp>
+
+namespace string {
+
+class GeneralAlphabet;
+class WildcardSymbol;
+
+/**
+ * \brief
+ * Linear wildcard string.
+
+ * \details
+ * S = (A, C, W),
+ * A (Alphabet) = finite set of symbols,
+ * C (Content) = representation of the string content
+ * W (Wildcard symbol) = symbol representing an wildcard symbol
+ *
+ * \tparam SymbolType used for the terminal alphabet
+ */
+template < class SymbolType >
+class WildcardLinearString final : public StringBase, public core::Components < WildcardLinearString < SymbolType >, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, WildcardSymbol > {
+	/**
+	 * Representation of the string content.
+	 */
+	ext::vector < SymbolType > m_Data;
+
+public:
+
+	/**
+	 * \brief Creates a new instance of the string with a concrete alphabet, content and wildcard.
+	 *
+	 * \param alphabet the initial alphabet of the string
+	 * \param str the initial content of the string
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( ext::set < SymbolType > alphabet, ext::vector < SymbolType > str, SymbolType wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string based on content and the wildcard, the alphabet is implicitly created from the content.
+	 *
+	 * \param str the initial content of the string
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( ext::vector < SymbolType > str, SymbolType wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string from the standard string and the wildcard. The alphabet is deduced from the content. The constructor expects SymbolType of the string is constructible from char.
+	 *
+	 * \param str the initial content of the string
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( const std::string & st, char wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string from the standard string. The wildcard is defaultly constructed. The alphabet is deduced from the content. The constructor expects SymbolType of the string is constructible from char.
+	 *
+	 * \param str the initial content of the string
+	 */
+	explicit WildcardLinearString ( const std::string & st );
+
+	/**
+	 * \brief Creates a new instance of the string from c-string and the wildcard. The alphabet is deduced from the content. The constructor expects SymbolType of the string is constructible from char.
+	 *
+	 * \param str the initial content of the string
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( const char * str , char wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string based on an epsilon. It copies the alphabet and sets the content to empty. The wildcard is set from the the parametery.
+	 *
+	 * \param epsilon the epsilon to base the string on
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( const Epsilon < SymbolType > & epsilon, SymbolType wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string based on an epsilon. It copies the alphabet and sets the content to empty. The wildcard is defaultly constructed.
+	 *
+	 * \param epsilon the epsilon to base the string on
+	 */
+	explicit WildcardLinearString ( const Epsilon < SymbolType > & epsilon );
+
+	/**
+	 * \brief Creates a new instance of the string based on a linear string. It copies the alphabet and content. The wildcard is set from the the parametery.
+	 *
+	 * \param string the linear string to base the string on
+	 * \param wildcard the explicit wildcard symbol
+	 */
+	explicit WildcardLinearString ( const LinearString < SymbolType > & string, SymbolType wildcard );
+
+	/**
+	 * \brief Creates a new instance of the string based on a linear string. It copies the alphabet and content. The wildcard is defaultly constructed.
+	 *
+	 * \param string the linear string to base the string on
+	 */
+	explicit WildcardLinearString ( const LinearString < SymbolType > & string );
+
+	/**
+	 * @copydoc string::StringBase::clone()
+	 */
+	virtual StringBase * clone ( ) const & override;
+
+	/**
+	 * @copydoc string::StringBase::plunder()
+	 */
+	virtual StringBase * clone ( ) && override;
+
+	/**
+	 * Getter of the alphabet.
+	 *
+	 * \returns the alphabet of the string
+	 */
+	const ext::set < SymbolType > & getAlphabet ( ) const & {
+		return this->template accessComponent < GeneralAlphabet > ( ).get ( );
+	}
+
+	/**
+	 * Getter of the alphabet.
+	 *
+	 * \returns the alphabet of the string
+	 */
+	ext::set < SymbolType > && getAlphabet ( ) && {
+		return std::move ( this->template accessComponent < GeneralAlphabet > ( ).get ( ) );
+	}
+
+	/**
+	 * Adder of an alphabet symbols.
+	 *
+	 * \param symbols the new symbols to be added to the alphabet
+	 */
+	void extendAlphabet ( const ext::set < SymbolType > & symbols ) {
+		this->template accessComponent < GeneralAlphabet > ( ).add( symbols );
+	}
+
+	/**
+	 * Getter of the wildcard symbol
+	 *
+	 * \returns the wildcard symbol of the string
+	 */
+	const SymbolType & getWildcardSymbol ( ) const & {
+		return this->template accessComponent < WildcardSymbol > ( ).get ( );
+	}
+
+	/**
+	 * Getter of the wildcard symbol
+	 *
+	 * \returns the wildcard symbol of the string
+	 */
+	SymbolType && getWildcardSymbol ( ) && {
+		return std::move ( this->template accessComponent < WildcardSymbol > ( ).get ( ) );
+	}
+
+	/**
+	 * Setter of the wildcard symbol
+	 *
+	 * \param wildcard new wildcard symbol of the string
+	 *
+	 * \returns true if the wildcard symbol was indeed changed
+	 */
+	bool setWildcardSymbol ( SymbolType wildcard ) {
+		return this-> template accessComponent < WildcardSymbol > ( ).set ( std::move ( wildcard ) );
+	}
+
+	/**
+	 * Appender of a symbol to the string.
+	 *
+	 * \param symbol the symbol to be added to the end of the string
+	 */
+	void appendSymbol ( SymbolType symbol );
+
+	/**
+	 * Getter of the string content.
+	 *
+	 * \return List of symbols forming string.
+	 */
+	const ext::vector < SymbolType > & getContent ( ) const &;
+
+	/**
+	 * Getter of the string content.
+	 *
+	 * \return List of symbols forming string.
+	 */
+	ext::vector < SymbolType > && getContent ( ) &&;
+
+	/**
+	 * Setter of the string content.
+	 *
+	 * \throws CommonException when new string contains symbols not present in the alphabet
+	 *
+	 * \param new List of symbols forming string.
+	 */
+	void setContent ( ext::vector < SymbolType > str );
+
+	/**
+	 * Test function to determine whether the cyclic string is empty
+	 *
+	 * \return true if string is an empty word (vector length is 0)
+	 */
+	bool isEmpty ( ) const;
+
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::compare ( const ObjectBase & )
+	 */
+	virtual int compare ( const ObjectBase & other ) const override {
+		if ( ext::type_index ( typeid ( * this ) ) == ext::type_index ( typeid ( other ) ) ) return this->compare ( ( decltype ( * this ) )other );
+
+		return ext::type_index ( typeid ( * this ) ) - ext::type_index ( typeid ( other ) );
+	}
+
+	/**
+	 * The actual compare method
+	 *
+	 * \param other the other instance
+	 *
+	 * \returns the actual relation between two by type same string instances
+	 */
+	int compare ( const WildcardLinearString & other ) const;
+
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator >> ( std::ostream & )
+	 */
+	virtual void operator >>( std::ostream & out ) const override;
+
+	/**
+	 * @copydoc alib::CommonBase<ObjectBase>::operator std::string ( )
+	 */
+	virtual explicit operator std::string ( ) const override;
+
+	/**
+	 * @copydoc alib::ObjectBase::inc()
+	 */
+	virtual object::ObjectBase * inc ( ) && override;
+
+};
+
+} /* namespace string */
+
+#include "Epsilon.h"
+
+namespace string {
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(ext::set<SymbolType> alphabet, ext::vector<SymbolType> str, SymbolType wildcard) : core::Components < WildcardLinearString, ext::set < SymbolType >, component::Set, GeneralAlphabet, SymbolType, component::Value, WildcardSymbol > ( std::move ( alphabet ), std::move(wildcard) ) {
+	setContent(std::move(str));
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(ext::vector<SymbolType> str, SymbolType wildcard) : WildcardLinearString ( ext::set < SymbolType > ( str.begin(), str.end() ) + ext::set < SymbolType > { wildcard }, str, wildcard ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const std::string & str, char wildcard) : WildcardLinearString ( ext::vector < SymbolType > ( str.begin ( ), str.end ( ) ), wildcard ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const std::string & str) : WildcardLinearString ( str, alphabet::WildcardSymbol::instance < char > ( ) ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const char* str, char wildcard) : WildcardLinearString ( ( std::string ) str, wildcard ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const Epsilon < SymbolType > & epsilon, SymbolType wildcard) : WildcardLinearString ( epsilon.getAlphabet( ) + ext::set < SymbolType > { wildcard }, ext::vector < SymbolType > ( ), wildcard ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const Epsilon < SymbolType > & epsilon ) : WildcardLinearString ( epsilon, alphabet::WildcardSymbol::instance < SymbolType > ( ) ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const LinearString < SymbolType > & string, SymbolType wildcard) : WildcardLinearString ( string.getAlphabet( ) + ext::set < SymbolType > { wildcard }, string.getContent ( ), wildcard ) {
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::WildcardLinearString(const LinearString < SymbolType > & string) : WildcardLinearString ( string, alphabet::WildcardSymbol::instance < SymbolType > ( ) ) {
+}
+
+template < class SymbolType >
+StringBase * WildcardLinearString < SymbolType >::clone ( ) const & {
+	return new WildcardLinearString ( * this );
+}
+
+template < class SymbolType >
+StringBase * WildcardLinearString < SymbolType >::clone ( ) && {
+	return new WildcardLinearString ( std::move ( * this ) );
+}
+
+template < class SymbolType >
+void WildcardLinearString < SymbolType >::appendSymbol ( SymbolType symbol ) {
+	if ( getAlphabet().count ( symbol ) == 0 )
+		throw exception::CommonException ( "Input symbol \"" + ext::to_string ( symbol ) + "\" not in the alphabet." );
+
+	m_Data.push_back ( std::move ( symbol ) );
+}
+
+template < class SymbolType >
+const ext::vector < SymbolType > & WildcardLinearString < SymbolType >::getContent ( ) const & {
+	return this->m_Data;
+}
+
+template < class SymbolType >
+ext::vector < SymbolType > && WildcardLinearString < SymbolType >::getContent ( ) && {
+	return std::move ( this->m_Data );
+}
+
+template < class SymbolType >
+void WildcardLinearString < SymbolType >::setContent ( ext::vector < SymbolType > str ) {
+	ext::set < SymbolType > minimalAlphabet ( str.begin ( ), str.end ( ) );
+	ext::set < SymbolType > unknownSymbols;
+	std::set_difference ( minimalAlphabet.begin ( ), minimalAlphabet.end ( ), getAlphabet().begin ( ), getAlphabet().end ( ), std::inserter ( unknownSymbols, unknownSymbols.end ( ) ) );
+
+	if ( unknownSymbols.size ( ) > 0 )
+		throw exception::CommonException ( "Input symbols not in the alphabet." );
+
+	this->m_Data = std::move ( str );
+}
+
+template < class SymbolType >
+bool WildcardLinearString < SymbolType >::isEmpty ( ) const {
+	return this->m_Data.size ( ) == 0;
+}
+
+template < class SymbolType >
+int WildcardLinearString < SymbolType >::compare ( const WildcardLinearString & other ) const {
+	auto first = ext::tie ( m_Data, getAlphabet ( ), getWildcardSymbol ( ) );
+	auto second = ext::tie ( other.m_Data, other.getAlphabet ( ), other.getWildcardSymbol ( ) );
+
+	static ext::compare < decltype ( first ) > comp;
+
+	return comp ( first, second );
+}
+
+template < class SymbolType >
+void WildcardLinearString < SymbolType >::operator >>( std::ostream & out ) const {
+	out << "(WildcardLinearString string: ";
+
+	for ( const SymbolType & symbol : this->m_Data )
+		out << symbol;
+
+	out << ", wildcard: " << this->getWildcardSymbol ( );
+
+	out << ")";
+}
+
+template < class SymbolType >
+WildcardLinearString < SymbolType >::operator std::string ( ) const {
+	std::stringstream ss;
+	ss << "\"";
+
+	for ( const SymbolType & symbol : this->m_Data )
+		ss << symbol;
+
+	ss << "\"";
+	return std::move ( ss ).str ( );
+}
+
+// what is this?
+template < class SymbolType >
+object::ObjectBase* WildcardLinearString < SymbolType >::inc() && {
+	return new object::UniqueObject(object::Object(std::move(*this)), primitive::Integer(0));
+}
+
+} /* namespace string */
+
+namespace core {
+
+/**
+ * Helper class specifying constraints for the string's internal alphabet component.
+ *
+ * \tparam SymbolType used for the alphabet of the string.
+ */
+template < class SymbolType >
+class SetConstraint< string::WildcardLinearString < SymbolType >, SymbolType, string::GeneralAlphabet > {
+public:
+	/**
+	 * Returns true if the symbol is still used in the string.
+	 *
+	 * \param string the tested string
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true if the symbol is used, false othervise
+	 */
+	static bool used ( const string::WildcardLinearString < SymbolType > & str, const SymbolType & symbol ) {
+		const ext::vector<SymbolType>& content = str.getContent ( );
+		return std::find(content.begin(), content.end(), symbol) != content.end();
+	}
+
+	/**
+	 * Returns true as all symbols are possibly available to be in an alphabet.
+	 *
+	 * \param string the tested string
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true
+	 */
+	static bool available ( const string::WildcardLinearString < SymbolType > &, const SymbolType & ) {
+		return true;
+	}
+
+	/**
+	 * All symbols are valid as symbols of an alphabet.
+	 *
+	 * \param string the tested string
+	 * \param symbol the tested symbol
+	 */
+	static void valid ( const string::WildcardLinearString < SymbolType > &, const SymbolType & ) {
+	}
+};
+
+/**
+ * Helper class specifying constraints for the string's internal wildcard element.
+ *
+ * \tparam SymbolType used for the alphabet of the string.
+ */
+template<class SymbolType >
+class ElementConstraint< string::WildcardLinearString < SymbolType >, SymbolType, string::WildcardSymbol > {
+public:
+	/**
+	 * Determines whether the symbol is available in the string's alphabet.
+	 *
+	 * \param string the tested string
+	 * \param symbol the tested symbol
+	 *
+	 * \returns true if the symbol is already in the alphabet of the string
+	 */
+	static bool available ( const string::WildcardLinearString < SymbolType > & string, const SymbolType & symbol ) {
+		return string.getAlphabet ( ).count ( symbol );
+	}
+
+	/**
+	 * All symbols are valid as an initial sildcard symbol of the string.
+	 *
+	 * \param string the tested string
+	 * \param symbol the tested symbol
+	 */
+	static void valid ( const string::WildcardLinearString < SymbolType > &, const SymbolType & ) {
+	}
+
+};
+
+/**
+ * Helper for normalisation of types specified by templates used as internal datatypes of symbols.
+ *
+ * \returns new instance of the string with default template parameters or unmodified instance if the template parameters were already default ones
+ */
+template < class SymbolType >
+struct normalize < string::WildcardLinearString < SymbolType > > {
+	static string::WildcardLinearString < > eval ( string::WildcardLinearString < SymbolType > && value ) {
+		ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getAlphabet ( ) );
+		ext::vector < DefaultSymbolType > content = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( value ).getContent ( ) );
+		DefaultSymbolType wildcard = alphabet::SymbolNormalize::normalizeSymbol ( std::move ( value ).getWildcardSymbol ( ) );
+		return string::WildcardLinearString < > ( std::move ( alphabet ), std::move ( content ), std::move ( wildcard ) );
+	}
+};
+
+} /* namespace core */
+
+#endif /* WILDCARD_LINEAR_STRING_H_ */
diff --git a/alib2data/src/string/xml/WildcardLinearString.cpp b/alib2data/src/string/xml/WildcardLinearString.cpp
new file mode 100644
index 0000000000..6ddd1b0c4f
--- /dev/null
+++ b/alib2data/src/string/xml/WildcardLinearString.cpp
@@ -0,0 +1,23 @@
+/*
+ * WildcardLinearString.cpp
+ *
+ *  Created on: Apr 12, 2018
+ *      Author: Jan Travnicek
+ */
+
+#include "WildcardLinearString.h"
+
+#include <string/String.h>
+#include <object/Object.h>
+
+#include <registration/XmlRegistration.hpp>
+
+namespace {
+
+static auto xmlWrite = registration::XmlWriterRegister < string::WildcardLinearString < > > ( );
+static auto xmlRead = registration::XmlReaderRegister < string::WildcardLinearString < > > ( );
+
+static auto xmlGroup1 = registration::XmlRegisterTypeInGroup < string::String, string::WildcardLinearString < > > ( );
+static auto xmlGroup2 = registration::XmlRegisterTypeInGroup < object::Object, string::WildcardLinearString < > > ( );
+
+} /* namespace */
diff --git a/alib2data/src/string/xml/WildcardLinearString.h b/alib2data/src/string/xml/WildcardLinearString.h
new file mode 100644
index 0000000000..8df45f92e1
--- /dev/null
+++ b/alib2data/src/string/xml/WildcardLinearString.h
@@ -0,0 +1,60 @@
+/*
+ * WildcardLinearString.h
+ *
+ * Created on: Apr 12, 2018
+ * Author: Jan Travnicek
+ */
+
+#ifndef _XML_WILDCARD_LINEAR_STRING_H_
+#define _XML_WILDCARD_LINEAR_STRING_H_
+
+#include <string/WildcardLinearString.h>
+#include <core/xmlApi.hpp>
+
+#include <string/xml/common/StringFromXmlParserCommon.h>
+#include <string/xml/common/StringToXmlComposerCommon.h>
+
+namespace core {
+
+template < typename SymbolType >
+struct xmlApi < string::WildcardLinearString < SymbolType > > {
+	static string::WildcardLinearString < SymbolType > parse ( ext::deque < sax::Token >::iterator & input );
+	static bool first ( const ext::deque < sax::Token >::const_iterator & input );
+	static const std::string & xmlTagName ( );
+	static void compose ( ext::deque < sax::Token > & output, const string::WildcardLinearString < SymbolType > & data );
+};
+
+template < typename SymbolType >
+string::WildcardLinearString < SymbolType > xmlApi < string::WildcardLinearString < SymbolType > >::parse ( ext::deque < sax::Token >::iterator & input ) {
+	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) );
+	ext::set<SymbolType> alphabet = string::StringFromXmlParserCommon::parseAlphabet < SymbolType > ( input );
+	ext::vector<SymbolType> content = string::StringFromXmlParserCommon::parseContent < SymbolType > ( input );
+	SymbolType wildcard = string::StringFromXmlParserCommon::parseWildcard < SymbolType > ( input );
+	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, xmlTagName ( ) );
+	return string::WildcardLinearString < SymbolType > ( std::move ( alphabet ), std::move ( content ), std::move ( wildcard ) );
+}
+
+template < typename SymbolType >
+bool xmlApi < string::WildcardLinearString < SymbolType > >::first ( const ext::deque < sax::Token >::const_iterator & input ) {
+	return sax::FromXMLParserHelper::isToken ( input, sax::Token::TokenType::START_ELEMENT, xmlTagName ( ) );
+}
+
+template < typename SymbolType >
+const std::string & xmlApi < string::WildcardLinearString < SymbolType > >::xmlTagName ( ) {
+	static std::string xmlTagName = "WildcardLinearString";
+
+	return xmlTagName;
+}
+
+template < typename SymbolType >
+void xmlApi < string::WildcardLinearString < SymbolType > >::compose ( ext::deque < sax::Token > & output, const string::WildcardLinearString < SymbolType > & input ) {
+	output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::START_ELEMENT );
+	string::StringToXmlComposerCommon::compose ( output, input.getAlphabet ( ) );
+	string::StringToXmlComposerCommon::compose ( output, input.getContent ( ) );
+	string::StringToXmlComposerCommon::compose ( output, input.getWildcardSymbol ( ) );
+	output.emplace_back ( xmlTagName ( ), sax::Token::TokenType::END_ELEMENT );
+}
+
+} /* namespace core */
+
+#endif /* _XML_WILDCARD_LINEAR_STRING_H_ */
diff --git a/alib2data/src/string/xml/common/StringFromXmlParserCommon.h b/alib2data/src/string/xml/common/StringFromXmlParserCommon.h
index 68074739dc..140da244e7 100644
--- a/alib2data/src/string/xml/common/StringFromXmlParserCommon.h
+++ b/alib2data/src/string/xml/common/StringFromXmlParserCommon.h
@@ -26,6 +26,8 @@ public:
 	static ext::vector < SymbolType > parseContent ( ext::deque < sax::Token >::iterator & input );
 	template < class SymbolType >
 	static ext::set < SymbolType > parseAlphabet ( ext::deque < sax::Token >::iterator & input );
+	template < class SymbolType >
+	static SymbolType parseWildcard ( ext::deque < sax::Token >::iterator & input );
 };
 
 template < class SymbolType >
@@ -56,6 +58,17 @@ ext::vector < SymbolType > StringFromXmlParserCommon::parseContent ( ext::deque
 	return data;
 }
 
+template < class SymbolType >
+SymbolType StringFromXmlParserCommon::parseWildcard ( ext::deque < sax::Token >::iterator & input ) {
+	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::START_ELEMENT, "wildcard" );
+
+	SymbolType wildcard = core::xmlApi < SymbolType >::parse ( input );
+
+	sax::FromXMLParserHelper::popToken ( input, sax::Token::TokenType::END_ELEMENT, "wildcard" );
+
+	return wildcard;
+}
+
 } /* namespace string */
 
 #endif /* STRING_FROM_XML_PARSER_COMMON_H_ */
diff --git a/alib2data/src/string/xml/common/StringToXmlComposerCommon.h b/alib2data/src/string/xml/common/StringToXmlComposerCommon.h
index a2d7856593..104c41062a 100644
--- a/alib2data/src/string/xml/common/StringToXmlComposerCommon.h
+++ b/alib2data/src/string/xml/common/StringToXmlComposerCommon.h
@@ -25,6 +25,8 @@ public:
 	static void compose ( ext::deque < sax::Token > & out, const ext::set < SymbolType > & alphabet );
 	template < class SymbolType >
 	static void compose ( ext::deque < sax::Token > & out, const ext::vector < SymbolType > & content );
+	template < class SymbolType >
+	static void compose ( ext::deque < sax::Token > & out, const SymbolType & wildcard );
 };
 
 template < class SymbolType >
@@ -47,6 +49,15 @@ void StringToXmlComposerCommon::compose(ext::deque<sax::Token>& out, const ext::
 	out.emplace_back ( "content", sax::Token::TokenType::END_ELEMENT );
 }
 
+template < class SymbolType >
+void StringToXmlComposerCommon::compose(ext::deque<sax::Token>& out, const SymbolType & wildcard ) {
+	out.emplace_back ( "wildcard", sax::Token::TokenType::START_ELEMENT );
+
+	core::xmlApi < SymbolType >::compose ( out, wildcard );
+
+	out.emplace_back ( "wildcard", sax::Token::TokenType::END_ELEMENT );
+}
+
 } /* namespace string */
 
 #endif /* STRING_TO_XML_COMPOSER_COMMON_H_ */
-- 
GitLab