mirror of https://gitee.com/bigwinds/arangodb
use range-based for loop
This commit is contained in:
parent
9b1ef915eb
commit
a7c8a37938
|
@ -33,7 +33,6 @@
|
|||
#include "Basics/ReadWriteLock.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Basics/delete_object.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
|
||||
|
@ -48,13 +47,13 @@ using namespace triagens::basics;
|
|||
/// @brief actions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static map<string, TRI_action_t*> Actions;
|
||||
static std::map<string, TRI_action_t*> Actions;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief prefix actions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static map<string, TRI_action_t*> PrefixActions;
|
||||
static std::map<string, TRI_action_t*> PrefixActions;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief actions lock
|
||||
|
@ -180,10 +179,14 @@ TRI_action_t* TRI_LookupActionVocBase (triagens::rest::HttpRequest* request) {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TRI_CleanupActions () {
|
||||
for_each(Actions.begin(), Actions.end(), DeleteObjectValue());
|
||||
for (auto& it: Actions) {
|
||||
delete it.second;
|
||||
}
|
||||
Actions.clear();
|
||||
|
||||
for_each(PrefixActions.begin(), PrefixActions.end(), DeleteObjectValue());
|
||||
for (auto& it: PrefixActions) {
|
||||
delete it.second;
|
||||
}
|
||||
PrefixActions.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/RandomGenerator.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/delete_object.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/files.h"
|
||||
|
@ -129,7 +128,9 @@ ApplicationServer::ApplicationServer (std::string const& name, std::string const
|
|||
|
||||
ApplicationServer::~ApplicationServer () {
|
||||
Random::shutdown();
|
||||
for_each(_features.begin(), _features.end(), DeleteObjectAny());
|
||||
for (auto& it : _features) {
|
||||
delete it;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "Basics/RandomGenerator.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Basics/delete_object.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/ssl-helper.h"
|
||||
|
@ -134,7 +133,9 @@ ApplicationEndpointServer::~ApplicationEndpointServer () {
|
|||
// overloaded class operator is a little unwieldy.
|
||||
// ..........................................................................
|
||||
|
||||
for_each(_servers.begin(), _servers.end(), triagens::basics::DeleteObjectAny());
|
||||
for (auto& it : _servers) {
|
||||
delete it;
|
||||
}
|
||||
_servers.clear();
|
||||
|
||||
if (_handlerFactory != nullptr) {
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete object helper
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2006-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_BASICS_DELETE__OBJECT_H
|
||||
#define ARANGODB_BASICS_DELETE__OBJECT_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete object helper
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct DeleteObjectAny {
|
||||
template<typename T> void operator () (const T* ptr) const {
|
||||
if (ptr != 0) {
|
||||
delete ptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete object helper for maps
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct DeleteObjectKey {
|
||||
template<typename T, typename S> void operator () (std::pair<T,S>& ptr) const {
|
||||
if (ptr.first != 0) {
|
||||
delete ptr.first;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief delete object helper for maps
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct DeleteObjectValue {
|
||||
template<typename T, typename S> void operator () (std::pair<T,S>& ptr) const {
|
||||
if (ptr.second != 0) {
|
||||
delete ptr.second;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
Loading…
Reference in New Issue