<commit_before>#ifndef SRC_LIB_MONGOBACKEND_SAFEBSONGET_H_
#define SRC_LIB_MONGOBACKEND_SAFEBSONGET_H_

/*
*
* Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U
*
* This file is part of Orion Context Broker.
*
* Orion Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion Context Broker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* iot_support at tid dot es
*
* Author: <NAME>
*/

#include "ngsi/SubscriptionId.h"
#include "ngsi/RegistrationId.h"
#include "ngsi/StatusCode.h"

#include "mongo/client/dbclient.h"

/* ****************************************************************************
*
* getObjectField -
*/
extern mongo::BSONObj getObjectField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getStringField -
*/
extern std::string getStringField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getIntField -
*/
extern int getIntField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getLongField -
*/
extern long long getLongField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getIntOrLongFieldAsLong -
*/
extern long long getIntOrLongFieldAsLong(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getBoolField -
*/
extern bool getBoolField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* getField -
*/
extern mongo::BSONElement getField(const mongo::BSONObj& b, const std::string& field, const std::string& caller);

/* ****************************************************************************
*
* moreSafe -
*/
extern bool moreSafe(const std::auto_ptr<mongo::DBClientCursor>& cursor);

/* ****************************************************************************
*
* nextSafeOrError -<commit_msg>FIX using caller default for get*Field() mongoBackend in order to make unit test compilation easier<commit_after>#ifndef SRC_LIB_MONGOBACKEND_SAFEBSONGET_H_
#define SRC_LIB_MONGOBACKEND_SAFEBSONGET_H_

/*
*
* Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U
*
* This file is part of Orion Context Broker.
*
* Orion Context Broker is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Orion Context Broker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
* General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Orion Context Broker. If not, see http://www.gnu.org/licenses/.
*
* For those usages not covered by this license please contact with
* iot_support at tid dot es
*
* Author: <NAME>
*/

#include "ngsi/SubscriptionId.h"
#include "ngsi/RegistrationId.h"
#include "ngsi/StatusCode.h"

#include "mongo/client/dbclient.h"

/* ****************************************************************************
*
* getObjectField -
*/
extern mongo::BSONObj getObjectField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getStringField -
*/
extern std::string getStringField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getIntField -
*/
extern int getIntField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getLongField -
*/
extern long long getLongField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getIntOrLongFieldAsLong -
*/
extern long long getIntOrLongFieldAsLong(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getBoolField -
*/
extern bool getBoolField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* getField -
*/
extern mongo::BSONElement getField(const mongo::BSONObj& b, const std::string& field, const std::string& caller = "<none>");

/* ****************************************************************************
*
* moreSafe -
*/
extern bool moreSafe(const std::auto_ptr<mongo::DBClientCursor>& cursor);

/* ****************************************************************************
*
* nextSafeOrError -
{'fraction_non_alphanumeric': 0.31685133123863074, 'fraction_numerical': 0.00165371258475277, 'mean_word_length': 6.607547169811321, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6119403', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1518, 'n_words': 507}