| 1 | #ifndef CPR_TIMEOUT_H |
| 2 | #define CPR_TIMEOUT_H |
| 3 | |
| 4 | #include <chrono> |
| 5 | #include <cstdint> |
| 6 | |
| 7 | namespace cpr { |
| 8 | |
| 9 | class Timeout { |
| 10 | public: |
| 11 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) |
| 12 | Timeout(const std::chrono::milliseconds& duration) : ms{duration} {} |
| 13 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) |
| 14 | Timeout(const std::int32_t& milliseconds) : Timeout{std::chrono::milliseconds(milliseconds)} {} |
| 15 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) |
| 16 | Timeout(const std::chrono::seconds& duration) : ms{std::chrono::milliseconds(duration).count()} {} |
| 17 | |
| 18 | // No way around since curl uses a long here. |
| 19 | // NOLINTNEXTLINE(google-runtime-int) |
| 20 | long Milliseconds() const; |
| 21 | |
| 22 | std::chrono::milliseconds ms; |
| 23 | }; |
| 24 | |
| 25 | } // namespace cpr |
| 26 | |
| 27 | #endif |
| 28 | |