MCPcopy Create free account
hub / github.com/ThePhD/sol2 / custom_reader_function

Function custom_reader_function

examples/source/custom_reader.cpp:39–51  ·  view source on GitHub ↗

function must match signature found in type lua_Reader: const char* ( lua_State*, void*, size_t* )

Source from the content-addressed store, hash-verified

37// function must match signature found in type lua_Reader:
38// const char* ( lua_State*, void*, size_t* )
39const char* custom_reader_function(
40 lua_State*, void* pointer_to_my_object, size_t* data_size) {
41 custom_reader& cr
42 = *(static_cast<custom_reader*>(pointer_to_my_object));
43 if (cr.read()) {
44 *data_size = cr.current_size;
45 return cr.buffer;
46 }
47 else {
48 *data_size = 0;
49 return nullptr;
50 }
51}
52
53int main() {
54 std::cout << "=== custom reader ===" << std::endl;

Callers

nothing calls this directly

Calls 1

readMethod · 0.80

Tested by

no test coverage detected