This file is indexed.

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


#ifndef MongoDB_Database_INCLUDED
#define MongoDB_Database_INCLUDED


#include "Poco/MongoDB/MongoDB.h"
#include "Poco/MongoDB/Connection.h"
#include "Poco/MongoDB/Document.h"
#include "Poco/MongoDB/QueryRequest.h"
#include "Poco/MongoDB/InsertRequest.h"
#include "Poco/MongoDB/UpdateRequest.h"
#include "Poco/MongoDB/DeleteRequest.h"


namespace Poco {
namespace MongoDB {


class MongoDB_API Database
	/// Database is a helper class for creating requests. MongoDB works with
	/// collection names and uses the part before the first dot as the name of
	/// the database.
{
public:
	explicit Database(const std::string& name);
		/// Creates a Database for the database with the given name.

	virtual ~Database();
		/// Destroys the Database.
		
	bool authenticate(Connection& connection, const std::string& username, const std::string& password, const std::string& method = AUTH_SCRAM_SHA1);
		/// Authenticates against the database using the given connection,
		/// username and password, as well as authentication method.
		///
		/// "MONGODB-CR" (default prior to MongoDB 3.0) and 
		/// "SCRAM-SHA-1" (default starting in 3.0) are the only supported 
		/// authentication methods.
		///
		/// Returns true if authentication was successful, otherwise false.
		///
		/// May throw a Poco::ProtocolException if authentication fails for a reason other than
		/// invalid credentials.

	Int64 count(Connection& connection, const std::string& collectionName) const;
		/// Sends a count request for the given collection to MongoDB. 
		///
		/// If the command fails, -1 is returned.

	Poco::SharedPtr<Poco::MongoDB::QueryRequest> createCommand() const;
		/// Creates a QueryRequest for a command.

	Poco::SharedPtr<Poco::MongoDB::QueryRequest> createCountRequest(const std::string& collectionName) const;
		/// Creates a QueryRequest to count the given collection. 
		/// The collectionname must not contain the database name.

	Poco::SharedPtr<Poco::MongoDB::DeleteRequest> createDeleteRequest(const std::string& collectionName) const;
		/// Creates a DeleteRequest to delete documents in the given collection.
		/// The collectionname must not contain the database name.

	Poco::SharedPtr<Poco::MongoDB::InsertRequest> createInsertRequest(const std::string& collectionName) const;
		/// Creates an InsertRequest to insert new documents in the given collection.
		/// The collectionname must not contain the database name.

	Poco::SharedPtr<Poco::MongoDB::QueryRequest> createQueryRequest(const std::string& collectionName) const;
		/// Creates a QueryRequest. 
		/// The collectionname must not contain the database name.

	Poco::SharedPtr<Poco::MongoDB::UpdateRequest> createUpdateRequest(const std::string& collectionName) const;
		/// Creates an UpdateRequest. 
		/// The collectionname must not contain the database name.

	Poco::MongoDB::Document::Ptr ensureIndex(Connection& connection,
		const std::string& collection,
		const std::string& indexName,
		Poco::MongoDB::Document::Ptr keys,
		bool unique = false,
		bool background = false,
		int version = 0,
		int ttl = 0);
		/// Creates an index. The document returned is the result of a getLastError call.
		/// For more info look at the ensureIndex information on the MongoDB website.

	Document::Ptr getLastErrorDoc(Connection& connection) const;
		/// Sends the getLastError command to the database and returns the error document.

	std::string getLastError(Connection& connection) const;
		/// Sends the getLastError command to the database and returns the err element
		/// from the error document. When err is null, an empty string is returned.

	static const std::string AUTH_MONGODB_CR;
		/// Default authentication mechanism prior to MongoDB 3.0.
		
	static const std::string AUTH_SCRAM_SHA1;
		/// Default authentication mechanism for MongoDB 3.0.

protected:
	bool authCR(Connection& connection, const std::string& username, const std::string& password);
	bool authSCRAM(Connection& connection, const std::string& username, const std::string& password);

private:
	std::string _dbname;
};


//
// inlines
//
inline Poco::SharedPtr<Poco::MongoDB::QueryRequest> Database::createCommand() const
{
	Poco::SharedPtr<Poco::MongoDB::QueryRequest> cmd = createQueryRequest("$cmd");
	cmd->setNumberToReturn(1);
	return cmd;
}


inline Poco::SharedPtr<Poco::MongoDB::DeleteRequest>
Database::createDeleteRequest(const std::string& collectionName) const
{
	return new Poco::MongoDB::DeleteRequest(_dbname + '.' + collectionName);
}


inline Poco::SharedPtr<Poco::MongoDB::InsertRequest>
Database::createInsertRequest(const std::string& collectionName) const
{
	return new Poco::MongoDB::InsertRequest(_dbname + '.' + collectionName);
}


inline Poco::SharedPtr<Poco::MongoDB::QueryRequest>
Database::createQueryRequest(const std::string& collectionName) const
{
	return new Poco::MongoDB::QueryRequest(_dbname + '.' + collectionName);
}


inline Poco::SharedPtr<Poco::MongoDB::UpdateRequest>
Database::createUpdateRequest(const std::string& collectionName) const
{
	return new Poco::MongoDB::UpdateRequest(_dbname + '.' + collectionName);
}


} } // namespace Poco::MongoDB


#endif // MongoDB_Database_INCLUDED