Exemplo n.º 1
0
boost::optional<int> asInt(const JsonObject &json, const std::string &errorBad, Severity severity)
{
    if(json.isInt()) {
        return boost::optional<int>(json.asInt());
    }
    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<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;
}