5 #include <SimoxUtility/algorithm/string.h>
15 const std::string& missingKey,
const nlohmann::json& j) :
20 static std::string getAvailableKeys(
const nlohmann::json& j)
23 for (
const auto& item : j.items())
25 ss <<
"\n- " << item.key();
30 std::string NoTypeNameEntryInJsonObject::makeMsg(
const std::string& missingKey,
const nlohmann::json& j)
33 ss <<
"No type name entry with key '" << missingKey <<
"' in JSON object.\n";
36 ss <<
"Available keys: " << getAvailableKeys(j);
40 ss <<
"JSON document is not an object, but a " << j.type_name() <<
".";
47 const std::string& key,
const std::string& typeName,
const nlohmann::json& j) :
52 std::string TypeNameEntryAlreadyInJsonObject::makeMsg(
53 const std::string& key,
const std::string& typeName,
const nlohmann::json& j)
56 ss <<
"Key '" << key <<
"' already used in JSON object "
57 <<
"when trying to store the type name '" << typeName <<
"'.\n";
58 ss <<
"Used keys:" << getAvailableKeys(j);
68 std::string TypeNameMismatch::makeMsg(
const std::string& typeInJson,
const std::string& typeOfObject)
71 ss <<
"Type stored JSON (" << typeInJson <<
") does not match the type of passed object ("
72 << typeOfObject <<
").";
82 const std::string& typeName,
const std::vector<std::string>& acceptedTypes) :
86 std::string SerializerAlreadyRegisteredForType::makeMsg(
87 const std::string& typeName,
const std::vector<std::string>& acceptedTypes)
90 ss <<
"There is already a registered serializer for type '" + typeName +
"'.";
91 if (!acceptedTypes.empty())
93 ss <<
"\nAccepted types:\n" + simox::alg::join(acceptedTypes,
"\n- ");