MCPcopy Create free account
hub / github.com/MultiMC/Launcher / read_string

Function read_string

launcher/minecraft/World.cpp:353–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351namespace {
352
353optional<QString> read_string (nbt::value& parent, const char * name)
354{
355 try
356 {
357 auto &namedValue = parent.at(name);
358 if(namedValue.get_type() != nbt::tag_type::String)
359 {
360 return nullopt;
361 }
362 auto & tag_str = namedValue.as<nbt::tag_string>();
363 return QString::fromStdString(tag_str.get());
364 }
365 catch (const std::out_of_range &e)
366 {
367 // fallback for old world formats
368 qWarning() << "String NBT tag" << name << "could not be found.";
369 return nullopt;
370 }
371 catch (const std::bad_cast &e)
372 {
373 // type mismatch
374 qWarning() << "NBT tag" << name << "could not be converted to string.";
375 return nullopt;
376 }
377}
378
379optional<int64_t> read_long (nbt::value& parent, const char * name)
380{

Callers 1

loadFromLevelDatMethod · 0.85

Calls 2

atMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected