Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
XMBStorage Class Reference

Storage for XMBData. More...

#include <XMBStorage.h>

Public Member Functions

 XMBStorage ()=default
 
bool ReadFromFile (const PIVFS &vfs, const VfsPath &filename)
 Read an XMB file on disk. More...
 
bool LoadXMLDoc (const xmlDocPtr doc)
 Parse an XML document into XMB. More...
 
bool LoadJSValue (const ScriptInterface &scriptInterface, JS::HandleValue value, const std::string &rootName)
 Parse a Javascript value into XMB. More...
 

Public Attributes

std::shared_ptr< u8m_Buffer
 
size_t m_Size = 0
 

Static Public Attributes

static const char * HeaderMagicStr = "XMB0"
 
static const char * UnfinishedHeaderMagicStr = "XMBu"
 
static const u32 XMBVersion = 4
 

Detailed Description

Storage for XMBData.

Constructor & Destructor Documentation

◆ XMBStorage()

XMBStorage::XMBStorage ( )
default

Member Function Documentation

◆ LoadJSValue()

bool XMBStorage::LoadJSValue ( const ScriptInterface scriptInterface,
JS::HandleValue  value,
const std::string &  rootName 
)

Parse a Javascript value into XMB.

The syntax is similar to ParamNode, but supports multiple children with the same name, to match XML. You need to pass the name of the root object, as unlike XML this cannot be recovered from the value. The following JS object: { "a": 5, "b": "test", "x": { // Like ParamNode, _string is used for the value. "_string": "value", // Like ParamNode, attributes are prefixed with . "@param": "something", "y": 3 }, // Every array item is parsed as a child. "object": [ "a", "b", { "_string": "c" }, { "child": "value" }, ], // Same but without the array. "child@0@": 1, "child@1@": 2 } will parse like the following XML: 5 test <x param="something">value <y>3</y> </x> <object>a</object> <object>b</object> <object>c</object> <object><child>value</child></object> <child>1</child> <child>2</child> See also tests for some other examples.

◆ LoadXMLDoc()

bool XMBStorage::LoadXMLDoc ( const xmlDocPtr  doc)

Parse an XML document into XMB.

Main limitations:

  • Can't correctly handle mixed text/elements inside elements - "<div> <b> Text </b> </div>" and "<div> Te<b/>xt </div>" are considered identical.

◆ ReadFromFile()

bool XMBStorage::ReadFromFile ( const PIVFS vfs,
const VfsPath filename 
)

Read an XMB file on disk.

Member Data Documentation

◆ HeaderMagicStr

const char * XMBStorage::HeaderMagicStr = "XMB0"
static

◆ m_Buffer

std::shared_ptr<u8> XMBStorage::m_Buffer

◆ m_Size

size_t XMBStorage::m_Size = 0

◆ UnfinishedHeaderMagicStr

const char * XMBStorage::UnfinishedHeaderMagicStr = "XMBu"
static

◆ XMBVersion

const u32 XMBStorage::XMBVersion = 4
static

The documentation for this class was generated from the following files: