Handles the saving and writing of a nlua state to XML.
More...
#include "nxml_lua.h"
#include "base64.h"
#include "log.h"
#include "mission.h"
#include "nlua.h"
#include "nlua_commodity.h"
#include "nlua_faction.h"
#include "nlua_jump.h"
#include "nlua_outfit.h"
#include "nlua_ship.h"
#include "nlua_spob.h"
#include "nlua_system.h"
#include "nlua_time.h"
#include "nlua_vec2.h"
#include "utf8.h"
Go to the source code of this file.
|
| static int | nxml_persistDataNode (lua_State *L, xmlTextWriterPtr writer) |
| | Persists the node on the top of the stack and pops it.
|
| static int | nxml_unpersistDataNode (lua_State *L, xmlNodePtr parent) |
| | Unpersists Lua data.
|
| 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.
|
| static int | nxml_saveNameAttribute (xmlTextWriterPtr writer, const char *name, size_t name_len, int keynum) |
| | Persists the key of a key/value pair.
|
| static int | nxml_saveData (xmlTextWriterPtr writer, const char *type, const char *name, size_t name_len, const char *value, int keynum) |
| | Persists Lua data.
|
| static int | nxml_saveCommodity (xmlTextWriterPtr writer, const char *name, size_t name_len, const Commodity *c, int keynum) |
| | Commodity-specific nxml_saveData derivative.
|
| static Commodity * | nxml_loadCommodity (xmlNodePtr node) |
| | Reverse of nxml_saveCommodity.
|
| 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.
|
| int | nxml_persistLua (nlua_env env, xmlTextWriterPtr writer) |
| | Persists all the nxml Lua data.
|
| int | nxml_unpersistLua (nlua_env env, xmlNodePtr parent) |
| | Unpersists Lua data into a table named "mem".
|
Handles the saving and writing of a nlua state to XML.
Definition in file nxml_lua.c.
◆ nxml_canWriteString()
| 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
-
| buf | Contents of a valid Lua string. |
| len | Corresponding length. |
- Returns
- 1 if OK, 0 if it won't work.
Definition at line 549 of file nxml_lua.c.
◆ nxml_loadCommodity()
| Commodity * nxml_loadCommodity |
( |
xmlNodePtr | node | ) |
|
|
static |
Reverse of nxml_saveCommodity.
Definition at line 121 of file nxml_lua.c.
◆ nxml_persistDataNode()
| int nxml_persistDataNode |
( |
lua_State * | L, |
|
|
xmlTextWriterPtr | writer ) |
|
static |
Persists the node on the top of the stack and pops it.
- Parameters
-
| L | Lua state with node to persist on top of the stack. |
| writer | XML Writer to use. |
- Returns
- 0 on success.
Definition at line 176 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
-
| env | Lua environment to save. |
| writer | XML Writer to use. |
- Returns
- 0 on success.
Definition at line 374 of file nxml_lua.c.
◆ nxml_saveCommodity()
| int nxml_saveCommodity |
( |
xmlTextWriterPtr | writer, |
|
|
const char * | name, |
|
|
size_t | name_len, |
|
|
const Commodity * | c, |
|
|
int | keynum ) |
|
static |
Commodity-specific nxml_saveData derivative.
- Parameters
-
| writer | XML Writer to use to persist stuff. |
| name | Name of the data to save. |
| name_len | Data size of name (which is an arbitrary Lua string). |
| c | Commodity to save. |
| keynum | Whether the "name" is a numeric key, to be marked with keynum="1" in the XML. |
- Returns
- 0 on success.
Definition at line 96 of file nxml_lua.c.
◆ nxml_saveData()
| 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
-
| writer | XML Writer to use to persist stuff. |
| type | Type of the data to save. |
| name | Name of the data to save. |
| name_len | Data size of name (which is an arbitrary Lua string). |
| value | Value of the data to save. |
| keynum | Whether the key is a number (not a string) and should be read back as such. |
- Returns
- 0 on success.
Definition at line 70 of file nxml_lua.c.
◆ nxml_saveJump()
| 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
-
| writer | XML Writer to use to persist stuff. |
| name | Name of the data to save. |
| name_len | Data size of name (which is an arbitrary Lua string). |
| start | System in which the jump is. |
| dest | Jump's destination system. |
| keynum | Whether 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()
| int nxml_saveNameAttribute |
( |
xmlTextWriterPtr | writer, |
|
|
const char * | name, |
|
|
size_t | name_len, |
|
|
int | keynum ) |
|
static |
Persists the key of a key/value pair.
- Parameters
-
| writer | XML Writer to use to persist stuff. |
| name | Name of the data to save. |
| name_len | Data size of name (which is an arbitrary Lua string). |
| keynum | Whether the "name" is a numeric key, to be marked with keynum="1" in the XML. |
- Returns
- 0 on success.
Definition at line 43 of file nxml_lua.c.
◆ nxml_unpersistDataNode()
| int nxml_unpersistDataNode |
( |
lua_State * | L, |
|
|
xmlNodePtr | parent ) |
|
static |
Unpersists Lua data.
- Parameters
-
| L | State to unpersist data into. |
| parent | Node containing all the Lua persisted data. |
- Returns
- 0 on success.
Definition at line 400 of file nxml_lua.c.
◆ nxml_unpersistLua()
| int nxml_unpersistLua |
( |
nlua_env | env, |
|
|
xmlNodePtr | parent ) |
Unpersists Lua data into a table named "mem".
- Parameters
-
| env | Environment to unpersist data into. |
| parent | Node containing all the Lua persisted data. |
- Returns
- 0 on success.
Definition at line 530 of file nxml_lua.c.