SimXMLDocument.cpp
Engine/source/console/SimXMLDocument.cpp
Public Functions
ConsoleDocClass(SimXMLDocument , "@brief <a href="/coding/class/classfile/">File</a> I/O object used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> creating, reading , and writing XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">documents.\n\n</a>" "A <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> container of various XML nodes. The <a href="/coding/file/document_8h/#document_8h_1ac6ea5b168e3fe8c7fa532450fc9391f7">Document</a> level may contain " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> header, comments and child Elements. Elements may " "contain attributes, data(or text) and child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Elements.\n\n</a>" "You build <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Elements using addNewElement(). This makes the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element the current " "one you 're working with. You then use setAttribute() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add attributes <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the Element. " "You use addData() or addText() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> write <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the text area of an Element." " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Thanks <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Rex Hiebert <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example\n</a>" "//Given the following <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">XML\n</a>" "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" "<DataTables>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <table tableName=\"2DShapes\">\n" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"1\">Triangle</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"2\">Square</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"3\">Circle</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " </table>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <table tableName=\"3DShapes\">\n" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"1\">Pyramid</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"2\">Cube</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"3\">Sphere</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " </table>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</DataTables>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Using <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">itself\n</a>" "function readXmlExample(%filename)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a>() {};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.loadFile(%filename);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %xml.pushChildElement(\"DataTables\");\n" " %xml.pushFirstChildElement(\"table\");\n" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a>(true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"TABLE:\" SPC %xml.attribute(\"tableName\"));\n" " %xml.pushFirstChildElement(\"rec\");\n" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> (true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %<a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a> = %xml.attribute(\"id\");\n" " %desc = %xml.getData();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\" Shape\" SPC %<a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a> SPC %desc);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"rec\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.popElement();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"table\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Thanks <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Scott Peal <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example\n</a>" "// Using <a href="/coding/class/classfileobject/">FileObject</a> in conjunction with <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SimXMLDocument\n</a>" "// This example uses an XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> format <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">of:\n</a>" "// <Models>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// <Model category=\"\" name=\"\" path=\"\" />\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// </Models>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "function getModelsInCatagory()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> = \"./Catalog.xml\";\n" " %fo = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classfileobject/">FileObject</a>();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %text = \"\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(%fo.openForRead(%<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a>))\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a>(!%fo.isEOF())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %text = %text @ %fo.readLine();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%fo.isEOF()) %text = %text @ \"\\n\";\n" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">else\n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Unable <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> locate the file: \" @ %file);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %fo.delete();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %xml = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a>() {};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.parse(%text);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // \"Get\" inside of the root element, \"Models\".\n" " %xml.pushChildElement(0);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " // \"Get\" into the first child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (%xml.pushFirstChildElement(\"Model\"))\n" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> (true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // Here, <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> read the element's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attributes.\n</a>" " // You might want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> save these values in an array or call the %xml.getElementValue()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> you have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">structure.\n\n</a>" " %catagory = %xml.attribute(\"catagory\");\n" " %name = %xml.attribute(\"name\");\n" " %path = %xml.attribute(\"path\");\n\n" " // now, read the next \"Model\"\n" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"Model\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@note <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> wrapper around TinyXml, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> standard XML library. If you 're familiar " "with its concepts, you 'll find they also apply <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">FileObject\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">FileSystem\n</a>" )
DefineEngineMethod(SimXMLDocument , addComment , void , (const char *comment) , "@brief Add the given comment as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document.\n\n</a>" "@param comment <a href="/coding/class/classstring/">String</a> containing the comment." "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> XML document with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> header)
DefineEngineMethod(SimXMLDocument , addData , void , (const char *text) , "@brief Add the given text as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use getData() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> retrieve any text from the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "addData() and addText() may be used interchangeably. As there is no " "difference between data and text)
DefineEngineMethod(SimXMLDocument , addHeader , void , () , "@brief Add <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> XML header <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document.\n\n</a>" "Sometimes called <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> declaration)
DefineEngineMethod(SimXMLDocument , addNewElement , void , (const char *name) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element with the given name as child of current Element's " "parent and push it onto the Element stack making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@note This differs from pushNewElement() in that it adds the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the " "current Element's parent (or document <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> there is no parent Element). This makes " "the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sibling of the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@param name XML tag <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@see pushNewElement()" )
DefineEngineMethod(SimXMLDocument , addText , void , (const char *text) )
DefineEngineMethod(SimXMLDocument , attribute , const char * , (const char *attributeName) , "@brief Get <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> string attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The attribute string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> found. Otherwise returns an empty <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n</a>" )
DefineEngineMethod(SimXMLDocument , attributeExists , bool , (const char *attributeName) , "@brief Tests <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the requested attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exists.\n\n</a>" "@param attributeName Name of attribute being queried <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for.\n\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the attribute exists." )
DefineEngineMethod(SimXMLDocument , attributeF32 , F32 , (const char *attributeName) , "(string attributeName)" "@brief Get float attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the given attribute in the form of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">float.\n</a>" "@deprecated Use attribute()." )
DefineEngineMethod(SimXMLDocument , attributeS32 , S32 , (const char *attributeName) , "(string attributeName)" "@brief Get int attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the given attribute in the form of an <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">integer.\n</a>" "@deprecated Use attribute()." )
DefineEngineMethod(SimXMLDocument , clear , void , () , "@brief Set this document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> its default <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n\n</a>" "Clears all Elements from the documents. Equivalent <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> using reset()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@see reset()" )
DefineEngineMethod(SimXMLDocument , clearError , void , () , "@brief Clear the last error <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">description.\n\n</a>" )
DefineEngineMethod(SimXMLDocument , elementValue , const char * , () , "@brief Get the Element's <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exists.\n\n</a>" "Usually returns the text from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> from the Element, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." )
DefineEngineMethod(SimXMLDocument , firstAttribute , const char * , () , "@brief Obtain the name of the current Element's first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute.\n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the first attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see nextAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see prevAttribute()" )
DefineEngineMethod(SimXMLDocument , getData , const char * , () , "@brief Gets the text from the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use addData() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add text <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "getData() and getText() may be used interchangeably. As there is no " "difference between data and text)
DefineEngineMethod(SimXMLDocument , getErrorDesc , const char * , () , "@brief Get last error <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">description.\n\n</a>" "@return A string of the last error message." )
DefineEngineMethod(SimXMLDocument , getText , const char * , () )
DefineEngineMethod(SimXMLDocument , lastAttribute , const char * , () , "@brief Obtain the name of the current Element's last <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute.\n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the last attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see prevAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , loadFile , bool , (const char *fileName) , "@brief Load in given filename and prepare it <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n\n</a>" "@note Clears the current document's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">contents.\n\n</a>" "@param fileName Name and path of XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> was loaded successfully." )
DefineEngineMethod(SimXMLDocument , nextAttribute , const char * , () , "@brief Get the name of the next attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the current Element after <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> firstAttribute().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the next attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see prevAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , nextSiblingElement , bool , (const char *name) , "@brief Put the next sibling Element with the given name on the stack, making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" " @param name <a href="/coding/class/classstring/">String</a> containing name of the next sibling." " @return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the Element was found and made the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n</a>" )
DefineEngineMethod(SimXMLDocument , parse , void , (const char *xmlString) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> document from <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "@note Clears the current document's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">contents.\n\n</a>" "@param xmlString Valid XML <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> parse and store as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> document." )
DefineEngineMethod(SimXMLDocument , popElement , void , () , "@brief Pop the last Element off the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" )
DefineEngineMethod(SimXMLDocument , prevAttribute , const char * , () , "@brief Get the name of the previous attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the current Element after <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> lastAttribute().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the previous attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see nextAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , pushChildElement , bool , (S32 index) , "@brief Push the child Element at the given index onto the stack, making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" " @param index Numerical index of Element being pushed." " @return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the Element was found and made the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n</a>" )
DefineEngineMethod(SimXMLDocument , pushFirstChildElement , bool , (const char *name) , "@brief Push the first child Element with the given name onto the stack)
DefineEngineMethod(SimXMLDocument , pushNewElement , void , (const char *name) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element with the given name as child of current Element " "and push it onto the Element stack making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@note This differs from addNewElement() in that it adds the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "child of the current Element (or <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of the document <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no Element exists).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@param name XML tag <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@see addNewElement()" )
DefineEngineMethod(SimXMLDocument , readComment , const char * , (S32 index) , "Gives the comment at the specified index, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">any.\n\n</a>" "Unlike addComment() that only works at the document level, readComment() may read " "comments from the document or any child Element. The current Element(or document " "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no Elements have been pushed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the stack) is the parent <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> any comments, and the " "provided index is the number of comments in <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> read back." " @param index Comment index number <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> query from the current Element <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack\n\n</a>" " @return <a href="/coding/class/classstring/">String</a> containing the comment, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no comment is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see addComment()" )
DefineEngineMethod(SimXMLDocument , removeText , void , () , "@brief Remove any text on the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use getText, removeText() will also remove any data from the " "current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" " @see addText()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see getText()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see addData()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see getData()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , reset , void , () , "@brief Set this document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> its default <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n\n</a>" "Clears all Elements from the documents. Equivalent <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> using clear()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@see clear()" )
DefineEngineMethod(SimXMLDocument , saveFile , bool , (const char *fileName) , "@brief Save document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name.\n\n</a>" "@param fileName Path and name of XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> save <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to.\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> was successfully saved." )
DefineEngineMethod(SimXMLDocument , setAttribute , void , (const char *attributeName, const char *value) , "@brief Set the attribute of the current Element on the stack <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value.\n\n</a>" "@param attributeName Name of attribute being <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">changed\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> New <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> assign <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute\n</a>" )
DefineEngineMethod(SimXMLDocument , setObjectAttributes , void , (const char *objectID) , "@brief Add the given <a href="/coding/class/classsimobject/">SimObject</a>'s fields as attributes of the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param objectID ID of <a href="/coding/class/classsimobject/">SimObject</a> being copied." )
Detailed Description
Public Functions
ConsoleDocClass(SimXMLDocument , "@brief <a href="/coding/class/classfile/">File</a> I/O object used <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> creating, reading , and writing XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">documents.\n\n</a>" "A <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> container of various XML nodes. The <a href="/coding/file/document_8h/#document_8h_1ac6ea5b168e3fe8c7fa532450fc9391f7">Document</a> level may contain " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> header, comments and child Elements. Elements may " "contain attributes, data(or text) and child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Elements.\n\n</a>" "You build <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Elements using addNewElement(). This makes the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element the current " "one you 're working with. You then use setAttribute() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add attributes <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the Element. " "You use addData() or addText() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> write <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the text area of an Element." " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Thanks <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Rex Hiebert <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example\n</a>" "//Given the following <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">XML\n</a>" "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" "<DataTables>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <table tableName=\"2DShapes\">\n" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"1\">Triangle</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"2\">Square</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"3\">Circle</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " </table>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <table tableName=\"3DShapes\">\n" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"1\">Pyramid</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"2\">Cube</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <rec <a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a>=\"3\">Sphere</rec>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " </table>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "</DataTables>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Using <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> by <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">itself\n</a>" "function readXmlExample(%filename)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a>() {};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.loadFile(%filename);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %xml.pushChildElement(\"DataTables\");\n" " %xml.pushFirstChildElement(\"table\");\n" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a>(true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"TABLE:\" SPC %xml.attribute(\"tableName\"));\n" " %xml.pushFirstChildElement(\"rec\");\n" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> (true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %<a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a> = %xml.attribute(\"id\");\n" " %desc = %xml.getData();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\" Shape\" SPC %<a href="/coding/file/win32cursorcontroller_8cpp/#win32cursorcontroller_8cpp_1ab38592509822a5f4674447022cc62efe">id</a> SPC %desc);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"rec\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.popElement();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"table\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Thanks <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> Scott Peal <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example\n</a>" "// Using <a href="/coding/class/classfileobject/">FileObject</a> in conjunction with <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">SimXMLDocument\n</a>" "// This example uses an XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> format <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">of:\n</a>" "// <Models>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// <Model category=\"\" name=\"\" path=\"\" />\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "// </Models>\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "function getModelsInCatagory()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> = \"./Catalog.xml\";\n" " %fo = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classfileobject/">FileObject</a>();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %text = \"\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a>(%fo.openForRead(%<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a>))\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a>(!%fo.isEOF())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %text = %text @ %fo.readLine();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%fo.isEOF()) %text = %text @ \"\\n\";\n" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">else\n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Unable <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> locate the file: \" @ %file);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %fo.delete();\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " %xml = <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a>() {};\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " %xml.parse(%text);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // \"Get\" inside of the root element, \"Models\".\n" " %xml.pushChildElement(0);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " // \"Get\" into the first child <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">element\n</a>" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (%xml.pushFirstChildElement(\"Model\"))\n" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a0e48c1f64b558d03d870367324920354">while</a> (true)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " {\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // Here, <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1acb559820d9ca11295b4500f179ef6392">i</a> read the element's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attributes.\n</a>" " // You might want <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> save these values in an array or call the %xml.getElementValue()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " // <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> you have <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> different XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">structure.\n\n</a>" " %catagory = %xml.attribute(\"catagory\");\n" " %name = %xml.attribute(\"name\");\n" " %path = %xml.attribute(\"path\");\n\n" " // now, read the next \"Model\"\n" " <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> (!%xml.nextSiblingElement(\"Model\")) break;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " }\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">endtsexample\n\n</a>" "@note <a href="/coding/class/classsimxmldocument/">SimXMLDocument</a> is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> wrapper around TinyXml, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> standard XML library. If you 're familiar " "with its concepts, you 'll find they also apply <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">here.\n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">FileObject\n\n</a>" " @ingroup <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">FileSystem\n</a>" )
DefineEngineMethod(SimXMLDocument , addComment , void , (const char *comment) , "@brief Add the given comment as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document.\n\n</a>" "@param comment <a href="/coding/class/classstring/">String</a> containing the comment." "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> XML document with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> header)
DefineEngineMethod(SimXMLDocument , addData , void , (const char *text) , "@brief Add the given text as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use getData() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> retrieve any text from the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "addData() and addText() may be used interchangeably. As there is no " "difference between data and text)
DefineEngineMethod(SimXMLDocument , addHeader , void , () , "@brief Add <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> XML header <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document.\n\n</a>" "Sometimes called <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> declaration)
DefineEngineMethod(SimXMLDocument , addNewElement , void , (const char *name) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element with the given name as child of current Element's " "parent and push it onto the Element stack making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@note This differs from pushNewElement() in that it adds the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the " "current Element's parent (or document <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> there is no parent Element). This makes " "the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> sibling of the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@param name XML tag <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@see pushNewElement()" )
DefineEngineMethod(SimXMLDocument , addText , void , (const char *text) )
DefineEngineMethod(SimXMLDocument , attribute , const char * , (const char *attributeName) , "@brief Get <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> string attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The attribute string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> found. Otherwise returns an empty <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n</a>" )
DefineEngineMethod(SimXMLDocument , attributeExists , bool , (const char *attributeName) , "@brief Tests <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the requested attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exists.\n\n</a>" "@param attributeName Name of attribute being queried <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">for.\n\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the attribute exists." )
DefineEngineMethod(SimXMLDocument , attributeF32 , F32 , (const char *attributeName) , "(string attributeName)" "@brief Get float attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the given attribute in the form of <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">float.\n</a>" "@deprecated Use attribute()." )
DefineEngineMethod(SimXMLDocument , attributeS32 , S32 , (const char *attributeName) , "(string attributeName)" "@brief Get int attribute from the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param attributeName Name of attribute <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">retrieve.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> of the given attribute in the form of an <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">integer.\n</a>" "@deprecated Use attribute()." )
DefineEngineMethod(SimXMLDocument , clear , void , () , "@brief Set this document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> its default <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n\n</a>" "Clears all Elements from the documents. Equivalent <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> using reset()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@see reset()" )
DefineEngineMethod(SimXMLDocument , clearError , void , () , "@brief Clear the last error <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">description.\n\n</a>" )
DefineEngineMethod(SimXMLDocument , elementValue , const char * , () , "@brief Get the Element's <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> it <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">exists.\n\n</a>" "Usually returns the text from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@return The <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> from the Element, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." )
DefineEngineMethod(SimXMLDocument , firstAttribute , const char * , () , "@brief Obtain the name of the current Element's first <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute.\n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the first attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see nextAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see prevAttribute()" )
DefineEngineMethod(SimXMLDocument , getData , const char * , () , "@brief Gets the text from the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use addData() <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> add text <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "getData() and getText() may be used interchangeably. As there is no " "difference between data and text)
DefineEngineMethod(SimXMLDocument , getErrorDesc , const char * , () , "@brief Get last error <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">description.\n\n</a>" "@return A string of the last error message." )
DefineEngineMethod(SimXMLDocument , getText , const char * , () )
DefineEngineMethod(SimXMLDocument , lastAttribute , const char * , () , "@brief Obtain the name of the current Element's last <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute.\n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the last attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see prevAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , loadFile , bool , (const char *fileName) , "@brief Load in given filename and prepare it <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">use.\n\n</a>" "@note Clears the current document's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">contents.\n\n</a>" "@param fileName Name and path of XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">document\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> was loaded successfully." )
DefineEngineMethod(SimXMLDocument , nextAttribute , const char * , () , "@brief Get the name of the next attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the current Element after <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> firstAttribute().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the next attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see prevAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , nextSiblingElement , bool , (const char *name) , "@brief Put the next sibling Element with the given name on the stack, making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" " @param name <a href="/coding/class/classstring/">String</a> containing name of the next sibling." " @return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the Element was found and made the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n</a>" )
DefineEngineMethod(SimXMLDocument , parse , void , (const char *xmlString) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> document from <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">string.\n\n</a>" "@note Clears the current document's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">contents.\n\n</a>" "@param xmlString Valid XML <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> parse and store as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> document." )
DefineEngineMethod(SimXMLDocument , popElement , void , () , "@brief Pop the last Element off the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" )
DefineEngineMethod(SimXMLDocument , prevAttribute , const char * , () , "@brief Get the name of the previous attribute <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the current Element after <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> call <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> lastAttribute().\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@return <a href="/coding/class/classstring/">String</a> containing the previous attribute's name, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> none is found." " @see lastAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see firstAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see nextAttribute()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , pushChildElement , bool , (S32 index) , "@brief Push the child Element at the given index onto the stack, making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" " @param index Numerical index of Element being pushed." " @return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the Element was found and made the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n</a>" )
DefineEngineMethod(SimXMLDocument , pushFirstChildElement , bool , (const char *name) , "@brief Push the first child Element with the given name onto the stack)
DefineEngineMethod(SimXMLDocument , pushNewElement , void , (const char *name) , "@brief Create <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> element with the given name as child of current Element " "and push it onto the Element stack making it the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">one.\n\n</a>" "@note This differs from addNewElement() in that it adds the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> Element as <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> " "child of the current Element (or <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> child of the document <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no Element exists).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@param name XML tag <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n</a>" "@see addNewElement()" )
DefineEngineMethod(SimXMLDocument , readComment , const char * , (S32 index) , "Gives the comment at the specified index, <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">any.\n\n</a>" "Unlike addComment() that only works at the document level, readComment() may read " "comments from the document or any child Element. The current Element(or document " "<a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no Elements have been pushed <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the stack) is the parent <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> any comments, and the " "provided index is the number of comments in <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> read back." " @param index Comment index number <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> query from the current Element <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack\n\n</a>" " @return <a href="/coding/class/classstring/">String</a> containing the comment, or an empty string <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> no comment is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">found.\n\n</a>" " @see addComment()" )
DefineEngineMethod(SimXMLDocument , removeText , void , () , "@brief Remove any text on the current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" "Use getText, removeText() will also remove any data from the " "current <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Element.\n\n</a>" " @see addText()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see getText()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see addData()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @see getData()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" )
DefineEngineMethod(SimXMLDocument , reset , void , () , "@brief Set this document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> its default <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state.\n\n</a>" "Clears all Elements from the documents. Equivalent <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> using clear()\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "@see clear()" )
DefineEngineMethod(SimXMLDocument , saveFile , bool , (const char *fileName) , "@brief Save document <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name.\n\n</a>" "@param fileName Path and name of XML <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> save <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">to.\n</a>" "@return True <a href="/coding/file/tsmeshintrinsics_8cpp/#tsmeshintrinsics_8cpp_1a4e4fa7e3399708e0777b5308db01278c">if</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> was successfully saved." )
DefineEngineMethod(SimXMLDocument , setAttribute , void , (const char *attributeName, const char *value) , "@brief Set the attribute of the current Element on the stack <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the given <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">value.\n\n</a>" "@param attributeName Name of attribute being <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">changed\n</a>" "@param <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> New <a href="/coding/file/pointer_8h/#pointer_8h_1a32aff7c6c4cd253fdf6563677afab5ce">value</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> assign <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">attribute\n</a>" )
DefineEngineMethod(SimXMLDocument , setObjectAttributes , void , (const char *objectID) , "@brief Add the given <a href="/coding/class/classsimobject/">SimObject</a>'s fields as attributes of the current Element on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">stack.\n\n</a>" "@param objectID ID of <a href="/coding/class/classsimobject/">SimObject</a> being copied." )
IMPLEMENT_CONOBJECT(SimXMLDocument )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#include "tinyxml/tinyxml.h" 25 26//----------------------------------------------------------------------------- 27// Console implementation of STL map. 28//----------------------------------------------------------------------------- 29 30#include "core/frameAllocator.h" 31#include "console/simBase.h" 32#include "console/consoleInternal.h" 33#include "console/SimXMLDocument.h" 34#include "console/engineAPI.h" 35 36IMPLEMENT_CONOBJECT(SimXMLDocument); 37 38ConsoleDocClass( SimXMLDocument, 39 "@brief File I/O object used for creating, reading, and writing XML documents.\n\n" 40 41 "A SimXMLDocument is a container of various XML nodes. The Document level may contain " 42 "a header (sometimes called a declaration), comments and child Elements. Elements may " 43 "contain attributes, data (or text) and child Elements.\n\n" 44 45 "You build new Elements using addNewElement(). This makes the new Element the current " 46 "one you're working with. You then use setAttribute() to add attributes to the Element. " 47 "You use addData() or addText() to write to the text area of an Element." 48 49 "@tsexample\n" 50 "// Thanks to Rex Hiebert for this example\n" 51 "// Given the following XML\n" 52 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 53 "<DataTables>\n" 54 " <table tableName=\"2DShapes\">\n" 55 " <rec id=\"1\">Triangle</rec>\n" 56 " <rec id=\"2\">Square</rec>\n" 57 " <rec id=\"3\">Circle</rec>\n" 58 " </table>\n" 59 " <table tableName=\"3DShapes\">\n" 60 " <rec id=\"1\">Pyramid</rec>\n" 61 " <rec id=\"2\">Cube</rec>\n" 62 " <rec id=\"3\">Sphere</rec>\n" 63 " </table>\n" 64 "</DataTables>\n\n" 65 "// Using SimXMLDocument by itself\n" 66 "function readXmlExample(%filename)\n" 67 "{\n" 68 " %xml = new SimXMLDocument() {};\n" 69 " %xml.loadFile(%filename);\n\n" 70 " %xml.pushChildElement(\"DataTables\");\n" 71 " %xml.pushFirstChildElement(\"table\");\n" 72 " while(true)\n" 73 " {\n" 74 " echo(\"TABLE:\" SPC %xml.attribute(\"tableName\"));\n" 75 " %xml.pushFirstChildElement(\"rec\");\n" 76 " while (true)\n" 77 " {\n" 78 " %id = %xml.attribute(\"id\");\n" 79 " %desc = %xml.getData();\n" 80 " echo(\" Shape\" SPC %id SPC %desc);\n" 81 " if (!%xml.nextSiblingElement(\"rec\")) break;\n" 82 " }\n" 83 " %xml.popElement();\n" 84 " if (!%xml.nextSiblingElement(\"table\")) break;\n" 85 " }\n" 86 "}\n\n" 87 88 "// Thanks to Scott Peal for this example\n" 89 "// Using FileObject in conjunction with SimXMLDocument\n" 90 "// This example uses an XML file with a format of:\n" 91 "// <Models>\n" 92 "// <Model category=\"\" name=\"\" path=\"\" />\n" 93 "// </Models>\n" 94 "function getModelsInCatagory()\n" 95 "{\n" 96 " %file = \"./Catalog.xml\";\n" 97 " %fo = new FileObject();\n" 98 " %text = \"\";\n\n" 99 " if(%fo.openForRead(%file))\n" 100 " {\n" 101 " while(!%fo.isEOF())\n" 102 " {\n" 103 " %text = %text @ %fo.readLine();\n" 104 " if (!%fo.isEOF()) %text = %text @ \"\\n\";\n" 105 " }\n" 106 " }\n" 107 " else\n" 108 " {\n" 109 " echo(\"Unable to locate the file: \" @ %file);\n" 110 " }\n\n" 111 " %fo.delete();\n\n" 112 " %xml = new SimXMLDocument() {};\n" 113 " %xml.parse(%text);\n" 114 " // \"Get\" inside of the root element, \"Models\".\n" 115 " %xml.pushChildElement(0);\n\n" 116 " // \"Get\" into the first child element\n" 117 " if (%xml.pushFirstChildElement(\"Model\"))\n" 118 " {\n" 119 " while (true)\n" 120 " {\n" 121 " // \n" 122 " // Here, i read the element's attributes.\n" 123 " // You might want to save these values in an array or call the %xml.getElementValue()\n" 124 " // if you have a different XML structure.\n\n" 125 " %catagory = %xml.attribute(\"catagory\");\n" 126 " %name = %xml.attribute(\"name\");\n" 127 " %path = %xml.attribute(\"path\");\n\n" 128 " // now, read the next \"Model\"\n" 129 " if (!%xml.nextSiblingElement(\"Model\")) break;\n" 130 " }\n" 131 " }\n" 132 "}\n" 133 "@endtsexample\n\n" 134 135 "@note SimXMLDocument is a wrapper around TinyXml, a standard XML library. If you're familiar " 136 "with its concepts, you'll find they also apply here.\n\n" 137 138 "@see FileObject\n\n" 139 140 "@ingroup FileSystem\n" 141); 142 143// ----------------------------------------------------------------------------- 144// Constructor. 145// ----------------------------------------------------------------------------- 146SimXMLDocument::SimXMLDocument(): 147m_qDocument(0), 148m_CurrentAttribute(0) 149{ 150} 151 152// ----------------------------------------------------------------------------- 153// Destructor. 154// ----------------------------------------------------------------------------- 155SimXMLDocument::~SimXMLDocument() 156{ 157} 158 159// ----------------------------------------------------------------------------- 160// Included for completeness. 161// ----------------------------------------------------------------------------- 162bool SimXMLDocument::processArguments(S32 argc, ConsoleValueRef *argv) 163{ 164 return argc == 0; 165} 166 167// ----------------------------------------------------------------------------- 168// Script constructor. 169// ----------------------------------------------------------------------------- 170bool SimXMLDocument::onAdd() 171{ 172 if(!Parent::onAdd()) 173 { 174 return false; 175 } 176 177 if(!m_qDocument) 178 { 179 m_qDocument = new TiXmlDocument(); 180 } 181 return true; 182} 183 184// ----------------------------------------------------------------------------- 185// Script destructor. 186// ----------------------------------------------------------------------------- 187void SimXMLDocument::onRemove() 188{ 189 Parent::onRemove(); 190 if(m_qDocument) 191 { 192 m_qDocument->Clear(); 193 delete(m_qDocument); 194 } 195} 196 197// ----------------------------------------------------------------------------- 198// Initialize peristent fields (datablocks). 199// ----------------------------------------------------------------------------- 200void SimXMLDocument::initPersistFields() 201{ 202 Parent::initPersistFields(); 203} 204 205// ----------------------------------------------------------------------------- 206// Set this to default state at construction. 207// ----------------------------------------------------------------------------- 208void SimXMLDocument::reset(void) 209{ 210 m_qDocument->Clear(); 211 m_paNode.clear(); 212 m_CurrentAttribute = 0; 213} 214 215DefineEngineMethod( SimXMLDocument, reset, void, (),, 216 "@brief Set this document to its default state.\n\n" 217 218 "Clears all Elements from the documents. Equivalent to using clear()\n\n" 219 220 "@see clear()") 221{ 222 object->reset(); 223} 224 225// ----------------------------------------------------------------------------- 226// Get true if file loads successfully. 227// ----------------------------------------------------------------------------- 228bool SimXMLDocument::loadFile(const char* rFileName) 229{ 230 reset(); 231 return m_qDocument->LoadFile(rFileName); 232} 233 234DefineEngineMethod( SimXMLDocument, loadFile, bool, ( const char* fileName ),, 235 "@brief Load in given filename and prepare it for use.\n\n" 236 "@note Clears the current document's contents.\n\n" 237 "@param fileName Name and path of XML document\n" 238 "@return True if the file was loaded successfully.") 239{ 240 return object->loadFile( fileName ); 241} 242 243// ----------------------------------------------------------------------------- 244// Get true if file saves successfully. 245// ----------------------------------------------------------------------------- 246bool SimXMLDocument::saveFile(const char* rFileName) 247{ 248 return m_qDocument->SaveFile( rFileName ); 249} 250 251// ----------------------------------------------------------------------------- 252// Get true if file saves successfully to string. 253// ----------------------------------------------------------------------------- 254bool SimXMLDocument::saveToString(String& str) 255{ 256 TiXmlPrinter printer; 257 bool ret = m_qDocument->Accept( &printer ); 258 if (ret) 259 str = printer.CStr(); 260 return ret; 261} 262 263DefineEngineMethod( SimXMLDocument, saveFile, bool, ( const char* fileName ),, 264 "@brief Save document to the given file name.\n\n" 265 "@param fileName Path and name of XML file to save to.\n" 266 "@return True if the file was successfully saved.") 267{ 268 return object->saveFile( fileName ); 269} 270 271// ----------------------------------------------------------------------------- 272// Get true if XML text parses correctly. 273// ----------------------------------------------------------------------------- 274S32 SimXMLDocument::parse(const char* rText) 275{ 276 reset(); 277 m_qDocument->Parse( rText ); 278 return 1; 279} 280 281DefineEngineMethod( SimXMLDocument, parse, void, ( const char* xmlString ),, 282 "@brief Create a document from a XML string.\n\n" 283 "@note Clears the current document's contents.\n\n" 284 "@param xmlString Valid XML to parse and store as a document.") 285{ 286 object->parse( xmlString ); 287} 288 289// ----------------------------------------------------------------------------- 290// Clear contents of XML document. 291// ----------------------------------------------------------------------------- 292void SimXMLDocument::clear(void) 293{ 294 reset(); 295} 296 297DefineEngineMethod( SimXMLDocument, clear, void, (),, 298 "@brief Set this document to its default state.\n\n" 299 300 "Clears all Elements from the documents. Equivalent to using reset()\n\n" 301 302 "@see reset()") 303{ 304 object->clear(); 305} 306 307// ----------------------------------------------------------------------------- 308// Get error description of XML document. 309// ----------------------------------------------------------------------------- 310const char* SimXMLDocument::getErrorDesc(void) const 311{ 312 if(!m_qDocument) 313 { 314 return StringTable->insert("No document"); 315 } 316 return m_qDocument->ErrorDesc(); 317} 318 319DefineEngineMethod( SimXMLDocument, getErrorDesc, const char*, (),, 320 "@brief Get last error description.\n\n" 321 "@return A string of the last error message.") 322{ 323 return object->getErrorDesc(); 324} 325 326// ----------------------------------------------------------------------------- 327// Clear error description of this. 328// ----------------------------------------------------------------------------- 329void SimXMLDocument::clearError(void) 330{ 331 m_qDocument->ClearError(); 332} 333 334DefineEngineMethod( SimXMLDocument, clearError, void, (),, 335 "@brief Clear the last error description.\n\n") 336{ 337 object->clearError(); 338} 339 340// ----------------------------------------------------------------------------- 341// Get true if first child element was successfully pushed onto stack. 342// ----------------------------------------------------------------------------- 343bool SimXMLDocument::pushFirstChildElement(const char* rName) 344{ 345 // Clear the current attribute pointer 346 m_CurrentAttribute = 0; 347 348 // Push the first element found under the current element of the given name 349 TiXmlElement* pElement; 350 if(!m_paNode.empty()) 351 { 352 const S32 iLastElement = m_paNode.size() - 1; 353 TiXmlElement* pNode = m_paNode[iLastElement]; 354 if(!pNode) 355 { 356 return false; 357 } 358 pElement = pNode->FirstChildElement(rName); 359 } 360 else 361 { 362 if(!m_qDocument) 363 { 364 return false; 365 } 366 pElement = m_qDocument->FirstChildElement(rName); 367 } 368 369 if(!pElement) 370 { 371 return false; 372 } 373 m_paNode.push_back(pElement); 374 return true; 375} 376 377DefineEngineMethod( SimXMLDocument, pushFirstChildElement, bool, ( const char* name ),, 378 "@brief Push the first child Element with the given name onto the stack, making it the current Element.\n\n" 379 380 "@param name String containing name of the child Element.\n" 381 "@return True if the Element was found and made the current one.\n" 382 383 "@tsexample\n" 384 "// Using the following test.xml file as an example:\n" 385 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 386 "// <NewElement>Some text</NewElement>\n\n" 387 388 "// Load in the file\n" 389 "%x = new SimXMLDocument();\n" 390 "%x.loadFile(\"test.xml\");\n\n" 391 392 "// Make the first Element the current one\n" 393 "%x.pushFirstChildElement(\"NewElement\");\n\n" 394 395 "// Store the current Element's text ('Some text' in this example)\n" 396 "// into 'result'\n" 397 "%result = %x.getText();\n" 398 "echo( %result );\n" 399 "@endtsexample\n\n") 400{ 401 return object->pushFirstChildElement( name ); 402} 403 404// ----------------------------------------------------------------------------- 405// Get true if first child element was successfully pushed onto stack. 406// ----------------------------------------------------------------------------- 407bool SimXMLDocument::pushChildElement(S32 index) 408{ 409 // Clear the current attribute pointer 410 m_CurrentAttribute = 0; 411 412 // Push the first element found under the current element of the given name 413 TiXmlElement* pElement; 414 if(!m_paNode.empty()) 415 { 416 const S32 iLastElement = m_paNode.size() - 1; 417 TiXmlElement* pNode = m_paNode[iLastElement]; 418 if(!pNode) 419 { 420 return false; 421 } 422 pElement = pNode->FirstChildElement(); 423 for( S32 i = 0; i < index; i++ ) 424 { 425 if( !pElement ) 426 return false; 427 428 pElement = pElement->NextSiblingElement(); 429 } 430 } 431 else 432 { 433 if(!m_qDocument) 434 { 435 return false; 436 } 437 pElement = m_qDocument->FirstChildElement(); 438 for( S32 i = 0; i < index; i++ ) 439 { 440 if( !pElement ) 441 return false; 442 443 pElement = pElement->NextSiblingElement(); 444 } 445 } 446 447 if(!pElement) 448 { 449 return false; 450 } 451 m_paNode.push_back(pElement); 452 return true; 453} 454 455DefineEngineMethod( SimXMLDocument, pushChildElement, bool, ( S32 index ),, 456 "@brief Push the child Element at the given index onto the stack, making it the current one.\n\n" 457 "@param index Numerical index of Element being pushed." 458 "@return True if the Element was found and made the current one.\n") 459{ 460 return object->pushChildElement( index ); 461} 462 463// ----------------------------------------------------------------------------- 464// Convert top stack element into its next sibling element. 465// ----------------------------------------------------------------------------- 466bool SimXMLDocument::nextSiblingElement(const char* rName) 467{ 468 // Clear the current attribute pointer 469 m_CurrentAttribute = 0; 470 471 // Attempt to find the next sibling element 472 if(m_paNode.empty()) 473 { 474 return false; 475 } 476 const S32 iLastElement = m_paNode.size() - 1; 477 TiXmlElement*& pElement = m_paNode[iLastElement]; 478 if(!pElement) 479 { 480 return false; 481 } 482 483 pElement = pElement->NextSiblingElement(rName); 484 if(!pElement) 485 { 486 return false; 487 } 488 489 return true; 490} 491 492DefineEngineMethod( SimXMLDocument, nextSiblingElement, bool, ( const char* name ),, 493 "@brief Put the next sibling Element with the given name on the stack, making it the current one.\n\n" 494 "@param name String containing name of the next sibling." 495 "@return True if the Element was found and made the current one.\n") 496{ 497 return object->nextSiblingElement( name ); 498} 499 500// ----------------------------------------------------------------------------- 501// Get element value if it exists. Used to extract a text node from the element. 502// for example. 503// ----------------------------------------------------------------------------- 504const char* SimXMLDocument::elementValue() 505{ 506 if(m_paNode.empty()) 507 { 508 return StringTable->EmptyString(); 509 } 510 const S32 iLastElement = m_paNode.size() - 1; 511 TiXmlElement* pNode = m_paNode[iLastElement]; 512 if(!pNode) 513 { 514 return StringTable->EmptyString(); 515 } 516 517 return pNode->Value(); 518} 519 520DefineEngineMethod( SimXMLDocument, elementValue, const char*, (),, 521 "@brief Get the Element's value if it exists.\n\n" 522 "Usually returns the text from the Element.\n" 523 "@return The value from the Element, or an empty string if none is found.") 524{ 525 return object->elementValue(); 526} 527 528// ----------------------------------------------------------------------------- 529// Pop last element off of stack. 530// ----------------------------------------------------------------------------- 531void SimXMLDocument::popElement(void) 532{ 533 m_paNode.pop_back(); 534} 535 536DefineEngineMethod( SimXMLDocument, popElement, void, (),, 537 "@brief Pop the last Element off the stack.\n\n") 538{ 539 object->popElement(); 540} 541 542// ----------------------------------------------------------------------------- 543// Get attribute value if it exists. 544// ----------------------------------------------------------------------------- 545const char* SimXMLDocument::attribute(const char* rAttribute) 546{ 547 if(m_paNode.empty()) 548 { 549 return StringTable->EmptyString(); 550 } 551 const S32 iLastElement = m_paNode.size() - 1; 552 TiXmlElement* pNode = m_paNode[iLastElement]; 553 if(!pNode) 554 { 555 return StringTable->EmptyString(); 556 } 557 558 if(!pNode->Attribute(rAttribute)) 559 { 560 return StringTable->EmptyString(); 561 } 562 563 return pNode->Attribute(rAttribute); 564} 565 566DefineEngineMethod( SimXMLDocument, attribute, const char*, ( const char* attributeName ),, 567 "@brief Get a string attribute from the current Element on the stack.\n\n" 568 "@param attributeName Name of attribute to retrieve.\n" 569 "@return The attribute string if found. Otherwise returns an empty string.\n") 570{ 571 return object->attribute( attributeName ); 572} 573 574// These two methods don't make a lot of sense the way TS works. Leaving them in for backwards-compatibility. 575DefineEngineMethod( SimXMLDocument, attributeF32, F32, (const char * attributeName), , "(string attributeName)" 576 "@brief Get float attribute from the current Element on the stack.\n\n" 577 "@param attributeName Name of attribute to retrieve.\n" 578 "@return The value of the given attribute in the form of a float.\n" 579 "@deprecated Use attribute().") 580{ 581 return dAtof( object->attribute( attributeName ) ); 582} 583 584DefineEngineMethod(SimXMLDocument, attributeS32, S32, (const char * attributeName), , "(string attributeName)" 585 "@brief Get int attribute from the current Element on the stack.\n\n" 586 "@param attributeName Name of attribute to retrieve.\n" 587 "@return The value of the given attribute in the form of an integer.\n" 588 "@deprecated Use attribute().") 589{ 590 return dAtoi( object->attribute( attributeName ) ); 591} 592 593// ----------------------------------------------------------------------------- 594// Get true if given attribute exists. 595// ----------------------------------------------------------------------------- 596bool SimXMLDocument::attributeExists(const char* rAttribute) 597{ 598 if(m_paNode.empty()) 599 { 600 return false; 601 } 602 const S32 iLastElement = m_paNode.size() - 1; 603 TiXmlElement* pNode = m_paNode[iLastElement]; 604 if(!pNode) 605 { 606 return false; 607 } 608 609 if(!pNode->Attribute(rAttribute)) 610 { 611 return false; 612 } 613 614 return true; 615} 616 617DefineEngineMethod( SimXMLDocument, attributeExists, bool, ( const char* attributeName ),, 618 "@brief Tests if the requested attribute exists.\n\n" 619 "@param attributeName Name of attribute being queried for.\n\n" 620 "@return True if the attribute exists.") 621{ 622 return object->attributeExists( attributeName ); 623} 624 625// ----------------------------------------------------------------------------- 626// Obtain the name of the current element's first attribute 627// ----------------------------------------------------------------------------- 628const char* SimXMLDocument::firstAttribute() 629{ 630 // Get the current element 631 if(m_paNode.empty()) 632 { 633 return StringTable->EmptyString(); 634 } 635 const S32 iLastElement = m_paNode.size() - 1; 636 TiXmlElement* pNode = m_paNode[iLastElement]; 637 if(!pNode) 638 { 639 return StringTable->EmptyString(); 640 } 641 642 // Gets its first attribute, if any 643 m_CurrentAttribute = pNode->FirstAttribute(); 644 if(!m_CurrentAttribute) 645 { 646 return StringTable->EmptyString(); 647 } 648 649 return m_CurrentAttribute->Name(); 650} 651 652DefineEngineMethod( SimXMLDocument, firstAttribute, const char*, (),, 653 "@brief Obtain the name of the current Element's first attribute.\n\n" 654 "@return String containing the first attribute's name, or an empty string if none is found.\n\n" 655 "@see nextAttribute()\n" 656 "@see lastAttribute()\n" 657 "@see prevAttribute()") 658{ 659 return object->firstAttribute(); 660} 661 662// ----------------------------------------------------------------------------- 663// Obtain the name of the current element's last attribute 664// ----------------------------------------------------------------------------- 665const char* SimXMLDocument::lastAttribute() 666{ 667 // Get the current element 668 if(m_paNode.empty()) 669 { 670 return StringTable->EmptyString(); 671 } 672 const S32 iLastElement = m_paNode.size() - 1; 673 TiXmlElement* pNode = m_paNode[iLastElement]; 674 if(!pNode) 675 { 676 return StringTable->EmptyString(); 677 } 678 679 // Gets its last attribute, if any 680 m_CurrentAttribute = pNode->LastAttribute(); 681 if(!m_CurrentAttribute) 682 { 683 return StringTable->EmptyString(); 684 } 685 686 return m_CurrentAttribute->Name(); 687} 688 689DefineEngineMethod( SimXMLDocument, lastAttribute, const char*, (),, 690 "@brief Obtain the name of the current Element's last attribute.\n\n" 691 "@return String containing the last attribute's name, or an empty string if none is found.\n\n" 692 "@see prevAttribute()\n" 693 "@see firstAttribute()\n" 694 "@see lastAttribute()\n") 695{ 696 return object->lastAttribute(); 697} 698 699// ----------------------------------------------------------------------------- 700// Get the name of the next attribute for the current element after a call 701// to firstAttribute(). 702// ----------------------------------------------------------------------------- 703const char* SimXMLDocument::nextAttribute() 704{ 705 if(!m_CurrentAttribute) 706 { 707 return StringTable->EmptyString(); 708 } 709 710 // Gets its next attribute, if any 711 m_CurrentAttribute = m_CurrentAttribute->Next(); 712 if(!m_CurrentAttribute) 713 { 714 return StringTable->EmptyString(); 715 } 716 717 return m_CurrentAttribute->Name(); 718} 719 720DefineEngineMethod( SimXMLDocument, nextAttribute, const char*, (),, 721 "@brief Get the name of the next attribute for the current Element after a call to firstAttribute().\n\n" 722 "@return String containing the next attribute's name, or an empty string if none is found." 723 "@see firstAttribute()\n" 724 "@see lastAttribute()\n" 725 "@see prevAttribute()\n") 726{ 727 return object->nextAttribute(); 728} 729 730// ----------------------------------------------------------------------------- 731// Get the name of the previous attribute for the current element after a call 732// to lastAttribute(). 733// ----------------------------------------------------------------------------- 734const char* SimXMLDocument::prevAttribute() 735{ 736 if(!m_CurrentAttribute) 737 { 738 return StringTable->EmptyString(); 739 } 740 741 // Gets its next attribute, if any 742 m_CurrentAttribute = m_CurrentAttribute->Previous(); 743 if(!m_CurrentAttribute) 744 { 745 return StringTable->EmptyString(); 746 } 747 748 return m_CurrentAttribute->Name(); 749} 750 751DefineEngineMethod( SimXMLDocument, prevAttribute, const char*, (),, 752 "@brief Get the name of the previous attribute for the current Element after a call to lastAttribute().\n\n" 753 "@return String containing the previous attribute's name, or an empty string if none is found." 754 "@see lastAttribute()\n" 755 "@see firstAttribute()\n" 756 "@see nextAttribute()\n") 757{ 758 return object->prevAttribute(); 759} 760 761// ----------------------------------------------------------------------------- 762// Set attribute of top stack element to given value. 763// ----------------------------------------------------------------------------- 764void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal) 765{ 766 if(m_paNode.empty()) 767 { 768 return; 769 } 770 771 const S32 iLastElement = m_paNode.size() - 1; 772 TiXmlElement* pElement = m_paNode[iLastElement]; 773 if(!pElement) 774 { 775 return; 776 } 777 pElement->SetAttribute(rAttribute, rVal); 778} 779DefineEngineMethod( SimXMLDocument, setAttribute, void, ( const char* attributeName, const char* value ),, 780 "@brief Set the attribute of the current Element on the stack to the given value.\n\n" 781 "@param attributeName Name of attribute being changed\n" 782 "@param value New value to assign to the attribute\n") 783{ 784 object->setAttribute( attributeName, value ); 785} 786 787// ----------------------------------------------------------------------------- 788// Set attribute of top stack element to given value. 789// ----------------------------------------------------------------------------- 790void SimXMLDocument::setObjectAttributes(const char* objectID) 791{ 792 if( !objectID || !objectID[0] ) 793 return; 794 795 if(m_paNode.empty()) 796 return; 797 798 SimObject *pObject = Sim::findObject( objectID ); 799 800 if( pObject == NULL ) 801 return; 802 803 const S32 iLastElement = m_paNode.size() - 1; 804 TiXmlElement* pElement = m_paNode[iLastElement]; 805 if(!pElement) 806 return; 807 808 char textbuf[1024]; 809 TiXmlElement field( "Field" ); 810 TiXmlElement group( "FieldGroup" ); 811 pElement->SetAttribute( "Name", pObject->getName() ); 812 813 814 // Iterate over our filed list and add them to the XML document... 815 AbstractClassRep::FieldList fieldList = pObject->getFieldList(); 816 AbstractClassRep::FieldList::iterator itr; 817 for(itr = fieldList.begin(); itr != fieldList.end(); itr++) 818 { 819 820 if( itr->type == AbstractClassRep::DeprecatedFieldType || 821 itr->type == AbstractClassRep::StartGroupFieldType || 822 itr->type == AbstractClassRep::EndGroupFieldType) continue; 823 824 // Not an Array 825 if(itr->elementCount == 1) 826 { 827 // get the value of the field as a string. 828 ConsoleBaseType *cbt = ConsoleBaseType::getType(itr->type); 829 830 const char *val = Con::getData(itr->type, (void *) (((const char *)pObject) + itr->offset), 0, itr->table, itr->flag); 831 832 // Make a copy for the field check. 833 if (!val) 834 continue; 835 836 FrameTemp<char> valCopy( dStrlen( val ) + 1 ); 837 dStrcpy( (char *)valCopy, val, valCopy.size() ); 838 839 if (!pObject->writeField(itr->pFieldname, valCopy)) 840 continue; 841 842 val = valCopy; 843 844 845 expandEscape(textbuf, val); 846 847 if( !pObject->writeField( itr->pFieldname, textbuf ) ) 848 continue; 849 850 field.SetValue( "Property" ); 851 field.SetAttribute( "name", itr->pFieldname ); 852 if( cbt != NULL ) 853 field.SetAttribute( "type", cbt->getTypeName() ); 854 else 855 field.SetAttribute( "type", "TypeString" ); 856 field.SetAttribute( "data", textbuf ); 857 858 pElement->InsertEndChild( field ); 859 860 continue; 861 } 862 } 863 864 //// IS An Array 865 //for(U32 j = 0; S32(j) < f->elementCount; j++) 866 //{ 867 868 // // If the start of a group create an element for the group and 869 // // the our chache to it 870 // const char *val = Con::getData(itr->type, (void *) (((const char *)pObject) + itr->offset), j, itr->table, itr->flag); 871 872 // // Make a copy for the field check. 873 // if (!val) 874 // continue; 875 876 // FrameTemp<char> valCopy( dStrlen( val ) + 1 ); 877 // dStrcpy( (char *)valCopy, val, valCopy.size() ); 878 879 // if (!pObject->writeField(itr->pFieldname, valCopy)) 880 // continue; 881 882 // val = valCopy; 883 884 // // get the value of the field as a string. 885 // ConsoleBaseType *cbt = ConsoleBaseType::getType(itr->type); 886 // const char * dstr = Con::getData(itr->type, (void *)(((const char *)pObject) + itr->offset), 0, itr->table, itr->flag); 887 // if(!dstr) 888 // dstr = ""; 889 // expandEscape(textbuf, dstr); 890 891 892 // if( !pObject->writeField( itr->pFieldname, dstr ) ) 893 // continue; 894 895 // field.SetValue( "Property" ); 896 // field.SetAttribute( "name", itr->pFieldname ); 897 // if( cbt != NULL ) 898 // field.SetAttribute( "type", cbt->getTypeName() ); 899 // else 900 // field.SetAttribute( "type", "TypeString" ); 901 // field.SetAttribute( "data", textbuf ); 902 903 // pElement->InsertEndChild( field ); 904 //} 905 906} 907 908DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* objectID ),, 909 "@brief Add the given SimObject's fields as attributes of the current Element on the stack.\n\n" 910 "@param objectID ID of SimObject being copied.") 911{ 912 object->setObjectAttributes( objectID ); 913} 914 915// ----------------------------------------------------------------------------- 916// Create a new element and set to child of current stack element. 917// New element is placed on top of element stack. 918// ----------------------------------------------------------------------------- 919void SimXMLDocument::pushNewElement(const char* rName) 920{ 921 TiXmlElement cElement( rName ); 922 TiXmlElement* pStackTop = 0; 923 if(m_paNode.empty()) 924 { 925 pStackTop = dynamic_cast<TiXmlElement*> 926 (m_qDocument->InsertEndChild( cElement ) ); 927 } 928 else 929 { 930 const S32 iFinalElement = m_paNode.size() - 1; 931 TiXmlElement* pNode = m_paNode[iFinalElement]; 932 if(!pNode) 933 { 934 return; 935 } 936 pStackTop = dynamic_cast<TiXmlElement*> 937 (pNode->InsertEndChild( cElement )); 938 } 939 if(!pStackTop) 940 { 941 return; 942 } 943 m_paNode.push_back(pStackTop); 944} 945 946DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),, 947 "@brief Create a new element with the given name as child of current Element " 948 "and push it onto the Element stack making it the current one.\n\n" 949 950 "@note This differs from addNewElement() in that it adds the new Element as a " 951 "child of the current Element (or a child of the document if no Element exists).\n\n" 952 953 "@param name XML tag for the new Element.\n" 954 955 "@see addNewElement()") 956{ 957 object->pushNewElement( name ); 958} 959 960// ----------------------------------------------------------------------------- 961// Create a new element and set to child of current stack element. 962// New element is placed on top of element stack. 963// ----------------------------------------------------------------------------- 964void SimXMLDocument::addNewElement(const char* rName) 965{ 966 TiXmlElement cElement( rName ); 967 TiXmlElement* pStackTop = 0; 968 if(m_paNode.empty()) 969 { 970 pStackTop = dynamic_cast<TiXmlElement*> 971 (m_qDocument->InsertEndChild( cElement )); 972 if(!pStackTop) 973 { 974 return; 975 } 976 m_paNode.push_back(pStackTop); 977 return; 978 } 979 980 const S32 iParentElement = m_paNode.size() - 2; 981 if(iParentElement < 0) 982 { 983 pStackTop = dynamic_cast<TiXmlElement*> 984 (m_qDocument->InsertEndChild( cElement )); 985 if(!pStackTop) 986 { 987 return; 988 } 989 m_paNode.push_back(pStackTop); 990 return; 991 } 992 else 993 { 994 TiXmlElement* pNode = m_paNode[iParentElement]; 995 if(!pNode) 996 { 997 return; 998 } 999 pStackTop = dynamic_cast<TiXmlElement*> 1000 (pNode->InsertEndChild( cElement )); 1001 if(!pStackTop) 1002 { 1003 return; 1004 } 1005 1006 // Overwrite top stack position. 1007 const S32 iFinalElement = m_paNode.size() - 1; 1008 m_paNode[iFinalElement] = pStackTop; 1009 //pNode = pStackTop; 1010 } 1011} 1012 1013DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),, 1014 "@brief Create a new element with the given name as child of current Element's " 1015 "parent and push it onto the Element stack making it the current one.\n\n" 1016 1017 "@note This differs from pushNewElement() in that it adds the new Element to the " 1018 "current Element's parent (or document if there is no parent Element). This makes " 1019 "the new Element a sibling of the current one.\n\n" 1020 1021 "@param name XML tag for the new Element.\n" 1022 1023 "@see pushNewElement()") 1024{ 1025 object->addNewElement( name ); 1026} 1027 1028// ----------------------------------------------------------------------------- 1029// Write XML document declaration. 1030// ----------------------------------------------------------------------------- 1031void SimXMLDocument::addHeader(void) 1032{ 1033 TiXmlDeclaration cDeclaration("1.0", "utf-8", "yes"); 1034 m_qDocument->InsertEndChild(cDeclaration); 1035} 1036 1037DefineEngineMethod( SimXMLDocument, addHeader, void, (),, 1038 "@brief Add a XML header to a document.\n\n" 1039 1040 "Sometimes called a declaration, you typically add a standard header to " 1041 "the document before adding any elements. SimXMLDocument always produces " 1042 "the following header:\n\n" 1043 "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n\n" 1044 1045 "@tsexample\n" 1046 "// Create a new XML document with just a header and single element.\n" 1047 "%x = new SimXMLDocument();\n" 1048 "%x.addHeader();\n" 1049 "%x.addNewElement(\"NewElement\");\n" 1050 "%x.saveFile(\"test.xml\");\n\n" 1051 "// Produces the following file:\n" 1052 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1053 "// <NewElement />\n" 1054 "@endtsexample\n\n") 1055{ 1056 object->addHeader(); 1057} 1058 1059void SimXMLDocument::addComment(const char* comment) 1060{ 1061 TiXmlComment cComment; 1062 cComment.SetValue(comment); 1063 m_qDocument->InsertEndChild(cComment); 1064} 1065 1066DefineEngineMethod(SimXMLDocument, addComment, void, ( const char* comment ),, 1067 "@brief Add the given comment as a child of the document.\n\n" 1068 "@param comment String containing the comment." 1069 1070 "@tsexample\n" 1071 "// Create a new XML document with a header, a comment and single element.\n" 1072 "%x = new SimXMLDocument();\n" 1073 "%x.addHeader();\n" 1074 "%x.addComment(\"This is a test comment\");\n" 1075 "%x.addNewElement(\"NewElement\");\n" 1076 "%x.saveFile(\"test.xml\");\n\n" 1077 "// Produces the following file:\n" 1078 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1079 "// <!--This is a test comment-->\n" 1080 "// <NewElement />\n" 1081 "@endtsexample\n\n" 1082 1083 "@see readComment()") 1084{ 1085 object->addComment( comment ); 1086} 1087 1088const char* SimXMLDocument::readComment( S32 index ) 1089{ 1090 // Clear the current attribute pointer 1091 m_CurrentAttribute = 0; 1092 1093 // Push the first element found under the current element of the given name 1094 if(!m_paNode.empty()) 1095 { 1096 const S32 iLastElement = m_paNode.size() - 1; 1097 TiXmlElement* pNode = m_paNode[iLastElement]; 1098 if(!pNode) 1099 { 1100 return ""; 1101 } 1102 TiXmlNode* node = pNode->FirstChild(); 1103 for( S32 i = 0; i < index; i++ ) 1104 { 1105 if( !node ) 1106 return ""; 1107 1108 node = node->NextSiblingElement(); 1109 } 1110 1111 if( node ) 1112 { 1113 TiXmlComment* comment = node->ToComment(); 1114 if( comment ) 1115 return comment->Value(); 1116 } 1117 } 1118 else 1119 { 1120 if(!m_qDocument) 1121 { 1122 return ""; 1123 } 1124 TiXmlNode* node = m_qDocument->FirstChild(); 1125 for( S32 i = 0; i < index; i++ ) 1126 { 1127 if( !node ) 1128 return ""; 1129 1130 node = node->NextSibling(); 1131 } 1132 1133 if( node ) 1134 { 1135 TiXmlComment* comment = node->ToComment(); 1136 if( comment ) 1137 return comment->Value(); 1138 } 1139 } 1140 return ""; 1141} 1142 1143DefineEngineMethod( SimXMLDocument, readComment, const char*, ( S32 index ),, 1144 "Gives the comment at the specified index, if any.\n\n" 1145 1146 "Unlike addComment() that only works at the document level, readComment() may read " 1147 "comments from the document or any child Element. The current Element (or document " 1148 "if no Elements have been pushed to the stack) is the parent for any comments, and the " 1149 "provided index is the number of comments in to read back." 1150 1151 "@param index Comment index number to query from the current Element stack\n\n" 1152 "@return String containing the comment, or an empty string if no comment is found.\n\n" 1153 1154 "@see addComment()") 1155{ 1156 return object->readComment( index ); 1157} 1158 1159void SimXMLDocument::addText(const char* text) 1160{ 1161 if(m_paNode.empty()) 1162 return; 1163 1164 const S32 iFinalElement = m_paNode.size() - 1; 1165 TiXmlElement* pNode = m_paNode[iFinalElement]; 1166 if(!pNode) 1167 return; 1168 1169 TiXmlText cText(text); 1170 pNode->InsertEndChild( cText ); 1171} 1172 1173DefineEngineMethod( SimXMLDocument, addText, void, ( const char* text ),, 1174 "@brief Add the given text as a child of current Element.\n\n" 1175 1176 "Use getText() to retrieve any text from the current Element and removeText() " 1177 "to clear any text.\n\n" 1178 1179 "addText() and addData() may be used interchangeably." 1180 1181 "@param text String containing the text.\n\n" 1182 1183 "@tsexample\n" 1184 "// Create a new XML document with a header and single element\n" 1185 "// with some added text.\n" 1186 "%x = new SimXMLDocument();\n" 1187 "%x.addHeader();\n" 1188 "%x.addNewElement(\"NewElement\");\n" 1189 "%x.addText(\"Some text\");\n" 1190 "%x.saveFile(\"test.xml\");\n\n" 1191 "// Produces the following file:\n" 1192 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1193 "// <NewElement>Some text</NewElement>\n" 1194 "@endtsexample\n\n" 1195 1196 "@see getText()\n" 1197 "@see removeText()\n" 1198 "@see addData()\n" 1199 "@see getData()") 1200{ 1201 object->addText( text ); 1202} 1203 1204const char* SimXMLDocument::getText() 1205{ 1206 if(m_paNode.empty()) 1207 return ""; 1208 1209 const S32 iFinalElement = m_paNode.size() - 1; 1210 TiXmlNode* pNode = m_paNode[iFinalElement]; 1211 if(!pNode) 1212 return ""; 1213 1214 if(!pNode->FirstChild()) 1215 return ""; 1216 1217 TiXmlText* text = pNode->FirstChild()->ToText(); 1218 if( !text ) 1219 return ""; 1220 1221 return text->Value(); 1222} 1223 1224DefineEngineMethod( SimXMLDocument, getText, const char*, (),, 1225 "@brief Gets the text from the current Element.\n\n" 1226 1227 "Use addText() to add text to the current Element and removeText() " 1228 "to clear any text.\n\n" 1229 1230 "getText() and getData() may be used interchangeably." 1231 1232 "@return String containing the text in the current Element." 1233 1234 "@tsexample\n" 1235 "// Using the following test.xml file as an example:\n" 1236 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1237 "// <NewElement>Some text</NewElement>\n\n" 1238 1239 "// Load in the file\n" 1240 "%x = new SimXMLDocument();\n" 1241 "%x.loadFile(\"test.xml\");\n\n" 1242 1243 "// Make the first Element the current one\n" 1244 "%x.pushFirstChildElement(\"NewElement\");\n\n" 1245 1246 "// Store the current Element's text ('Some text' in this example)\n" 1247 "// into 'result'\n" 1248 "%result = %x.getText();\n" 1249 "echo( %result );\n" 1250 "@endtsexample\n\n" 1251 1252 "@see addText()\n" 1253 "@see removeText()\n" 1254 "@see addData()\n" 1255 "@see getData()\n") 1256{ 1257 const char* text = object->getText(); 1258 if( !text ) 1259 return ""; 1260 1261 return text; 1262} 1263 1264void SimXMLDocument::removeText() 1265{ 1266 if(m_paNode.empty()) 1267 return; 1268 1269 const S32 iFinalElement = m_paNode.size() - 1; 1270 TiXmlElement* pNode = m_paNode[iFinalElement]; 1271 if(!pNode) 1272 return; 1273 1274 if( !pNode->FirstChild() ) 1275 return; 1276 1277 TiXmlText* text = pNode->FirstChild()->ToText(); 1278 if( !text ) 1279 return; 1280 1281 pNode->RemoveChild(text); 1282} 1283 1284DefineEngineMethod( SimXMLDocument, removeText, void, (),, 1285 "@brief Remove any text on the current Element.\n\n" 1286 1287 "Use getText() to retrieve any text from the current Element and addText() " 1288 "to add text to the current Element. As getData() and addData() are equivalent " 1289 "to getText() and addText(), removeText() will also remove any data from the " 1290 "current Element.\n\n" 1291 1292 "@see addText()\n" 1293 "@see getText()\n" 1294 "@see addData()\n" 1295 "@see getData()\n") 1296{ 1297 object->removeText(); 1298} 1299 1300void SimXMLDocument::addData(const char* text) 1301{ 1302 if(m_paNode.empty()) 1303 return; 1304 1305 const S32 iFinalElement = m_paNode.size() - 1; 1306 TiXmlElement* pNode = m_paNode[iFinalElement]; 1307 if(!pNode) 1308 return; 1309 1310 TiXmlText cText(text); 1311 pNode->InsertEndChild( cText ); 1312} 1313 1314DefineEngineMethod( SimXMLDocument, addData, void, ( const char* text ),, 1315 "@brief Add the given text as a child of current Element.\n\n" 1316 1317 "Use getData() to retrieve any text from the current Element.\n\n" 1318 1319 "addData() and addText() may be used interchangeably. As there is no " 1320 "difference between data and text, you may also use removeText() to clear " 1321 "any data from the current Element.\n\n" 1322 1323 "@param text String containing the text.\n\n" 1324 1325 "@tsexample\n" 1326 "// Create a new XML document with a header and single element\n" 1327 "// with some added data.\n" 1328 "%x = new SimXMLDocument();\n" 1329 "%x.addHeader();\n" 1330 "%x.addNewElement(\"NewElement\");\n" 1331 "%x.addData(\"Some text\");\n" 1332 "%x.saveFile(\"test.xml\");\n\n" 1333 "// Produces the following file:\n" 1334 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1335 "// <NewElement>Some text</NewElement>\n" 1336 "@endtsexample\n\n" 1337 1338 "@see getData()" 1339 "@see addText()\n" 1340 "@see getText()\n" 1341 "@see removeText()\n") 1342{ 1343 object->addData( text ); 1344} 1345 1346const char* SimXMLDocument::getData() 1347{ 1348 if(m_paNode.empty()) 1349 return ""; 1350 1351 const S32 iFinalElement = m_paNode.size() - 1; 1352 TiXmlNode* pNode = m_paNode[iFinalElement]; 1353 if(!pNode) 1354 return ""; 1355 1356 if( !pNode->FirstChild() ) 1357 return ""; 1358 1359 TiXmlText* text = pNode->FirstChild()->ToText(); 1360 if( !text ) 1361 return ""; 1362 1363 return text->Value(); 1364} 1365 1366DefineEngineMethod( SimXMLDocument, getData, const char*, (),, 1367 "@brief Gets the text from the current Element.\n\n" 1368 1369 "Use addData() to add text to the current Element.\n\n" 1370 1371 "getData() and getText() may be used interchangeably. As there is no " 1372 "difference between data and text, you may also use removeText() to clear " 1373 "any data from the current Element.\n\n" 1374 1375 "@return String containing the text in the current Element." 1376 1377 "@tsexample\n" 1378 "// Using the following test.xml file as an example:\n" 1379 "// <?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>\n" 1380 "// <NewElement>Some data</NewElement>\n\n" 1381 1382 "// Load in the file\n" 1383 "%x = new SimXMLDocument();\n" 1384 "%x.loadFile(\"test.xml\");\n\n" 1385 1386 "// Make the first Element the current one\n" 1387 "%x.pushFirstChildElement(\"NewElement\");\n\n" 1388 1389 "// Store the current Element's data ('Some data' in this example)\n" 1390 "// into 'result'\n" 1391 "%result = %x.getData();\n" 1392 "echo( %result );\n" 1393 "@endtsexample\n\n" 1394 1395 "@see addData()\n" 1396 "@see addText()\n" 1397 "@see getText()\n" 1398 "@see removeText()\n") 1399{ 1400 const char* text = object->getData(); 1401 if( !text ) 1402 return ""; 1403 1404 return text; 1405} 1406 1407////EOF///////////////////////////////////////////////////////////////////////// 1408