Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
CookieMap.h
Go to the documentation of this file.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
23#pragma once
24
26#include <map>
27
28#ifdef SESE_PLATFORM_WINDOWS
29#pragma warning(disable : 4251)
30#endif
31
32namespace sese::net::http {
33
35class CookieMap {
36public:
37 using Ptr = std::shared_ptr<CookieMap>;
38 using Map = std::map<std::string, Cookie::Ptr>;
39
42 void add(const Cookie::Ptr &cookie) noexcept;
46 Cookie::Ptr find(const std::string &name) noexcept;
47
50 void expired(uint64_t now);
51
54 void updateExpiresFrom(uint64_t offset);
55
56 [[nodiscard]] size_t size() const { return map.size(); }
57 [[nodiscard]] bool empty() const { return map.empty(); }
58 void clear() { map.clear(); }
59
60 inline Map::iterator begin() noexcept { return map.begin(); }
61 inline Map::iterator end() noexcept { return map.end(); }
62
63private:
65};
66} // namespace sese::net::http