summaryrefslogtreecommitdiff
path: root/src/mbgl/storage/resource_options.cpp
blob: c56a22540b086c50ab592f27c2d799506ccce459 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <mbgl/storage/resource_options.hpp>
#include <mbgl/util/constants.hpp>

namespace mbgl {

class ResourceOptions::Impl {
public:
    std::string accessToken;
    std::string baseURL = mbgl::util::API_BASE_URL;
    std::string cachePath = ":memory:";
    std::string assetPath = ".";
    uint64_t maximumSize = mbgl::util::DEFAULT_MAX_CACHE_SIZE;
    void* platformContext = nullptr;
};

// These requires the complete type of Impl.
ResourceOptions::ResourceOptions() : impl_(std::make_unique<Impl>()) {}
ResourceOptions::~ResourceOptions() = default;
ResourceOptions::ResourceOptions(ResourceOptions&&) noexcept = default;
ResourceOptions::ResourceOptions(const ResourceOptions& other) : impl_(std::make_unique<Impl>(*other.impl_)) {}

ResourceOptions ResourceOptions::clone() const {
    return ResourceOptions(*this);
}

ResourceOptions& ResourceOptions::withAccessToken(std::string token) {
    impl_->accessToken = std::move(token);
    return *this;
}

const std::string& ResourceOptions::accessToken() const {
    return impl_->accessToken;
}

ResourceOptions& ResourceOptions::withBaseURL(std::string url) {
    impl_->baseURL = std::move(url);
    return *this;
}

const std::string& ResourceOptions::baseURL() const {
    return impl_->baseURL;
}

ResourceOptions& ResourceOptions::withCachePath(std::string path) {
    impl_->cachePath = std::move(path);
    return *this;
}

const std::string& ResourceOptions::cachePath() const {
    return impl_->cachePath;
}

ResourceOptions& ResourceOptions::withAssetPath(std::string path) {
    impl_->assetPath = std::move(path);
    return *this;
}

const std::string& ResourceOptions::assetPath() const {
    return impl_->assetPath;
}

ResourceOptions& ResourceOptions::withMaximumCacheSize(uint64_t size) {
    impl_->maximumSize = size;
    return *this;
}

uint64_t ResourceOptions::maximumCacheSize() const {
    return impl_->maximumSize;
}

ResourceOptions& ResourceOptions::withPlatformContext(void* context) {
    impl_->platformContext = context;
    return *this;
}

void* ResourceOptions::platformContext() const {
    return impl_->platformContext;
}

}  // namespace mbgl