pornsieve  0.0.0
Search porn sites and filter the results using regular expressions
helpers.hpp
Go to the documentation of this file.
1 /* This file is part of pornsieve.
2  * Copyright © 2021 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
23 #ifndef PORNSIEVE_HELPERS_HPP
24 #define PORNSIEVE_HELPERS_HPP
25 
26 #include <chrono>
27 #include <string>
28 #include <string_view>
29 #include <vector>
30 
31 namespace pornsieve
32 {
33 
34 using std::string;
35 using std::string_view;
36 using std::vector;
37 using std::chrono::system_clock;
39 
51 vector<string> json_to_vector(string_view json, string_view key);
52 
62 std::chrono::seconds string_to_duration(string_view duration_string);
63 
71 time_point string_to_timepoint(string_view time_string);
72 
84 string timepoint_to_string(const system_clock::time_point &timepoint,
85  string_view format = "%FT%T");
86 
87 } // namespace pornsieve
88 
89 #endif // PORNSIEVE_HELPERS_HPP
pornsieve
The namespace containing the pornsieve library.
Definition: config.hpp:30
pornsieve::timepoint_to_string
string timepoint_to_string(const system_clock::time_point &timepoint, string_view format="%FT%T")
Return date and time as string in UTC.
Definition: helpers.cpp:83
pornsieve::string_to_duration
std::chrono::seconds string_to_duration(string_view duration_string)
Converts a duration from string to chrono seconds.
Definition: helpers.cpp:47
pornsieve::json_to_vector
vector< string > json_to_vector(string_view json, string_view key)
Converts a JSON array into a vector.
Definition: helpers.cpp:37
pornsieve::string_to_timepoint
time_point string_to_timepoint(string_view time_string)
Converts a time from string to time_point.
Definition: helpers.cpp:72
pornsieve::time_point
std::chrono::system_clock::time_point time_point
In this lib we use the system clock for our time points.
Definition: helpers.hpp:38