MCPcopy Create free account
hub / github.com/bab2min/tomotopy / getValueFromMisc

Function getValueFromMisc

src/python/handler/module.h:410–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408
409template<typename _Ty>
410_Ty getValueFromMisc(const char* key, const tomoto::RawDoc::MiscType& misc, const char* failMsg)
411{
412 auto it = misc.find(key);
413 if (it == misc.end()) throw std::runtime_error{ failMsg + std::string{ " (the required value was not given)" } };
414 auto obj = (PyObject*)std::get<std::shared_ptr<void>>(it->second).get();
415 _Ty ret;
416 if (!py::toCpp(obj, ret))
417 {
418 throw std::runtime_error{ failMsg + (" (given " + py::repr(obj) + ")") };
419 }
420 return ret;
421}
422
423template<typename _Ty>
424_Ty getValueFromMiscDefault(const char* key, const tomoto::RawDoc::MiscType& misc, const char* failMsg, const _Ty& def = {})

Callers

nothing calls this directly

Calls 4

toCppFunction · 0.85
reprFunction · 0.85
endMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected