This file is indexed.

/usr/include/Poco/JSON/ParserImpl.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
//
// Parser.h
//
// Library: JSON
// Package: JSON
// Module:  ParserImpl
//
// Definition of the ParserImpl class.
//
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier:	BSL-1.0
//


#ifndef JSON_JSONParserImpl_INCLUDED
#define JSON_JSONParserImpl_INCLUDED


#include "Poco/JSON/JSON.h"
#include "Poco/JSON/Object.h"
#include "Poco/JSON/Array.h"
#include "Poco/JSON/ParseHandler.h"
#include "Poco/JSON/JSONException.h"
#include "Poco/UTF8Encoding.h"
#include "Poco/Dynamic/Var.h"
#include <string>


struct json_stream;

namespace Poco {
namespace JSON {


class JSON_API ParserImpl
{
protected:
	static const std::size_t JSON_PARSE_BUFFER_SIZE = 4096;
	static const std::size_t JSON_PARSER_STACK_SIZE = 128;
	static const int         JSON_UNLIMITED_DEPTH = -1;

	ParserImpl(const Handler::Ptr& pHandler = new ParseHandler, std::size_t bufSize = JSON_PARSE_BUFFER_SIZE);
		/// Creates JSON ParserImpl, using the given Handler and buffer size.

	virtual ~ParserImpl();
		/// Destroys JSON ParserImpl.

	void resetImpl();
		/// Resets the parser.

	void setAllowCommentsImpl(bool comments);
		/// Allow or disallow comments. By default, comments are not allowed.

	bool getAllowCommentsImpl() const;
		/// Returns true if comments are allowed, false otherwise.
		///
		/// By default, comments are not allowed.

	void setAllowNullByteImpl(bool nullByte);
		/// Allow or disallow null byte in strings.
		///
		/// By default, null byte is allowed.

	bool getAllowNullByteImpl() const;
		/// Returns true if null byte is allowed, false otherwise.
		///
		/// By default, null bytes are allowed.

	void setDepthImpl(std::size_t depth);
		/// Sets the allowed JSON depth.

	std::size_t getDepthImpl() const;
		/// Returns the allowed JSON depth.

	Dynamic::Var parseImpl(const std::string& json);
		/// Parses JSON from a string.

	Dynamic::Var parseImpl(std::istream& in);
		/// Parses JSON from an input stream.

	void setHandlerImpl(const Handler::Ptr& pHandler);
		/// Set the Handler.

	const Handler::Ptr& getHandlerImpl();
		/// Returns the Handler.

	Dynamic::Var asVarImpl() const;
		/// Returns the result of parsing;

	Dynamic::Var resultImpl() const;
		/// Returns the result of parsing as Dynamic::Var;

private:
	ParserImpl(const ParserImpl&);
	ParserImpl& operator =(const ParserImpl&);

	void handleArray();
	void handleObject();
	void handle();
	void handle(const std::string& json);
	void stripComments(std::string& json);
	bool checkError();

	json_stream* _pJSON;
	Handler::Ptr _pHandler;
	int          _depth;
	char         _decimalPoint;
	bool         _allowNullByte;
	bool         _allowComments;
};


//
// inlines
//

inline void ParserImpl::resetImpl()
{
	// currently, json stream is opened and closed on every parse request
	// (perhaps there is some optimization room?)
	//json_reset(&_json);
	if (_pHandler) _pHandler->reset();
}


inline void ParserImpl::setAllowCommentsImpl(bool comments)
{
	_allowComments = comments;
}


inline bool ParserImpl::getAllowCommentsImpl() const
{
	return _allowComments;
}


inline void ParserImpl::setAllowNullByteImpl(bool nullByte)
{
	_allowNullByte = nullByte;
}


inline bool ParserImpl::getAllowNullByteImpl() const
{
	return _allowNullByte;
}


inline void ParserImpl::setDepthImpl(std::size_t depth)
{
	_depth = static_cast<int>(depth);
}


inline std::size_t ParserImpl::getDepthImpl() const
{
	return static_cast<int>(_depth);
}


inline void ParserImpl::setHandlerImpl(const Handler::Ptr& pHandler)
{
	_pHandler = pHandler;
}


inline const Handler::Ptr& ParserImpl::getHandlerImpl()
{
	return _pHandler;
}


inline Dynamic::Var ParserImpl::resultImpl() const
{
	return asVarImpl();
}


inline Dynamic::Var ParserImpl::asVarImpl() const
{
	if (_pHandler) return _pHandler->asVar();

	return Dynamic::Var();
}


} } // namespace Poco::JSON


#endif // JSON_JSONParserImpl_INCLUDED