MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / GetDataString

Function GetDataString

src/vm/luavm/lmylib.cpp:219–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219static bool GetDataString(lua_State *L, vector<std::shared_ptr<std::vector<uint8_t>>> &ret) {
220 //从栈里取一串字符串
221 if (!lua_isstring(L, -1 - 0)) {
222 LogPrint(BCLog::LUAVM, "%s\n", "data is not string");
223 return false;
224 }
225 vector<uint8_t> vBuf;
226 vBuf.clear();
227 const char *pStr = nullptr;
228 pStr = lua_tostring(L, -1 - 0);
229 if (pStr && (strlen(pStr) <= LUA_C_BUFFER_SIZE)) {
230 for (size_t i = 0; i < strlen(pStr); i++) {
231 vBuf.insert(vBuf.end(), pStr[i]);
232 }
233 ret.insert(ret.end(), std::make_shared<vector<uint8_t>>(vBuf.begin(), vBuf.end()));
234 // LogPrint(BCLog::LUAVM, "GetDataString:%s\n", pStr);
235 return true;
236 } else {
237 LogPrint(BCLog::LUAVM, "%s\n", "lua_tostring get fail");
238 return false;
239 }
240}
241
242// get bool field value of table
243static bool GetBoolInTable(lua_State *L, const char *pKey, bool &value) {

Callers 4

ExSha256FuncFunction · 0.85
ExSha256OnceFuncFunction · 0.85
ExDeleteDataDBFuncFunction · 0.85
ExReadDataDBFuncFunction · 0.85

Calls 5

lua_isstringFunction · 0.85
clearMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected