Line data Source code
1 : // Copyright (c) 2011-2022 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // https://snapwebsites.org/project/edhttp
4 : // contact@m2osw.com
5 : //
6 : // This program is free software: you can redistribute it and/or modify
7 : // it under the terms of the GNU General Public License as published by
8 : // the Free Software Foundation, either version 3 of the License, or
9 : // (at your option) any later version.
10 : //
11 : // This program is distributed in the hope that it will be useful,
12 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : // GNU General Public License for more details.
15 : //
16 : // You should have received a copy of the GNU General Public License
17 : // along with this program. If not, see <https://www.gnu.org/licenses/>.
18 : #pragma once
19 :
20 : // self
21 : //
22 : #include <edhttp/string_part.h>
23 :
24 :
25 :
26 : namespace edhttp
27 : {
28 :
29 :
30 :
31 : // for HTTP_ACCEPT_ENCODING, HTTP_ACCEPT_LANGUAGE, HTTP_ACCEPT
32 34 : class weighted_http_string
33 : {
34 : public:
35 : weighted_http_string(std::string const & str = std::string());
36 :
37 : bool parse(std::string const & str, bool reset = false);
38 15 : std::string const & get_string() const { return f_str; }
39 : string_part::level_t get_level(std::string const & name);
40 : void sort_by_level();
41 26 : string_part::vector_t & get_parts() { return f_parts; }
42 : string_part::vector_t const &
43 : get_parts() const { return f_parts; }
44 : std::string to_string() const;
45 22 : std::string const & error_messages() const { return f_error_messages; }
46 :
47 : private:
48 : std::string f_str = std::string();
49 : string_part::vector_t f_parts = string_part::vector_t(); // do NOT use a map, we want to keep them in order
50 : std::string f_error_messages = std::string();
51 : };
52 :
53 :
54 :
55 : } // namespace edhttp
56 : // vim: ts=4 sw=4 et
|