]> git.ipfire.org Git - thirdparty/squid.git/blame - src/mgr/IntParam.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / mgr / IntParam.cc
CommitLineData
b8151fa1 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
b8151fa1 3 *
bbc27441
AJ
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.
b8151fa1
CT
7 */
8
bbc27441
AJ
9/* DEBUG: section 16 Cache Manager API */
10
f7f3304a 11#include "squid.h"
b8151fa1
CT
12#include "base/TextException.h"
13#include "ipc/TypedMsgHdr.h"
14#include "mgr/IntParam.h"
15
b8151fa1 16Mgr::IntParam::IntParam():
f53969cc 17 QueryParam(QueryParam::ptInt), array()
b8151fa1
CT
18{
19}
20
21Mgr::IntParam::IntParam(const std::vector<int>& anArray):
f53969cc 22 QueryParam(QueryParam::ptInt), array(anArray)
b8151fa1
CT
23{
24}
25
26void
27Mgr::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
36void
37Mgr::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
46const std::vector<int>&
47Mgr::IntParam::value() const
48{
49 return array;
50}
f53969cc 51