瀏覽代碼

Remove handling of data binding in xml parser

Michael Ragazzon 6 年之前
父節點
當前提交
8fdcf5aab0
共有 4 個文件被更改,包括 0 次插入64 次删除
  1. 0 5
      Include/RmlUi/Core/Factory.h
  2. 0 11
      Include/RmlUi/Core/XMLParser.h
  3. 0 22
      Source/Core/Factory.cpp
  4. 0 26
      Source/Core/XMLParser.cpp

+ 0 - 5
Include/RmlUi/Core/Factory.h

@@ -42,7 +42,6 @@ class DecoratorInstancer;
 class Element;
 class Element;
 class ElementDocument;
 class ElementDocument;
 class ElementInstancer;
 class ElementInstancer;
-class ElementText;
 class Event;
 class Event;
 class EventInstancer;
 class EventInstancer;
 class EventListener;
 class EventListener;
@@ -104,10 +103,6 @@ public:
 	/// @param[in] text The text to instance the element (or elements) from.
 	/// @param[in] text The text to instance the element (or elements) from.
 	/// @return True if the string was parsed without error, false otherwise.
 	/// @return True if the string was parsed without error, false otherwise.
 	static bool InstanceElementText(Element* parent, const String& text);
 	static bool InstanceElementText(Element* parent, const String& text);
-	/// Instances a single text element with no text contents.
-	/// @param[in] parent The element any instanced elements will be parented to.
-	/// @return The instanced text element if successful, nullptr otherwise.
-	static ElementText* InstanceElementText(Element* parent);
 	/// Instances an element tree based on the stream.
 	/// Instances an element tree based on the stream.
 	/// @param[in] parent The element the stream elements will be added to.
 	/// @param[in] parent The element the stream elements will be added to.
 	/// @param[in] stream The stream to read the element RML from.
 	/// @param[in] stream The stream to read the element RML from.

+ 0 - 11
Include/RmlUi/Core/XMLParser.h

@@ -40,8 +40,6 @@ class DocumentHeader;
 class Element;
 class Element;
 class XMLNodeHandler;
 class XMLNodeHandler;
 class URL;
 class URL;
-class DataModel;
-class Context;
 
 
 /**
 /**
 	RmlUi's XML parsing engine. The factory creates an instance of this class for each RML parse.
 	RmlUi's XML parsing engine. The factory creates an instance of this class for each RML parse.
@@ -84,8 +82,6 @@ public:
 
 
 		// The default handler used for this frame's children.
 		// The default handler used for this frame's children.
 		XMLNodeHandler* child_handler = nullptr;
 		XMLNodeHandler* child_handler = nullptr;
-
-		DataModel* data_model = nullptr;
 	};
 	};
 
 
 	/// Pushes an element handler onto the parse stack for parsing child elements.
 	/// Pushes an element handler onto the parse stack for parsing child elements.
@@ -99,9 +95,6 @@ public:
 	/// @return The parser's current parse frame.
 	/// @return The parser's current parse frame.
 	const ParseFrame* GetParseFrame() const;
 	const ParseFrame* GetParseFrame() const;
 
 
-	/// Get the data model name for the current frame.
-	DataModel* GetDataModel() const;
-
 protected:
 protected:
 	/// Called when the parser finds the beginning of an element tag.
 	/// Called when the parser finds the beginning of an element tag.
 	void HandleElementStart(const String& name, const XMLAttributes& attributes) override;
 	void HandleElementStart(const String& name, const XMLAttributes& attributes) override;
@@ -117,10 +110,6 @@ private:
 	// The active node handler.
 	// The active node handler.
 	XMLNodeHandler* active_handler;
 	XMLNodeHandler* active_handler;
 
 
-	DataModel* active_data_model;
-
-	Context* root_context;
-
 	// The parser stack.
 	// The parser stack.
 	using ParserStack = std::stack< ParseFrame >;
 	using ParserStack = std::stack< ParseFrame >;
 	ParserStack stack;
 	ParserStack stack;

+ 0 - 22
Source/Core/Factory.cpp

@@ -395,28 +395,6 @@ bool Factory::InstanceElementText(Element* parent, const String& text)
 	return true;
 	return true;
 }
 }
 
 
-ElementText* Factory::InstanceElementText(Element* parent)
-{
-	XMLAttributes attributes;
-	ElementPtr element = Factory::InstanceElement(parent, "#text", "#text", attributes);
-	if (!element)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to instance text element, instancer returned nullptr.");
-		return nullptr;
-	}
-
-	ElementText* text_element = rmlui_dynamic_cast<ElementText*>(element.get());
-	if (!text_element)
-	{
-		Log::Message(Log::LT_ERROR, "Failed to instance text element. Found type '%s', was expecting a derivative of ElementText.", rmlui_type_name(*element));
-		return nullptr;
-	}
-
-	parent->AppendChild(std::move(element));
-
-	return text_element;
-}
-
 // Instances a element tree based on the stream
 // Instances a element tree based on the stream
 bool Factory::InstanceElementStream(Element* parent, Stream* stream)
 bool Factory::InstanceElementStream(Element* parent, Stream* stream)
 {
 {

+ 0 - 26
Source/Core/XMLParser.cpp

@@ -51,9 +51,7 @@ XMLParser::XMLParser(Element* root)
 	frame.element = root;
 	frame.element = root;
 	stack.push(frame);
 	stack.push(frame);
 
 
-	root_context = (root ? root->GetContext() : nullptr);
 	active_handler = nullptr;
 	active_handler = nullptr;
-	active_data_model = nullptr;
 
 
 	header = new DocumentHeader();
 	header = new DocumentHeader();
 }
 }
@@ -119,11 +117,6 @@ const XMLParser::ParseFrame* XMLParser::GetParseFrame() const
 	return &stack.top();
 	return &stack.top();
 }
 }
 
 
-DataModel* XMLParser::GetDataModel() const
-{
-	return active_data_model;
-}
-
 /// Called when the parser finds the beginning of an element tag.
 /// Called when the parser finds the beginning of an element tag.
 void XMLParser::HandleElementStart(const String& _name, const XMLAttributes& attributes)
 void XMLParser::HandleElementStart(const String& _name, const XMLAttributes& attributes)
 {
 {
@@ -138,22 +131,6 @@ void XMLParser::HandleElementStart(const String& _name, const XMLAttributes& att
 	// Store the current active handler, so we can use it through this function (as active handler may change)
 	// Store the current active handler, so we can use it through this function (as active handler may change)
 	XMLNodeHandler* node_handler = active_handler;
 	XMLNodeHandler* node_handler = active_handler;
 
 
-	// Look for the data model attribute
-	if (root_context)
-	{
-		static const String data_model = "data-model";
-		auto it = attributes.find(data_model);
-		if (it != attributes.end())
-		{
-			String data_model = it->second.Get<String>();
-
-			active_data_model = root_context->GetDataModel(data_model);
-
-			if (!active_data_model)
-				Log::Message(Log::LT_WARNING, "Could not locate data model '%s'.", data_model.c_str());
-		}
-	}
-
 	Element* element = nullptr;
 	Element* element = nullptr;
 
 
 	// Get the handler to handle the open tag
 	// Get the handler to handle the open tag
@@ -168,7 +145,6 @@ void XMLParser::HandleElementStart(const String& _name, const XMLAttributes& att
 	frame.child_handler = active_handler;
 	frame.child_handler = active_handler;
 	frame.element = (element ? element : stack.top().element);
 	frame.element = (element ? element : stack.top().element);
 	frame.tag = name;
 	frame.tag = name;
-	frame.data_model = active_data_model;
 	stack.push(frame);
 	stack.push(frame);
 }
 }
 
 
@@ -184,8 +160,6 @@ void XMLParser::HandleElementEnd(const String& _name)
 	stack.pop();
 	stack.pop();
 	// Restore active handler to the previous frame's child handler
 	// Restore active handler to the previous frame's child handler
 	active_handler = stack.top().child_handler;	
 	active_handler = stack.top().child_handler;	
-	// Restore the active data model to the current frame's model
-	active_data_model = stack.top().data_model;
 
 
 	// Check frame names
 	// Check frame names
 	if (name != frame.tag)
 	if (name != frame.tag)