### Emscripten SDK Installation Source: https://github.com/pjasicek/openclaw/blob/master/README.md Steps to clone, install, and activate the Emscripten SDK. Ensure you are using a Linux-like environment (e.g., WSL on Windows). ```shell git clone https://github.com/emscripten-core/emsdk.git cd emsdk ./emsdk install latest ./emsdk activate latest source ./emsdk_env.sh ``` -------------------------------- ### Install Linux Prerequisites for OpenClaw Source: https://github.com/pjasicek/openclaw/blob/master/README.md Install necessary SDL2 development libraries for Ubuntu 16.04 or similar distributions to build OpenClaw. ```shell sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev ``` -------------------------------- ### Install GLFW Library Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/glfw/CMakeLists.txt Installs the built GLFW library and its export targets if the GLFW_INSTALL option is enabled. This makes the library available for other projects to use. ```cmake if (GLFW_INSTALL) install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}) endif() ``` -------------------------------- ### XML Declaration Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlDeclaration.html This is an example of a correct XML declaration. TinyXml can read or write files with or without this declaration. ```xml ``` -------------------------------- ### Install Box2D Headers Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Box2D/CMakeLists.txt Installs all Box2D header files to their respective locations within the installation directory when BOX2D_INSTALL is enabled. This ensures that external projects can find the necessary header files. ```cmake install(FILES ${BOX2D_General_HDRS} DESTINATION include/Box2D) install(FILES ${BOX2D_Collision_HDRS} DESTINATION include/Box2D/Collision) install(FILES ${BOX2D_Shapes_HDRS} DESTINATION include/Box2D/Collision/Shapes) install(FILES ${BOX2D_Common_HDRS} DESTINATION include/Box2D/Common) install(FILES ${BOX2D_Dynamics_HDRS} DESTINATION include/Box2D/Dynamics) install(FILES ${BOX2D_Contacts_HDRS} DESTINATION include/Box2D/Dynamics/Contacts) install(FILES ${BOX2D_Joints_HDRS} DESTINATION include/Box2D/Dynamics/Joints) install(FILES ${BOX2D_Rope_HDRS} DESTINATION include/Box2D/Rope) ``` -------------------------------- ### Basic XML Structure Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt An example of a simple XML structure representing a ToDo list. This is used to illustrate how TinyXML parses and represents XML data. ```xml Go to the Toy store! Do bills ``` -------------------------------- ### Install CMake Build System Hooks Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Box2D/CMakeLists.txt Installs CMake configuration files (targets and config files) to facilitate integration with third-party applications. This includes setting up variables for include directories, library paths, and the main library name. ```cmake install(EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR}/Box2D) set (BOX2D_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include) set (BOX2D_INCLUDE_DIRS ${BOX2D_INCLUDE_DIR} ) set (BOX2D_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}) set (BOX2D_LIBRARY Box2D) set (BOX2D_LIBRARIES ${BOX2D_LIBRARY}) set (BOX2D_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/Box2D/UseBox2D.cmake) configure_file(Box2DConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake @ONLY ESCAPE_QUOTES) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Box2DConfig.cmake UseBox2D.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/Box2D) ``` -------------------------------- ### Install Box2D Libraries Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Box2D/CMakeLists.txt Installs the Box2D libraries (shared or static) based on build configurations when BOX2D_INSTALL is enabled. This makes the compiled library accessible for linking by other projects. ```cmake if(BOX2D_BUILD_SHARED) install(TARGETS Box2D_shared EXPORT Box2D-targets LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} RUNTIME DESTINATION bin) endif() if(BOX2D_BUILD_STATIC) install(TARGETS Box2D EXPORT Box2D-targets DESTINATION ${LIB_INSTALL_DIR}) endif() ``` -------------------------------- ### TiXmlPrinter Usage Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlPrinter.html This example demonstrates how to use the TiXmlPrinter to format and print an XML document to standard output. It shows setting indentation and then accepting the document for printing. ```APIDOC ## TiXmlPrinter Usage Example ### Description This example demonstrates how to use the TiXmlPrinter to format and print an XML document to standard output. It shows setting indentation and then accepting the document for printing. ### Methods - `SetIndent(const char* _indent)`: Sets the characters used for indentation. Defaults to 4 spaces. Can be set to a tab character or an empty string for no indentation. - `SetLineBreak(const char* _lineBreak)`: Sets the string used for line breaks. Defaults to a newline character. Can be customized for different operating systems or set to an empty string for no line breaks. - `SetStreamPrinting()`: Switches to a dense formatting mode without line breaks. - `Accept(TiXmlVisitor* visitor)`: Accepts a visitor to traverse the XML document. TiXmlPrinter uses this to process the document. - `CStr()`: Returns the printed XML document as a C-style string. - `Str()`: Returns the printed XML document as a std::string. - `Size()`: Returns the length of the printed XML document string. ### Code Example ```cpp TiXmlPrinter printer; printer.SetIndent( "\t" ); doc.Accept( &printer ); fprintf( stdout, "%s", printer.CStr() ); ``` ``` -------------------------------- ### C-style XML Output Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt Demonstrates C-style XML output using FILE* streams. This method generates human-readable, formatted output with ample whitespace. ```C++ // C style output: // based on FILE* // the Print() and SaveFile() methods // Generates formatted output, with plenty of white space, intended to be as // human-readable as possible. They are very fast, and tolerant of ill formed // XML documents. For example, an XML document that contains 2 root elements // and 2 declarations, will still print. ``` -------------------------------- ### TinyXML DOM Representation Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt Illustrates the hierarchical Document Object Model (DOM) representation of the example XML within TinyXML. This shows how different XML components map to TinyXML classes. ```text TiXmlDocument "demo.xml" TiXmlDeclaration "version='1.0'" "standalone=no" TiXmlComment " Our to do list data" TiXmlElement "ToDo" TiXmlElement "Item" Attribtutes: priority = 1 TiXmlText "Go to the " TiXmlElement "bold" TiXmlText "Toy store!" TiXmlElement "Item" Attributes: priority=2 TiXmlText "Do bills" ``` -------------------------------- ### Build XML Document Programmatically (Alternative Order) Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html An alternative method for programmatically building an XML document, demonstrating a different order of node creation and linking. The resulting XML is identical to the previous example. ```C++ void write_simple_doc2( ) { // same as write_simple_doc1 but add each node // as early as possible into the tree. TiXmlDocument doc; TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" ); doc.LinkEndChild( decl ); TiXmlElement * element = new TiXmlElement( "Hello" ); doc.LinkEndChild( element ); TiXmlText * text = new TiXmlText( "World" ); element->LinkEndChild( text ); doc.SaveFile( "madeByHand2.xml" ); } ``` -------------------------------- ### GetText Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlElement.html Demonstrates the usage of GetText() for retrieving text content from an XML element. Shows a simple case where the element directly contains text. ```cpp const char* str = fooElement->GetText(); ``` -------------------------------- ### Basic XML File Structure Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/index.html An example of a simple XML file structure that can be parsed by TinyXML. This demonstrates a declaration, comment, and nested elements with attributes. ```xml Go to the Toy store! Do bills ``` -------------------------------- ### C-style XML Input Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt Illustrates C-style XML input using FILE* streams. This method is a fast and tolerant way to read XML data when C++ streams are not required. ```C++ // C style input: // based on FILE* // the Parse() and LoadFile() methods // A fast, tolerant read. Use whenever you don't need the C++ streams. ``` -------------------------------- ### XML Parsing Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html This C++ code snippet demonstrates parsing specific elements and attributes from an XML structure, such as 'Windows' and 'Connection' settings. ```C++ // block: windows { m_windows.clear(); // trash existing list TiXmlElement* pWindowNode=hRoot.FirstChild( "Windows" ).FirstChild().Element(); for( pWindowNode; pWindowNode; pWindowNode=pWindowNode->NextSiblingElement()) { WindowSettings w; const char *pName=pWindowNode->Attribute("name"); if (pName) w.name=pName; pWindowNode->QueryIntAttribute("x", &w.x); // If this fails, original value is left as-is pWindowNode->QueryIntAttribute("y", &w.y); pWindowNode->QueryIntAttribute("w", &w.w); pWindowNode->QueryIntAttribute("hh", &w.h); m_windows.push_back(w); } } // block: connection { pElem=hRoot.FirstChild("Connection").Element(); if (pElem) { m_connection.ip=pElem->Attribute("ip"); pElem->QueryDoubleAttribute("timeout",&m_connection.timeout); } } ``` -------------------------------- ### Linux Prerequisites for Claw Launcher Source: https://github.com/pjasicek/openclaw/blob/master/README.md Install the necessary Mono runtime packages for running the Claw Launcher on Ubuntu. Similar packages may be required for other Linux distributions. ```shell sudo apt install mono-runtime libmono-system4.0-cil libmono-system-windows-forms4.0-cil ``` -------------------------------- ### C++ Style XML Input Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt Demonstrates C++ style XML input using std::istream. This method reads XML from a stream, useful for network transmission, but is slower and less tolerant of malformed XML. ```C++ // C++ style input: // based on std::istream // operator>> // Reads XML from a stream, making it useful for network transmission. The tricky // part is knowing when the XML document is complete, since there will almost // certainly be other data in the stream. TinyXML will assume the XML data is // complete after it reads the root element. Put another way, documents that // are ill-constructed with more than one root element will not read correctly. // Also note that operator>> is somewhat slower than Parse, due to both // implementation of the STL and limitations of TinyXML. ``` -------------------------------- ### C++ Style XML Output Example Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/readme.txt Shows C++ style XML output using std::ostream. This method generates condensed output suitable for network transmission, and is not tolerant of ill-formed XML. ```C++ // C++ style output: // based on std::ostream // operator<< // Generates condensed output, intended for network transmission rather than // readability. Depending on your system's implementation of the ostream class, // these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML: // a document should contain the correct one root element. Additional root level // elements will not be streamed out. ``` -------------------------------- ### Loading and Displaying AppSettings Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Demonstrates loading previously saved settings and displaying them to the console. ```C++ // block: load settings { AppSettings settings; settings.load("appsettings2.xml"); printf("%s: %s\n", settings.m_name.c_str(), settings.m_messages["Welcome"].c_str()); WindowSettings & w=settings.m_windows.front(); printf("%s: Show window '%s' at %d,%d (%d x %d)\n", settings.m_name.c_str(), w.name.c_str(), w.x, w.y, w.w, w.h); printf("%s: %s\n", settings.m_name.c_str(), settings.m_messages["Farewell"].c_str()); } ``` -------------------------------- ### Efficient Iteration with TiXmlHandle and NextSiblingElement Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Presents the recommended approach for iterating through sibling elements using TiXmlHandle to get the first element and then C++'s for loop with NextSiblingElement. ```C++ TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); for( child; child; child=child->NextSiblingElement() ) { // do something } ``` -------------------------------- ### Basic AppSettings Save and Load Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Demonstrates the fundamental usage of saving and loading an AppSettings object to an XML file. ```C++ int main(void) { AppSettings settings; settings.save("appsettings2.xml"); settings.load("appsettings2.xml"); return 0; } ``` -------------------------------- ### Create Testbed Executable Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Testbed/CMakeLists.txt Defines the 'Testbed' executable target and lists all its source files, combining framework and test sources. ```cmake add_executable(Testbed ${Testbed_Framework_SRCS} ${Testbed_Tests_SRCS} ) ``` -------------------------------- ### Emscripten Module Configuration Source: https://github.com/pjasicek/openclaw/blob/master/Build_Release/openclaw.html Configures the Emscripten module, including pre-run tasks, canvas element setup, data file downloads, and status updates for game loading. ```javascript var loadingElement = document.getElementById("loading"); // Emscripten structure var Module = { preRun: [function () { // Here you can change canvas size dynamically if it's needed // var ratio = window.devicePixelRatio || 1; // Module.canvas.width = Math.max(screen.width, screen.height) * ratio; // Module.canvas.height = Math.min(screen.width, screen.height) * ratio; loadingElement.remove(); loadingElement = null; Module.canvas.style.display = "block"; }], canvas: (function () { var canvas = document.getElementById('canvas'); // As a default initial behavior, pop up an alert when webgl context is lost. To make your // application robust, you may want to override this behavior before shipping! // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 canvas.addEventListener("webglcontextlost", function (e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); return canvas; })(), dataFileDownloads: { "openclaw.data": { total: 0, loaded: 0, } }, setStatus: function (text) { if (loadingElement) { Module.canvas.style.display = "none"; var progress = (Module.dataFileDownloads["openclaw.data"].loaded / Module.dataFileDownloads["openclaw.data"].total * 100) | 0; if (progress < 100) { loadingElement.innerHTML = "Game resources are downloading... " + (progress | 0) + "%"; } else { loadingElement.innerHTML = "Game resources have been downloaded. Game is loading..."; } } }, // Could be removed. This code for debug build only print: Console.printToConsole, printErr: Console.printToConsole, }; ``` -------------------------------- ### Initialize Game Settings from Local Storage Source: https://github.com/pjasicek/openclaw/blob/master/Build_Release/openclaw.html Initializes game resolution and scale from local storage if available. Updates UI elements and internal game variables. ```javascript if (window.localStorage.width && window.localStorage.height && window.localStorage.scale) { document.getElementById('res').value = window.localStorage.width + " " + window.localStorage.height; document.getElementById('scale').value = window.localStorage.scale; CheatCodeManager.winsize = window.localStorage.width + " " + window.localStorage.height; CheatCodeManager.scale = window.localStorage.scale; } ``` -------------------------------- ### Customizing and Saving AppSettings Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Shows how to customize various settings within an AppSettings object before saving it to an XML file. ```C++ // block: customise and save settings { AppSettings settings; settings.m_name="HitchHikerApp"; settings.m_messages["Welcome"]="Don't Panic"; settings.m_messages["Farewell"]="Thanks for all the fish"; settings.m_windows.push_back(WindowSettings(15,25,300,250,"BookFrame")); settings.m_connection.ip="192.168.0.77"; settings.m_connection.timeout=42.0; settings.save("appsettings2.xml"); } ``` -------------------------------- ### NextSiblingElement Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlNode.html Convenience function to get the next sibling element. ```APIDOC ## NextSiblingElement ### Description Convenience function to get the next sibling element. ### Method const [TiXmlElement](classTiXmlElement.html) * NextSiblingElement() const ### Parameters None ``` ```APIDOC ## NextSiblingElement (by char*) ### Description Convenience function to get the next sibling element with the given value. ### Method const [TiXmlElement](classTiXmlElement.html) * NextSiblingElement(const char *) ### Parameters #### Path Parameters - **value** (const char *) - Description: The value of the sibling element to find. ``` ```APIDOC ## NextSiblingElement (by string) ### Description Convenience function to get the next sibling element with the given STL string value. ### Method const [TiXmlElement](classTiXmlElement.html) * NextSiblingElement(const std::string &) ### Parameters #### Path Parameters - **value** (const std::string &) - Description: The value of the sibling element to find. ``` ```APIDOC ## NextSiblingElement (mutable by string) ### Description Convenience function to get the next sibling element with the given STL string value. ### Method [TiXmlElement](classTiXmlElement.html) * NextSiblingElement(const std::string &) ### Parameters #### Path Parameters - **value** (const std::string &) - Description: The value of the sibling element to find. ``` -------------------------------- ### Build XML Document Programmatically Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Shows how to create an XML document, including a declaration and an element with text, using the TinyXML API. The document is then saved to a file. ```C++ void build_simple_doc( ) { // Make xml: World TiXmlDocument doc; TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" ); TiXmlElement * element = new TiXmlElement( "Hello" ); TiXmlText * text = new TiXmlText( "World" ); element->LinkEndChild( text ); doc.LinkEndChild( decl ); doc.LinkEndChild( element ); doc.SaveFile( "madeByHand.xml" ); } ``` -------------------------------- ### Get Attribute Name and Value Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlAttribute.html Retrieves the name and value of the attribute. ```APIDOC ## Name() ### Description Return the name of this attribute. ### Method const char * ### Endpoint Name() ``` ```APIDOC ## Value() ### Description Return the value of this attribute. ### Method const char * ### Endpoint Value() ``` ```APIDOC ## ValueStr() ### Description Return the value of this attribute. ### Method const std::string & ### Endpoint ValueStr() ``` -------------------------------- ### Box2D HelloWorld CMakeLists Configuration Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/HelloWorld/CMakeLists.txt Configures the build for the HelloWorld executable, linking it with the Box2D library. ```cmake include_directories (${Box2D_SOURCE_DIR}) add_executable(HelloWorld HelloWorld.cpp) target_link_libraries (HelloWorld Box2D) ``` -------------------------------- ### Get Error Description Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns a textual description of the last error that occurred. ```cpp const char* TiXmlDocument::ErrorDesc() const { return errorDesc.c_str (); } ``` -------------------------------- ### Get Node Type Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns the type of the current node as an enumerated value. ```cpp int [Type](classTiXmlNode.html#a57b99d5c97d67a42b9752f5210a1ba5e "Query the type (as an enumerated value, above) of this node.")() const { return type; } ``` -------------------------------- ### Basic TinyXML CMake Configuration Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/CMakeLists.txt Sets up the minimum CMake version, project name, and version. It then defines the TinyXML library as a static library with its source files. ```cmake cmake_minimum_required(VERSION 3.2) project(tinyxml VERSION 2.6.2 LANGUAGES CXX) add_library(tinyxml STATIC tinyxml.h tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp ) ``` -------------------------------- ### Get Last Attribute Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlElement.html Accesses the last attribute associated with this XML element. ```cpp const TiXmlAttribute* TiXmlElement::LastAttribute() const ``` -------------------------------- ### Using Accept() with TiXmlPrinter Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlNode.html Demonstrates how to use the Accept() method with a TiXmlPrinter to traverse the TinyXML DOM and obtain the XML string representation. ```cpp TiXmlPrinter printer; tinyxmlDoc.Accept( &printer ); const char* xmlcstr = printer.CStr(); ``` -------------------------------- ### Get First Attribute Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlElement.html Accesses the first attribute associated with this XML element. ```cpp const TiXmlAttribute* TiXmlElement::FirstAttribute() const ``` -------------------------------- ### TiXmlDocument Root Element Access Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Methods to get the root element of the XML document. ```APIDOC ## TiXmlDocument Root Element Access ### Description Methods to get the root element of the XML document. ### Methods - `const TiXmlElement* RootElement() const`: Gets the root element (the only top-level element) of the document (const version). - `TiXmlElement* RootElement()`: Gets the root element (the only top-level element) of the document. ``` -------------------------------- ### Get Error ID Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns the error ID. The error description is generally more useful. ```cpp int TiXmlDocument::ErrorId() const { return errorId; } ``` -------------------------------- ### Get Attribute Value as Numeric Types Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlAttribute.html Retrieves the attribute value converted to integer or double. ```APIDOC ## IntValue() ### Description Return the value of this attribute, converted to an integer. ### Method int ### Endpoint IntValue() ``` ```APIDOC ## DoubleValue() ### Description Return the value of this attribute, converted to a double. ### Method double ### Endpoint DoubleValue() ``` -------------------------------- ### Building and Saving an XML Document with TinyXml Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html This function constructs a complex XML document in memory, including a declaration, comments, elements with attributes, and text nodes, then saves it to 'appsettings.xml'. ```C++ void write_app_settings_doc( ) { TiXmlDocument doc; TiXmlElement* msg; TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" ); doc.LinkEndChild( decl ); TiXmlElement * root = new TiXmlElement( "MyApp" ); doc.LinkEndChild( root ); TiXmlComment * comment = new TiXmlComment(); comment->SetValue(" Settings for MyApp " ); root->LinkEndChild( comment ); TiXmlElement * msgs = new TiXmlElement( "Messages" ); root->LinkEndChild( msgs ); msg = new TiXmlElement( "Welcome" ); msg->LinkEndChild( new TiXmlText( "Welcome to MyApp" )); msgs->LinkEndChild( msg ); msg = new TiXmlElement( "Farewell" ); msg->LinkEndChild( new TiXmlText( "Thank you for using MyApp" )); msgs->LinkEndChild( msg ); TiXmlElement * windows = new TiXmlElement( "Windows" ); root->LinkEndChild( windows ); TiXmlElement * window; window = new TiXmlElement( "Window" ); windows->LinkEndChild( window ); window->SetAttribute("name", "MainFrame"); window->SetAttribute("x", 5); window->SetAttribute("y", 15); window->SetAttribute("w", 400); window->SetAttribute("h", 250); TiXmlElement * cxn = new TiXmlElement( "Connection" ); root->LinkEndChild( cxn ); cxn->SetAttribute("ip", "192.168.0.1"); cxn->SetDoubleAttribute("timeout", 123.456); // floating point attrib dump_to_stdout( &doc ); doc.SaveFile( "appsettings.xml" ); } ``` -------------------------------- ### Get Root Element Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Retrieves the root element of the XML document. This is a convenience function that calls FirstChildElement. ```cpp const TiXmlElement* TiXmlDocument::RootElement() const { return FirstChildElement(); } ``` ```cpp TiXmlElement* TiXmlDocument::RootElement() { return FirstChildElement(); } ``` -------------------------------- ### Get Column Number Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns the column number of the current location. This is a simple inline getter function. ```cpp int [Column]() const { return location.col + 1; } ``` -------------------------------- ### Define Test Source Files Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Testbed/CMakeLists.txt Lists all the source and header files for the various tests within the Box2D testbed. This includes a wide range of physics simulations. ```cmake set(Testbed_Tests_SRCS Tests/TestEntries.cpp Tests/AddPair.h Tests/ApplyForce.h Tests/BodyTypes.h Tests/Breakable.h Tests/Bridge.h Tests/BulletTest.h Tests/Cantilever.h Tests/Car.h Tests/Chain.h Tests/CharacterCollision.h Tests/CollisionFiltering.h Tests/CollisionProcessing.h Tests/CompoundShapes.h Tests/Confined.h Tests/ContinuousTest.h Tests/DistanceTest.h Tests/Dominos.h Tests/DumpShell.h Tests/DynamicTreeTest.h Tests/EdgeShapes.h Tests/EdgeTest.h Tests/Gears.h Tests/OneSidedPlatform.h Tests/Pinball.h Tests/PolyCollision.h Tests/PolyShapes.h Tests/Prismatic.h Tests/Pulleys.h Tests/Pyramid.h Tests/RayCast.h Tests/Revolute.h Tests/Rope.h Tests/RopeJoint.h Tests/SensorTest.h Tests/ShapeEditing.h Tests/SliderCrank.h Tests/SphereStack.h Tests/TheoJansen.h Tests/Tiles.h Tests/TimeOfImpact.h Tests/VaryingFriction.h Tests/VaryingRestitution.h Tests/VerticalStack.h Tests/Web.h ) ``` -------------------------------- ### Get Error Column Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns the column number where an error occurred. Adds 1 to the internal 0-based index. ```cpp int ErrorCol() const { return errorLocation.col+1; } ``` -------------------------------- ### Get Error Row Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Returns the row number where an error occurred. Adds 1 to the internal 0-based index. ```cpp int ErrorRow() const { return errorLocation.row+1; } ``` -------------------------------- ### Configure Include and Link Directories Source: https://github.com/pjasicek/openclaw/blob/master/MidiProc/CMakeLists.txt Specifies private include directories and link directories for the MidiProc target. ```cmake target_include_directories(MidiProc PRIVATE ../ThirdParty/) target_link_directories(MidiProc PRIVATE ../Build_Release) target_link_directories(MidiProc PRIVATE ../ThirdParty/SDL2/lib/x86) ``` -------------------------------- ### Get Parent Document Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Retrieves a pointer to the TiXmlDocument that this node belongs to. This is a convenience overload that casts the const version. ```cpp const [TiXmlDocument](classTiXmlDocument.html "Always the top level node.")* [GetDocument](classTiXmlNode.html#a80e397fa973cf5323e33b07154b024f3 "Return a pointer to the Document this node lives in.")() const; ``` ```cpp [TiXmlDocument](classTiXmlDocument.html "Always the top level node.")* [GetDocument](classTiXmlNode.html#a80e397fa973cf5323e33b07154b024f3 "Return a pointer to the Document this node lives in.")() { return const_cast< [TiXmlDocument](classTiXmlDocument.html "Always the top level node.")* >( (const_cast< const [TiXmlNode](classTiXmlNode.html "The parent class for everything in the Document Object Model.")* >(this))->GetDocument() ); } ``` -------------------------------- ### Getting the Parent Document Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlNode.html Retrieves a pointer to the TiXmlDocument that this node belongs to. Returns null if the node is not part of a document. ```cpp const [TiXmlDocument](classTiXmlDocument.html)* TiXmlNode::GetDocument( void ) const ``` -------------------------------- ### TiXmlString Find Character (Overload) Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinystr_8h_source.html Searches for a character within the string. This overload starts the search from the beginning of the string. ```cpp size_type find (char lookup) const { return find(lookup, 0); } ``` -------------------------------- ### Define Testbed Framework Source Files Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Testbed/CMakeLists.txt Lists the source and header files for the Box2D testbed framework. These are essential for the testbed's core functionality. ```cmake set(Testbed_Framework_SRCS Framework/DebugDraw.cpp Framework/DebugDraw.h Framework/imgui.h Framework/imgui.cpp Framework/Main.cpp Framework/RenderGL3.cpp Framework/RenderGL3.h Framework/Test.cpp Framework/Test.h ) ``` -------------------------------- ### Get Underlying TiXmlText Pointer Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Directly retrieves the TiXmlText pointer wrapped by the handle. Returns null if the node is not text. ```cpp TiXmlText * Text() const ``` -------------------------------- ### Get Underlying TiXmlElement Pointer Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Directly retrieves the TiXmlElement pointer wrapped by the handle. Returns null if the node is not an element. ```cpp TiXmlElement * Element() const ``` -------------------------------- ### Load XML from File Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Demonstrates loading an XML file into a TiXmlDocument and checking if the load was successful. This is a basic real-world usage pattern. ```C++ void dump_to_stdout(const char* pFilename) { TiXmlDocument doc(pFilename); bool loadOkay = doc.LoadFile(); if (loadOkay) { printf("\n%s:\n", pFilename); dump_to_stdout( &doc ); // defined later in the tutorial } else { printf("Failed to load file \"%s\"\n", pFilename); } } ``` ```C++ int main(void) { dump_to_stdout("example1.xml"); return 0; } ``` -------------------------------- ### Accept Visitor (Const) Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlElement.html Accepts a TiXmlVisitor and walks the XML tree, visiting this node and all its children. ```cpp virtual bool TiXmlElement::Accept(TiXmlVisitor *visitor) const ``` -------------------------------- ### Get Underlying TiXmlNode Pointer Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Directly retrieves the TiXmlNode pointer wrapped by the handle. Performs null checks internally. ```cpp TiXmlNode * Node() const ``` -------------------------------- ### Get XML Entity Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Decodes an XML entity (e.g., &) into its corresponding character. Returns a pointer to the character following the entity. ```cpp static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); ``` -------------------------------- ### Running Claw Launcher on Linux Source: https://github.com/pjasicek/openclaw/blob/master/README.md Execute the Claw Launcher application on Linux using the Mono runtime. Ensure you are in the correct directory containing the launcher executable. ```shell ~/OpenClaw/Build_Release$ mono ClawLauncher.exe ``` -------------------------------- ### Get User Data Pointer Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Retrieves the generic user pointer associated with the XML node. Overloaded for const and non-const access. ```cpp void* [GetUserData]() { return userData; } ``` ```cpp const void* [GetUserData]() const { return userData; } ``` -------------------------------- ### Saving a TinyXml Document to a File Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html Demonstrates the simple process of saving a pre-built TinyXml DOM document to a specified file path. ```C++ doc.SaveFile( saveFilename ); ``` -------------------------------- ### Get Underlying TiXmlUnknown Pointer Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Directly retrieves the TiXmlUnknown pointer wrapped by the handle. Returns null if the node is not an unknown type. ```cpp TiXmlUnknown * Unknown() const ``` -------------------------------- ### Platform-Specific Include and Library Directories (macOS) Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Testbed/CMakeLists.txt Configures include and library paths for OpenGL and X11 on macOS. This ensures the correct system libraries are found. ```cmake if(APPLE) # We are not using the Apple's framework version, but X11's include_directories( /usr/X11/include ) link_directories( /usr/X11/lib ) set (OPENGL_LIBRARIES GL GLU X11) elseif(WIN32) set (ADDITIONAL_LIBRARIES winmm) endif(APPLE) ``` -------------------------------- ### Get Specific Child Element Handle by Index Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the child element at the specified index. Skips non-element nodes. ```cpp TiXmlHandle ChildElement( int index ) const ``` -------------------------------- ### Get First Child Element Handle by Name Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the first child element that matches the specified name (value). ```cpp TiXmlHandle FirstChildElement( const char * value ) const ``` -------------------------------- ### Loading an XML File with TinyXML Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/index.html Demonstrates how to load an XML file using the TiXmlDocument class in TinyXML. This is the initial step for parsing an XML document. ```cpp TiXmlDocument doc( "demo.xml" ); doc.LoadFile(); ``` -------------------------------- ### Get First Child Element Handle Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the first child element of the current node. Skips non-element nodes. ```cpp TiXmlHandle FirstChildElement() const ``` -------------------------------- ### Loading XML with Custom Tab Size Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlDocument.html Demonstrates how to set a custom tab size for accurate error reporting before loading an XML file. This setting affects how row and column numbers are calculated. ```cpp TiXmlDocument doc; doc.SetTabSize( 8 ); doc.Load( "myfile.xml" ); ``` -------------------------------- ### Get First Child Node Handle by Name Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the first child node that matches the specified name (value). ```cpp TiXmlHandle FirstChild( const char * value ) const ``` -------------------------------- ### Set Output Directories Source: https://github.com/pjasicek/openclaw/blob/master/CMakeLists.txt Configures the output directories for runtime executables and shared libraries. ```cmake set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../Build_Release) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ../android/libs/armeabi-v7a) ``` -------------------------------- ### Get First Child Node Handle Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the first child node of the current node. Useful for iterating through children. ```cpp TiXmlHandle FirstChild() const ``` -------------------------------- ### Get User Data in TinyXml Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlBase.html Retrieves a pointer to the arbitrary user data associated with the object. Overloaded for const and non-const access. ```cpp void * TiXmlBase::GetUserData(); ``` ```cpp const void * TiXmlBase::GetUserData() const; ``` -------------------------------- ### Link Libraries to Testbed Executable Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/Testbed/CMakeLists.txt Specifies the libraries that the 'Testbed' executable depends on. This includes Box2D, GLEW, GLFW, and OpenGL libraries. ```cmake target_link_libraries ( Testbed Box2D glew glfw ${ADDITIONAL_LIBRARIES} ${OPENGL_LIBRARIES} ) ``` -------------------------------- ### Get Row Position in TinyXml Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlBase.html Returns the position (row number) of a node or attribute in the original source file. This is an inline function. ```cpp int TiXmlBase::Row() const; ``` -------------------------------- ### Running OpenClaw with Python SimpleHTTPServer Source: https://github.com/pjasicek/openclaw/blob/master/README.md Serve the compiled OpenClaw WebAssembly files using Python's built-in HTTP server. Access the game via http://localhost:8080/openclaw.html. ```shell cd Build_Release python -m SimpleHTTPServer 8080 # Go to http://localhost:8080/openclaw.html ``` -------------------------------- ### Get First Child Element (No Value) Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Retrieves the first child element of the current node. This is a convenience overload that casts the const version. ```cpp const [TiXmlElement](classTiXmlElement.html "The element is a container class.")* [FirstChildElement](classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba "Convenience function to get through elements.")() const; ``` ```cpp [TiXmlElement](classTiXmlElement.html "The element is a container class.")* [FirstChildElement](classTiXmlNode.html#af4fb652f6bd79ae0d5ce7d0f7d3c0fba "Convenience function to get through elements.")() { return const_cast< [TiXmlElement](classTiXmlElement.html "The element is a container class.")* >( (const_cast< const [TiXmlNode](classTiXmlNode.html "The parent class for everything in the Document Object Model.")* >(this))->FirstChildElement() ); } ``` -------------------------------- ### Build OpenClaw on Windows using CMake and Visual Studio Source: https://github.com/pjasicek/openclaw/blob/master/README.md Use CMake to generate a Visual Studio solution or Makefiles for building the OpenClaw project on Windows. ```shell mkdir build cd build cmake -G "Visual Studio 15 2017" .. msbuild OpenClaw.sln # Or cmake -G "NMake Makefiles" .. nmake ``` -------------------------------- ### Accept Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlElement.html Accepts a visitor pattern implementation to traverse the XML node tree. ```APIDOC ## Accept ### Description Implements the visitor pattern, allowing a TiXmlVisitor to traverse this node and its children. ### Method bool ### Parameters #### Path Parameters - **visitor** (TiXmlVisitor *) - Description: A pointer to the TiXmlVisitor object. ### Returns True if the visitor successfully visited the node and its children, false otherwise. ``` -------------------------------- ### Get Character with Entity Decoding Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tinyxml_8h_source.html Reads a character from a stream, interpreting any XML entities. The output character and its length (up to 4 bytes) are provided. ```cpp inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) ``` -------------------------------- ### Get Specific Child Node Handle by Index Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlHandle.html Returns a TiXmlHandle to the child node at the specified index. Useful for accessing children by their order. ```cpp TiXmlHandle Child( int index ) const ``` -------------------------------- ### Clone and Build OpenClaw on Linux Source: https://github.com/pjasicek/openclaw/blob/master/README.md Clone the OpenClaw repository and use CMake and make to compile the project on Linux. ```shell git clone https://github.com/pjasicek/OpenClaw.git # CLAW.REZ iz required from original game in the OpenClaw/Build_Release folder # Use cmake to build fresh Makefile. There is no need specific arguments. make ``` -------------------------------- ### Loading and Dumping XML Structure Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/tutorial0.html This C++ code demonstrates loading an XML file and recursively dumping its structure to stdout. It includes utility functions for indentation and attribute handling. ```C++ #include "stdafx.h" #include "tinyxml.h" // ---------------------------------------------------------------------- // STDOUT dump and indenting utility functions // ---------------------------------------------------------------------- const unsigned int NUM_INDENTS_PER_SPACE=2; const char * getIndent( unsigned int numIndents ) { static const char * pINDENT=" + "; static const unsigned int LENGTH=strlen( pINDENT ); unsigned int n=numIndents*NUM_INDENTS_PER_SPACE; if ( n > LENGTH ) n = LENGTH; return &pINDENT[ LENGTH-n ]; } // same as getIndent but no "+" at the end const char * getIndentAlt( unsigned int numIndents ) { static const char * pINDENT=" "; static const unsigned int LENGTH=strlen( pINDENT ); unsigned int n=numIndents*NUM_INDENTS_PER_SPACE; if ( n > LENGTH ) n = LENGTH; return &pINDENT[ LENGTH-n ]; } int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent) { if ( !pElement ) return 0; TiXmlAttribute* pAttrib=pElement->FirstAttribute(); int i=0; int ival; double dval; const char* pIndent=getIndent(indent); printf("\n"); while (pAttrib) { printf( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value()); if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS) printf( " int=%d", ival); if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf( " d=%1.1f", dval); printf( "\n" ); i++; pAttrib=pAttrib->Next(); } return i; } void dump_to_stdout( TiXmlNode* pParent, unsigned int indent = 0 ) { if ( !pParent ) return; TiXmlNode* pChild; TiXmlText* pText; int t = pParent->Type(); printf( "%s", getIndent(indent)); int num; switch ( t ) { case TiXmlNode::TINYXML_DOCUMENT: printf( "Document" ); break; case TiXmlNode::TINYXML_ELEMENT: printf( "Element [%s]", pParent->Value() ); num=dump_attribs_to_stdout(pParent->ToElement(), indent+1); switch(num) { case 0: printf( " (No attributes)"); break; case 1: printf( "%s1 attribute", getIndentAlt(indent)); break; default: printf( "%s%d attributes", getIndentAlt(indent), num); break; } break; case TiXmlNode::TINYXML_COMMENT: printf( "Comment: [%s]", pParent->Value()); break; case TiXmlNode::TINYXML_UNKNOWN: printf( "Unknown" ); break; case TiXmlNode::TINYXML_TEXT: pText = pParent->ToText(); printf( "Text: [%s]", pText->Value() ); break; case TiXmlNode::TINYXML_DECLARATION: printf( "Declaration" ); break; default: break; } printf( "\n" ); for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) { dump_to_stdout( pChild, indent+1 ); } } // load the named file and dump its structure to STDOUT void dump_to_stdout(const char* pFilename) { TiXmlDocument doc(pFilename); bool loadOkay = doc.LoadFile(); if (loadOkay) { printf("\n%s:\n", pFilename); dump_to_stdout( &doc ); // defined later in the tutorial } else { printf("Failed to load file \"%s\"\n", pFilename); } } // ---------------------------------------------------------------------- // main() for printing files named on the command line // ---------------------------------------------------------------------- int main(int argc, char* argv[]) { for (int i=1; i= length()) return npos; for (const char* p = c_str() + offset; *p != '\0'; ++p) { if (*p == tofind) return static_cast< size_type >( p - c_str() ); } return npos; } ``` -------------------------------- ### Platform-Specific Headers and Sources for GLFW (X11) Source: https://github.com/pjasicek/openclaw/blob/master/Box2D/glfw/CMakeLists.txt Configures the header and source files for GLFW when building on Linux/Unix systems using the X11 backend. Includes X11 platform files, XKB, and joystick handling. ```cmake elseif (_GLFW_X11) set(glfw_HEADERS ${common_headers} x11_platform.h xkb_unicode.h linux_joystick.h posix_time.h posix_tls.h) set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c xkb_unicode.c linux_joystick.c posix_time.c posix_tls.c) ``` -------------------------------- ### TiXmlNode::Value Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlNode.html Retrieves the value of the node, which varies depending on the node type. For example, for an Element, it's the name; for a Comment, it's the comment text. ```APIDOC ## TiXmlNode::Value ### Description Retrieves the value of the node. The meaning of 'value' changes for the specific type of TiXmlNode. - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string The subclasses will wrap this function. ### Method `const` `inline` `const char*` Value() ### Parameters None ``` -------------------------------- ### Accept Visitor Source: https://github.com/pjasicek/openclaw/blob/master/ThirdParty/Tinyxml/docs/classTiXmlDocument.html Walks the XML tree, visiting this node and all of its children with a TiXmlVisitor. ```APIDOC ## Accept ### Description Walk the XML tree visiting this node and all of its children. ### Method virtual bool ### Endpoint Accept(TiXmlVisitor* content) ### Parameters * **content** (TiXmlVisitor*) - A pointer to the TiXmlVisitor to use for traversal. ### Response * **bool** - True if the visitor accepted the node and its children, false otherwise. ```