MCPcopy Create free account
hub / github.com/anjo76/angelscript / DictionaryToString

Function DictionaryToString

sdk/samples/asrun/source/main.cpp:278–311  ·  view source on GitHub ↗

This is the to-string callback for the dictionary type

Source from the content-addressed store, hash-verified

276
277// This is the to-string callback for the dictionary type
278std::string DictionaryToString(void *obj, int expandMembers, CDebugger *dbg)
279{
280 CScriptDictionary *dic = reinterpret_cast<CScriptDictionary*>(obj);
281
282 std::stringstream s;
283 s << "(len=" << dic->GetSize() << ")";
284
285 if( expandMembers > 0 )
286 {
287 s << " [";
288 asUINT n = 0;
289 for( CScriptDictionary::CIterator it = dic->begin(); it != dic->end(); it++, n++ )
290 {
291 s << "[" << it.GetKey() << "] = ";
292
293 // Get the type and address of the value
294 const void *val = it.GetAddressOfValue();
295 int typeId = it.GetTypeId();
296
297 // Use the engine from the currently active context (if none is active, the debugger
298 // will use the engine held inside it by default, but in an environment where there
299 // multiple engines this might not be the correct instance).
300 asIScriptContext *ctx = asGetActiveContext();
301
302 s << dbg->ToString(const_cast<void*>(val), typeId, expandMembers - 1, ctx ? ctx->GetEngine() : 0);
303
304 if( n < dic->GetSize() - 1 )
305 s << ", ";
306 }
307 s << "]";
308 }
309
310 return s.str();
311}
312
313// This is the to-string callback for the dictionary type
314std::string DateTimeToString(void *obj, int expandMembers, CDebugger *dbg)

Callers

nothing calls this directly

Calls 9

beginMethod · 0.80
endMethod · 0.80
strMethod · 0.80
GetSizeMethod · 0.45
GetKeyMethod · 0.45
GetAddressOfValueMethod · 0.45
GetTypeIdMethod · 0.45
ToStringMethod · 0.45
GetEngineMethod · 0.45

Tested by

no test coverage detected