Files
MapLibreParticleLab/include/mbgl/storage/response.hpp
John Firebaugh 4d29c7d5ce [core] Remove Response::Error::Reason::Canceled
There is no such thing as a cancelled response, only cancelled requests. A request that is cancelled does not have its callback called with a Response.
2016-02-04 13:18:14 -08:00

55 lines
1.2 KiB
C++

#ifndef MBGL_STORAGE_RESPONSE
#define MBGL_STORAGE_RESPONSE
#include <mbgl/util/chrono.hpp>
#include <mbgl/util/optional.hpp>
#include <string>
#include <memory>
namespace mbgl {
class Response {
public:
Response() = default;
Response(const Response&);
Response& operator=(const Response&);
public:
class Error;
// When this object is empty, the response was successful.
std::unique_ptr<const Error> error;
// This is set to true for 304 Not Modified responses.
bool notModified = false;
// The actual data of the response. This is null if notModified is true.
std::shared_ptr<const std::string> data;
optional<SystemTimePoint> modified;
optional<SystemTimePoint> expires;
optional<std::string> etag;
};
class Response::Error {
public:
enum class Reason : uint8_t {
Success = 1,
NotFound = 2,
Server = 3,
Connection = 4,
Other = 6,
} reason = Reason::Other;
// An error message from the request handler, e.g. a server message or a system message
// informing the user about the reason for the failure.
std::string message;
public:
Error(Reason, const std::string& = "");
};
} // namespace mbgl
#endif