Browse Source

Add optional name for LoadDocumentFromMemory() (#130)

* Add optional name for LoadDocumentFromMemory()

* LoadDocumentFromMemory() minor tweaks
LWSS 5 years ago
parent
commit
37923c1695
2 changed files with 5 additions and 3 deletions
  1. 2 1
      Include/RmlUi/Core/Context.h
  2. 3 2
      Source/Core/Context.cpp

+ 2 - 1
Include/RmlUi/Core/Context.h

@@ -101,8 +101,9 @@ public:
 	ElementDocument* LoadDocument(Stream* document_stream);
 	/// Load a document into the context.
 	/// @param[in] string The string containing the document RML.
+	/// @param[in] string Optional string used to name the document - mainly for Log Messages.
 	/// @return The loaded document, or nullptr if no document was loaded.
-	ElementDocument* LoadDocumentFromMemory(const String& string);
+	ElementDocument* LoadDocumentFromMemory(const String& string, const String& source_url = "[document from memory]");
 	/// Unload the given document.
 	/// @param[in] document The document to unload.
 	void UnloadDocument(ElementDocument* document);

+ 3 - 2
Source/Core/Context.cpp

@@ -279,11 +279,12 @@ ElementDocument* Context::LoadDocument(Stream* stream)
 }
 
 // Load a document into the context.
-ElementDocument* Context::LoadDocumentFromMemory(const String& string)
+ElementDocument* Context::LoadDocumentFromMemory(const String& string, const String& source_url)
 {
 	// Open the stream based on the string contents.
 	auto stream = MakeUnique<StreamMemory>((byte*)string.c_str(), string.size());
-	stream->SetSourceURL("[document from memory]");
+
+	stream->SetSourceURL( source_url.c_str() );
 
 	// Load the document from the stream.
 	ElementDocument* document = LoadDocument(stream.get());