IntParam.cc
Go to the documentation of this file.
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 "Debug.h"
14 #include "ipc/TypedMsgHdr.h"
15 #include "mgr/IntParam.h"
16 
18  QueryParam(QueryParam::ptInt), array()
19 {
20 }
21 
22 Mgr::IntParam::IntParam(const std::vector<int>& anArray):
23  QueryParam(QueryParam::ptInt), array(anArray)
24 {
25 }
26 
27 void
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 
37 void
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 
47 const std::vector<int>&
49 {
50  return array;
51 }
52 
int type
Definition: errorpage.cc:78
void putInt(int n)
store an integer
Definition: TypedMsgHdr.cc:109
void putPod(const Pod &pod)
store POD
Definition: TypedMsgHdr.h:52
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
static MemPoolIterator Iterator
Definition: Pool.cc:26
virtual void unpackValue(const Ipc::TypedMsgHdr &msg)
load parameter value from msg
Definition: IntParam.cc:38
int getInt() const
load an integer
Definition: TypedMsgHdr.cc:101
virtual void pack(Ipc::TypedMsgHdr &msg) const
store parameter into msg
Definition: IntParam.cc:28
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:48

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors