IntParam.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
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
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
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>&
48 {
49  return array;
50 }
51 
int type
Definition: errorpage.cc:79
void putInt(int n)
store an integer
Definition: TypedMsgHdr.cc:109
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:52
static MemPoolIterator Iterator
Definition: Pool.cc:26
virtual void unpackValue(const Ipc::TypedMsgHdr &msg)
load parameter value from msg
Definition: IntParam.cc:37
int getInt() const
load an integer
Definition: TypedMsgHdr.cc:101
virtual void pack(Ipc::TypedMsgHdr &msg) const
store parameter into msg
Definition: IntParam.cc:27
#define Must(cond)
Definition: TextException.h:89
struct msghdr with a known type, fixed-size I/O and control buffers
Definition: TypedMsgHdr.h:31
const std::vector< int > & value() const
Definition: IntParam.cc:47

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors