This file is indexed.

/usr/include/Poco/Redis/Array.h is in libpoco-dev 1.8.0.1-1ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
//
// Array.h
//
// Library: Redis
// Package: Redis
// Module:  Array
//
// Definition of the Array class.
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef Redis_Array_INCLUDED
#define Redis_Array_INCLUDED


#include "Poco/Redis/Redis.h"
#include "Poco/Redis/Type.h"
#include "Poco/Redis/Exception.h"
#include <vector>
#include <sstream>


namespace Poco {
namespace Redis {


class Redis_API Array
	/// Represents a Redis Array. An Array can contain Integers, Strings,
	/// Bulk Strings, Errors and other Arrays. It can also contain a Null
	/// value.
{
public:
	typedef std::vector<RedisType::Ptr>::const_iterator const_iterator;

	Array();
		/// Creates an Array. As long as there are no elements added,
		/// the array will contain a Null value.

	Array(const Array& copy);
		/// Creates an Array by copying another one.

	virtual ~Array();
		/// Destroys the Array.

	template<typename T>
	Array& operator<<(const T& arg)
		/// Adds the argument to the array.
		///
		/// Note: a std::string will be added as a BulkString because this
		/// is commonly used for representing strings in Redis. If you
		/// really need a simple string, use addSimpleString().
	{
		return add(arg);
	}

	Array& operator<<(const char* s);
		/// Special implementation for const char*.
		///
		/// Note: the specialization creates a BulkString. If you need
		/// a simple string, call addSimpleString().

	Array& operator<<(const std::vector<std::string>& strings);
		/// Special implementation for a vector with strings.
		/// All strings will be added as a BulkString.

	Array& add();
		/// Adds an Null BulkString.

	template<typename T>
	Array& add(const T& arg)
		/// Adds an element to the array.
		///
		/// Note: the specialization for std::string will add a BulkString!
		/// If you really need a simple string, call addSimpleString.
	{
		addRedisType(new Type<T>(arg));
		return *this;
	}

	Array& add(const char* s);
		/// Special implementation for const char*.
		///
		/// Note: the specialization creates a BulkString. If you need
		/// a simple string, call addSimpleString.

	Array& add(const std::vector<std::string>& strings);
		/// Special implementation for a vector with strings.
		/// All strings will be added as a BulkString.

	Array& addRedisType(RedisType::Ptr value);
		/// Adds a Redis element.

	Array& addSimpleString(const std::string& value);
		/// Adds a simple string (can't contain newline characters!).

	const_iterator begin() const;
		/// Returns an iterator to the start of the array. 
		///
		/// Note: this can throw a NullValueException when this is a Null array.

	void clear();
		/// Removes all elements from the array.

	const_iterator end() const;
		/// Returns an iterator to the end of the array. 
		///
		/// Note: this can throw a NullValueException when this is a Null array.

	template<typename T>
	T get(size_t pos) const
		/// Returns the element on the given position and tries to convert
		/// to the template type. A Poco::BadCastException will be thrown when the
		/// the conversion fails. An Poco::InvalidArgumentException will be thrown
		/// when the index is out of range. When the array is a Null array
		/// a Poco::NullValueException is thrown.
	{
		if ( _elements.isNull() ) throw NullValueException();

		if ( pos >= _elements.value().size() ) throw InvalidArgumentException();

		RedisType::Ptr element = _elements.value().at(pos);
		if ( RedisTypeTraits<T>::TypeId == element->type() )
		{
			Type<T>* concrete = dynamic_cast<Type<T>* >(element.get());
			if ( concrete != NULL ) return concrete->value();
		}
		throw BadCastException();
	}

	int getType(size_t pos) const;
		/// Returns the type of the element. This can throw a Poco::NullValueException
		/// when this array is a Null array. An Poco::InvalidArgumentException will
		/// be thrown when the index is out of range.

	bool isNull() const;
		/// Returns true when this is a Null array.

	void makeNull();
		/// Turns the array into a Null array. When the array already has some
		/// elements, the array will be cleared.

	std::string toString() const;
		/// Returns the String representation as specified in the
		/// Redis Protocol specification.

	size_t size() const;
		/// Returns the size of the array. 
		///
		/// Note: this can throw a NullValueException when this is a Null array.

private:
	void checkNull();
		/// Checks for null array and sets a new vector if true.

	Nullable<std::vector<RedisType::Ptr> > _elements;
};


//
// inlines
//


inline Array& Array::operator<<(const char* s)
{
	BulkString value(s);
	return add(value);
}


inline Array& Array::operator<<(const std::vector<std::string>& strings)
{
	return add(strings);
}


inline Array& Array::add()
{
	BulkString value;
	return add(value);
}


template<>
inline Array& Array::add(const std::string& arg)
{
	BulkString value(arg);
	return add(value);
}


inline Array& Array::add(const char* s)
{
	BulkString value(s);
	return add(value);
}


inline Array& Array::add(const std::vector<std::string>& strings)
{
	for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); ++it)
	{
		add(*it);
	}
	return *this;
}


inline Array& Array::addSimpleString(const std::string& value)
{
	return addRedisType(new Type<std::string>(value));
}


inline Array::const_iterator Array::begin() const
{
	return _elements.value().begin();
}


inline void Array::checkNull()
{
	std::vector<RedisType::Ptr> v;
	if ( _elements.isNull() ) _elements.assign(v);
}


inline void Array::clear()
{
	if ( !_elements.isNull() )
	{
		_elements.value().clear();
	}
}


inline Array::const_iterator Array::end() const
{
	return _elements.value().end();
}


inline bool Array::isNull() const
{
	return _elements.isNull();
}


inline void Array::makeNull()
{
	if ( !_elements.isNull() ) _elements.value().clear();

	_elements.clear();
}


inline size_t Array::size() const
{
	return _elements.value().size();
}


template<>
struct RedisTypeTraits<Array>
{
	enum { TypeId = RedisType::REDIS_ARRAY };

	static const char marker = '*';

	static std::string toString(const Array& value)
	{
		std::stringstream result;
		result <<  marker;
		if ( value.isNull() )
		{
			result << "-1" << LineEnding::NEWLINE_CRLF;
		}
		else
		{
			result << value.size() << LineEnding::NEWLINE_CRLF;
			for(std::vector<RedisType::Ptr>::const_iterator it = value.begin();
				it != value.end(); ++it)
			{
				result << (*it)->toString();
			}
		}
		return result.str();
	}

	static void read(RedisInputStream& input, Array& value)
	{
		value.clear();

		Int64 length = NumberParser::parse64(input.getline());

		if ( length != -1 )
		{
			for(int i = 0; i < length; ++i)
			{
				char marker = input.get();
				RedisType::Ptr element = RedisType::createRedisType(marker);

				if ( element.isNull() )
					throw RedisException("Wrong answer received from Redis server");

				element->read(input);
				value.addRedisType(element);
			}
		}
	}
};


} } // namespace Poco::Redis


#endif // Redis_Array_INCLUDED