Exemplo n.º 1
0
boost::optional<JsonObject> getObject(const JsonObject &json, const std::string &key)
{
    JsonObject value = json[key];
    if(!value.isNull()) {
        return boost::optional<JsonObject>(value);
    }
    return boost::none;
}
Exemplo n.º 2
0
boost::optional<int> STADIC_API getInt(const JsonObject &json, const std::string &key) {
    JsonObject value = json[key];
    if(value.isNull()) {
        return boost::none;
    } else if(value.isInt()) {
        return boost::optional<int>(value.asInt());
    }
    return boost::none;
}
Exemplo n.º 3
0
boost::optional<double> STADIC_API getDouble(const JsonObject &json, const std::string &key) {
    JsonObject value = json[key];
    if(value.isNull()) {
        return boost::none;
    } else if(value.isDouble()) {
        return boost::optional<double>(value.asDouble());
    }
    return boost::none;
}
Exemplo n.º 4
0
boost::optional<JsonObject> getObject(const JsonObject &json, const std::string &key,
                                      const std::string &errorMissing, Severity severity)
{
    JsonObject value = json[key];
    if(!value.isNull()) {
        return boost::optional<JsonObject>(value);
    }
    STADIC_LOG(severity, errorMissing);
    return boost::none;
}
Exemplo n.º 5
0
boost::optional<std::string> getString(const JsonObject &json, const std::string &key)
{
    JsonObject value = json[key];
    if(value.isNull()) {
        return boost::none;
    } else if(value.isString()) {
        return boost::optional<std::string>(value.asString());
    }
    return boost::none;
}
Exemplo n.º 6
0
boost::optional<int> getInt(const JsonObject &json, const std::string &key, const std::string &errorMissing,
                            const std::string &errorBad, Severity severity)
{
    JsonObject value = json[key];
    if(value.isNull()) {
        STADIC_LOG(severity, errorMissing);
    } else {
        if(value.isInt()) {
            return boost::optional<int>(value.asInt());
        } else {
            STADIC_LOG(severity, errorBad);
        }
    }
    return boost::none;
}
Exemplo n.º 7
0
boost::optional<bool> getBool(const JsonObject &json, const std::string &key, bool defaultValue,
                              const std::string &errorBad, Severity severity)
{
    JsonObject value = json[key];
    if(value.isNull()) {
        return boost::optional<bool>(defaultValue);
    } else {
        if(value.isBool()) {
            return boost::optional<bool>(value.asBool());
        } else {
            STADIC_LOG(severity, errorBad);
        }
    }
    return boost::none;
}