naev 0.10.4
Functions
nxml_lua.c File Reference

Handles the saving and writing of a nlua state to XML. More...

#include "nxml_lua.h"
#include "base64.h"
#include "log.h"
#include "nlua.h"
#include "nlua_commodity.h"
#include "nlua_faction.h"
#include "nlua_jump.h"
#include "nlua_outfit.h"
#include "nlua_spob.h"
#include "nlua_ship.h"
#include "nlua_system.h"
#include "nlua_time.h"
#include "nlua_vec2.h"
#include "nluadef.h"
#include "nstring.h"
#include "mission.h"
#include "utf8.h"

Go to the source code of this file.

Functions

static int nxml_persistDataNode (lua_State *L, xmlTextWriterPtr writer)
 Persists the node on the top of the stack and pops it. More...
 
static int nxml_unpersistDataNode (lua_State *L, xmlNodePtr parent)
 Unpersists Lua data. More...
 
static int nxml_canWriteString (const char *buf, size_t len)
 Checks whether saving the given string (from lua_tolstring) can be saved into an XML document without blowing up. More...
 
static int nxml_saveNameAttribute (xmlTextWriterPtr writer, const char *name, size_t name_len, int keynum)
 Persists the key of a key/value pair. More...
 
static int nxml_saveData (xmlTextWriterPtr writer, const char *type, const char *name, size_t name_len, const char *value, int keynum)
 Persists Lua data. More...
 
static int nxml_saveCommodity (xmlTextWriterPtr writer, const char *name, size_t name_len, const Commodity *c, int keynum)
 Commodity-specific nxml_saveData derivative. More...
 
static Commoditynxml_loadCommodity (xmlNodePtr node)
 Reverse of nxml_saveCommodity. More...
 
static int nxml_saveJump (xmlTextWriterPtr writer, const char *name, size_t name_len, const char *start, const char *dest, int keynum)
 Jump-specific nxml_saveData derivative. More...
 
int nxml_persistLua (nlua_env env, xmlTextWriterPtr writer)
 Persists all the nxml Lua data. More...
 
int nxml_unpersistLua (nlua_env env, xmlNodePtr parent)
 Unpersists Lua data into a table named "mem". More...
 

Detailed Description

Handles the saving and writing of a nlua state to XML.

Definition in file nxml_lua.c.

Function Documentation

◆ nxml_canWriteString()

static int nxml_canWriteString ( const char *  buf,
size_t  len 
)
static

Checks whether saving the given string (from lua_tolstring) can be saved into an XML document without blowing up.

Parameters
bufContents of a valid Lua string.
lenCorresponding length.
Returns
1 if OK, 0 if it won't work.

Definition at line 540 of file nxml_lua.c.

◆ nxml_loadCommodity()

static Commodity * nxml_loadCommodity ( xmlNodePtr  node)
static

Reverse of nxml_saveCommodity.

Definition at line 122 of file nxml_lua.c.

◆ nxml_persistDataNode()

static int nxml_persistDataNode ( lua_State *  L,
xmlTextWriterPtr  writer 
)
static

Persists the node on the top of the stack and pops it.

Parameters
LLua state with node to persist on top of the stack.
writerXML Writer to use.
Returns
0 on success.

Definition at line 175 of file nxml_lua.c.

◆ nxml_persistLua()

int nxml_persistLua ( nlua_env  env,
xmlTextWriterPtr  writer 
)

Persists all the nxml Lua data.

All supported contents of the table named "mem" are saved. Functions aren't supported.

Parameters
envLua environment to save.
writerXML Writer to use.
Returns
0 on success.

Definition at line 368 of file nxml_lua.c.

◆ nxml_saveCommodity()

static int nxml_saveCommodity ( xmlTextWriterPtr  writer,
const char *  name,
size_t  name_len,
const Commodity c,
int  keynum 
)
static

Commodity-specific nxml_saveData derivative.

Parameters
writerXML Writer to use to persist stuff.
nameName of the data to save.
name_lenData size of name (which is an arbitrary Lua string).
cCommodity to save.
keynumWhether the "name" is a numeric key, to be marked with keynum="1" in the XML.
Returns
0 on success.

Definition at line 97 of file nxml_lua.c.

◆ nxml_saveData()

static int nxml_saveData ( xmlTextWriterPtr  writer,
const char *  type,
const char *  name,
size_t  name_len,
const char *  value,
int  keynum 
)
static

Persists Lua data.

Parameters
writerXML Writer to use to persist stuff.
typeType of the data to save.
nameName of the data to save.
name_lenData size of name (which is an arbitrary Lua string).
valueValue of the data to save.
keynumWhether the key is a number (not a string) and should be read back as such.
Returns
0 on success.

Definition at line 73 of file nxml_lua.c.

◆ nxml_saveJump()

static int nxml_saveJump ( xmlTextWriterPtr  writer,
const char *  name,
size_t  name_len,
const char *  start,
const char *  dest,
int  keynum 
)
static

Jump-specific nxml_saveData derivative.

Parameters
writerXML Writer to use to persist stuff.
nameName of the data to save.
name_lenData size of name (which is an arbitrary Lua string).
startSystem in which the jump is.
destJump's destination system.
keynumWhether the "name" is a numeric key, to be marked with keynum="1" in the XML.
Returns
0 on success.

Definition at line 153 of file nxml_lua.c.

◆ nxml_saveNameAttribute()

static int nxml_saveNameAttribute ( xmlTextWriterPtr  writer,
const char *  name,
size_t  name_len,
int  keynum 
)
static

Persists the key of a key/value pair.

Parameters
writerXML Writer to use to persist stuff.
nameName of the data to save.
name_lenData size of name (which is an arbitrary Lua string).
keynumWhether the "name" is a numeric key, to be marked with keynum="1" in the XML.
Returns
0 on success.

Definition at line 48 of file nxml_lua.c.

◆ nxml_unpersistDataNode()

static int nxml_unpersistDataNode ( lua_State *  L,
xmlNodePtr  parent 
)
static

Unpersists Lua data.

Parameters
LState to unpersist data into.
parentNode containing all the Lua persisted data.
Returns
0 on success.

Definition at line 394 of file nxml_lua.c.

◆ nxml_unpersistLua()

int nxml_unpersistLua ( nlua_env  env,
xmlNodePtr  parent 
)

Unpersists Lua data into a table named "mem".

Parameters
envEnvironment to unpersist data into.
parentNode containing all the Lua persisted data.
Returns
0 on success.

Definition at line 521 of file nxml_lua.c.