]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/QueryParams.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / mgr / QueryParams.h
1 /*
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9 /* DEBUG: section 16 Cache Manager API */
10
11 #ifndef SQUID_MGR_QUERY_PARAMS_H
12 #define SQUID_MGR_QUERY_PARAMS_H
13
14 #include "ipc/forward.h"
15 #include "mgr/QueryParam.h"
16 #include "SquidString.h"
17 #include <vector>
18 #include <utility>
19
20 namespace Mgr
21 {
22
23 class QueryParams
24 {
25 public:
26 typedef std::pair<String, QueryParam::Pointer> Param;
27 typedef std::vector<Param> Params;
28
29 public:
30 /// returns query parameter by name
31 QueryParam::Pointer get(const String& name) const;
32 void pack(Ipc::TypedMsgHdr& msg) const; ///< store params into msg
33 void unpack(const Ipc::TypedMsgHdr& msg); ///< load params from msg
34 /// parses the query string parameters
35 static bool Parse(const String& aParamsStr, QueryParams& aParams);
36
37 private:
38 /// find query parameter by name
39 Params::const_iterator find(const String& name) const;
40 /// creates a parameter of the specified type
41 static QueryParam::Pointer CreateParam(QueryParam::Type aType);
42 /// parses string like "param=value"; returns true if success
43 static bool ParseParam(const String& paramStr, Param& param);
44
45 private:
46 Params params;
47 };
48
49 } // namespace Mgr
50
51 #endif /* SQUID_MGR_QUERY_PARAMS_H */
52