xxhrtypes.hpp
1 #ifndef XXHR_XXHR_TYPES_H
2 #define XXHR_XXHR_TYPES_H
3 
4 #include <algorithm>
5 #include <map>
6 #include <string>
7 #include <cctype>
8 
9 namespace xxhr {
10 
11  constexpr const auto CRLF = "\r\n";
12 
13 
14  struct CaseInsensitiveCompare {
15  bool operator()(const std::string& a, const std::string& b) const noexcept {
16  return std::lexicographical_compare(
17  a.begin(), a.end(), b.begin(), b.end(),
18  [](unsigned char ac, unsigned char bc) { return std::tolower(ac) < std::tolower(bc); });
19  }
20  };
21 
23  using Header = std::map<std::string, std::string, CaseInsensitiveCompare>;
24  using Url = std::string;
25 
26  // We import ""s to be able to create Url without typing the cumbersome Url{"www.site.com"} but "www.site.com"s instead.
27  using namespace std::string_literals; // Sadly `using std::string_literals::operator""s;` throws an erroneous warning IMHO.
28 
29 } // namespace xxhr
30 
31 #endif
main library namespace
Definition: api.hpp:19
std::map< std::string, std::string, CaseInsensitiveCompare > Header
HTTP Headers to add to the request or received in xxhr::Response.
Definition: xxhrtypes.hpp:23