|
CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
|
Public Member Functions | |
| void | insert (std::string_view piece, size_t index) |
| Insert the given chunk at the given index in the buffer. | |
Static Public Member Functions | |
| static const char * | load_fn (lua_State *L, void *ud, size_t *size) |
| lua_Reader callback function for lua_load or luaT_load | |
Public Attributes | |
| const char * | piece [load_multi_buffer_capacity] {nullptr} |
| Pieces of the lua code chunk to be loaded. | |
| size_t | piece_size [load_multi_buffer_capacity] {} |
| Lengths of the pieces. | |
Structure for loading multiple strings as a Lua chunk, avoiding concatenation
luaL_loadbuffer() is a good way to load a string as a Lua chunk. If there are several strings which need to be concatenated before being loaded, then it can be more efficient to call lua_load with a callback function for loading the strings one at a time than to concatenate the strings into a single buffer.
This class provides the data structure and callback function to do this.
Because of the api of lua_tolstring the API of this class allows direct and independent assignment of the chunk pieces and their sizes.
It is up to the caller to keep track of how many pieces are used and to ensure that no more than load_multi_buffer_capacity pieces are used.
|
inline |
Insert the given chunk at the given index in the buffer.
|
inlinestatic |
lua_Reader callback function for lua_load or luaT_load
Called repeatedly by lua to get the next piece of data to load until a null pointer is returned.
| L | The Lua state |
| ud | Pointer to the load_multi_buffer instance |
| size | Pointer to size_t to receive the size of the returned string |
| const char* load_multi_buffer::piece[load_multi_buffer_capacity] {nullptr} |
Pieces of the lua code chunk to be loaded.
| size_t load_multi_buffer::piece_size[load_multi_buffer_capacity] {} |
Lengths of the pieces.