IntParam.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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 "debug/Stream.h"
14#include "ipc/TypedMsgHdr.h"
15#include "mgr/IntParam.h"
16
18 QueryParam(QueryParam::ptInt), array()
19{
20}
21
22Mgr::IntParam::IntParam(const std::vector<int>& anArray):
23 QueryParam(QueryParam::ptInt), array(anArray)
24{
25}
26
27void
29{
30 msg.putPod(type);
31 msg.putInt(array.size());
32 typedef std::vector<int>::const_iterator Iterator;
33 for (Iterator iter = array.begin(); iter != array.end(); ++iter)
34 msg.putInt(*iter);
35}
36
37void
39{
40 array.clear();
41 int count = msg.getInt();
42 Must(count >= 0);
43 for ( ; count > 0; --count)
44 array.push_back(msg.getInt());
45}
46
47const std::vector<int>&
49{
50 return array;
51}
52
#define Must(condition)
Definition: TextException.h:75
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:35
void putInt(int n)
store an integer
Definition: TypedMsgHdr.cc:119
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:126
int getInt() const
load an integer
Definition: TypedMsgHdr.cc:111
void unpackValue(const Ipc::TypedMsgHdr &msg) override
load parameter value from msg
Definition: IntParam.cc:38
void pack(Ipc::TypedMsgHdr &msg) const override
store parameter into msg
Definition: IntParam.cc:28
const std::vector< int > & value() const
Definition: IntParam.cc:48

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors