]> git.ipfire.org Git - thirdparty/squid.git/blob - src/mgr/IntParam.cc
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / mgr / IntParam.cc
1 /*
2 * Copyright (C) 1996-2018 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 #include "squid.h"
12 #include "base/TextException.h"
13 #include "ipc/TypedMsgHdr.h"
14 #include "mgr/IntParam.h"
15
16 Mgr::IntParam::IntParam():
17 QueryParam(QueryParam::ptInt), array()
18 {
19 }
20
21 Mgr::IntParam::IntParam(const std::vector<int>& anArray):
22 QueryParam(QueryParam::ptInt), array(anArray)
23 {
24 }
25
26 void
27 Mgr::IntParam::pack(Ipc::TypedMsgHdr& msg) const
28 {
29 msg.putPod(type);
30 msg.putInt(array.size());
31 typedef std::vector<int>::const_iterator Iterator;
32 for (Iterator iter = array.begin(); iter != array.end(); ++iter)
33 msg.putInt(*iter);
34 }
35
36 void
37 Mgr::IntParam::unpackValue(const Ipc::TypedMsgHdr& msg)
38 {
39 array.clear();
40 int count = msg.getInt();
41 Must(count >= 0);
42 for ( ; count > 0; --count)
43 array.push_back(msg.getInt());
44 }
45
46 const std::vector<int>&
47 Mgr::IntParam::value() const
48 {
49 return array;
50 }
51