delete m_inventory_from_server;
// Delete detached inventories
- for (std::map<std::string, Inventory*>::iterator
+ for (UNORDERED_MAP<std::string, Inventory*>::iterator
i = m_detached_inventories.begin();
i != m_detached_inventories.end(); ++i) {
delete i->second;
break;
case InventoryLocation::DETACHED:
{
- if(m_detached_inventories.count(loc.name) == 0)
+ if (m_detached_inventories.count(loc.name) == 0)
return NULL;
return m_detached_inventories[loc.name];
}
u16 getHP();
u16 getBreath();
- bool checkPrivilege(const std::string &priv)
+ bool checkPrivilege(const std::string &priv) const
{ return (m_privileges.count(priv) != 0); }
bool getChatMessage(std::wstring &message);
std::map<int, u16> m_sounds_to_objects;
// Privileges
- std::set<std::string> m_privileges;
+ UNORDERED_SET<std::string> m_privileges;
// Detached inventories
// key = name
- std::map<std::string, Inventory*> m_detached_inventories;
+ UNORDERED_MAP<std::string, Inventory*> m_detached_inventories;
// Storage for mesh data for creating multiple instances of the same mesh
StringMap m_mesh_data;
{
MutexAutoLock clientslock(m_clients_mutex);
- for(std::map<u16, RemoteClient*>::iterator
- i = m_clients.begin();
- i != m_clients.end(); ++i)
- {
-
+ for (UNORDERED_MAP<u16, RemoteClient*>::iterator i = m_clients.begin();
+ i != m_clients.end(); ++i) {
// Delete client
delete i->second;
}
std::vector<u16> reply;
MutexAutoLock clientslock(m_clients_mutex);
- for(std::map<u16, RemoteClient*>::iterator
- i = m_clients.begin();
- i != m_clients.end(); ++i)
- {
+ for(UNORDERED_MAP<u16, RemoteClient*>::iterator i = m_clients.begin();
+ i != m_clients.end(); ++i) {
if (i->second->getState() >= min_state)
reply.push_back(i->second->peer_id);
}
NetworkPacket* pkt, bool reliable)
{
MutexAutoLock clientslock(m_clients_mutex);
- for(std::map<u16, RemoteClient*>::iterator
- i = m_clients.begin();
+ for(UNORDERED_MAP<u16, RemoteClient*>::iterator i = m_clients.begin();
i != m_clients.end(); ++i) {
RemoteClient *client = i->second;
RemoteClient* ClientInterface::getClientNoEx(u16 peer_id, ClientState state_min)
{
MutexAutoLock clientslock(m_clients_mutex);
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client may not exist; clients are immediately removed if their
// access is denied, and this event occurs later then.
- if(n == m_clients.end())
+ if (n == m_clients.end())
return NULL;
if (n->second->getState() >= state_min)
RemoteClient* ClientInterface::lockedGetClientNoEx(u16 peer_id, ClientState state_min)
{
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client may not exist; clients are immediately removed if their
// access is denied, and this event occurs later then.
- if(n == m_clients.end())
+ if (n == m_clients.end())
return NULL;
if (n->second->getState() >= state_min)
ClientState ClientInterface::getClientState(u16 peer_id)
{
MutexAutoLock clientslock(m_clients_mutex);
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client may not exist; clients are immediately removed if their
// access is denied, and this event occurs later then.
- if(n == m_clients.end())
+ if (n == m_clients.end())
return CS_Invalid;
return n->second->getState();
void ClientInterface::setPlayerName(u16 peer_id,std::string name)
{
MutexAutoLock clientslock(m_clients_mutex);
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client may not exist; clients are immediately removed if their
// access is denied, and this event occurs later then.
- if(n != m_clients.end())
+ if (n != m_clients.end())
n->second->setName(name);
}
MutexAutoLock conlock(m_clients_mutex);
// Error check
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client may not exist; clients are immediately removed if their
// access is denied, and this event occurs later then.
- if(n == m_clients.end())
+ if (n == m_clients.end())
return;
/*
MutexAutoLock conlock(m_clients_mutex);
// Error check
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// The client shouldn't already exist
- if(n != m_clients.end()) return;
+ if (n != m_clients.end()) return;
// Create client
RemoteClient *client = new RemoteClient();
MutexAutoLock clientlock(m_clients_mutex);
// Error check
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// No client to deliver event
if (n == m_clients.end())
MutexAutoLock conlock(m_clients_mutex);
// Error check
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// No client to get version
if (n == m_clients.end())
MutexAutoLock conlock(m_clients_mutex);
// Error check
- std::map<u16, RemoteClient*>::iterator n;
- n = m_clients.find(peer_id);
+ UNORDERED_MAP<u16, RemoteClient*>::iterator n = m_clients.find(peer_id);
// No client to set versions
if (n == m_clients.end())
#include "serialization.h" // for SER_FMT_VER_INVALID
#include "threading/mutex.h"
#include "network/networkpacket.h"
+#include "util/cpp11_container.h"
#include <list>
#include <vector>
-#include <map>
#include <set>
class MapBlock;
void lock() { m_clients_mutex.lock(); }
void unlock() { m_clients_mutex.unlock(); }
- std::map<u16, RemoteClient*>& getClientList()
- { return m_clients; }
+ UNORDERED_MAP<u16, RemoteClient*>& getClientList() { return m_clients; }
private:
/* update internal player list */
con::Connection* m_con;
Mutex m_clients_mutex;
// Connected clients (behind the con mutex)
- std::map<u16, RemoteClient*> m_clients;
+ UNORDERED_MAP<u16, RemoteClient*> m_clients;
std::vector<std::string> m_clients_names; //for announcing masterserver
// Environment
return;
m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render
- for(std::map<std::string,
- core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin();
- ii != m_bone_position.end(); ++ii)
- {
+ for(UNORDERED_MAP<std::string, core::vector2d<v3f> >::const_iterator
+ ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii) {
std::string bone_name = (*ii).first;
v3f bone_pos = (*ii).second.X;
v3f bone_rot = (*ii).second.Y;
int m_animation_speed;
int m_animation_blend;
bool m_animation_loop;
- std::map<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
+ UNORDERED_MAP<std::string, core::vector2d<v3f> > m_bone_position; // stores position and rotation for each bone name
std::string m_attachment_bone;
v3f m_attachment_position;
v3f m_attachment_rotation;
}
-bool EmergeManager::popBlockEmergeData(
- v3s16 pos,
- BlockEmergeData *bedata)
+bool EmergeManager::popBlockEmergeData(v3s16 pos, BlockEmergeData *bedata)
{
std::map<v3s16, BlockEmergeData>::iterator it;
- std::map<u16, u16>::iterator it2;
+ UNORDERED_MAP<u16, u16>::iterator it2;
it = m_blocks_enqueued.find(pos);
if (it == m_blocks_enqueued.end())
Mutex m_queue_mutex;
std::map<v3s16, BlockEmergeData> m_blocks_enqueued;
- std::map<u16, u16> m_peer_queue_count;
+ UNORDERED_MAP<u16, u16> m_peer_queue_count;
u16 m_qlimit_total;
u16 m_qlimit_diskonly;
void ServerEnvironment::getObjectsInsideRadius(std::vector<u16> &objects, v3f pos, float radius)
{
- for(std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
- i != m_active_objects.end(); ++i)
- {
+ for (ActiveObjectMap::iterator i = m_active_objects.begin();
+ i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
u16 id = i->first;
v3f objectpos = obj->getBasePosition();
- if(objectpos.getDistanceFrom(pos) > radius)
+ if (objectpos.getDistanceFrom(pos) > radius)
continue;
objects.push_back(id);
}
infostream << "ServerEnvironment::clearObjects(): "
<< "Removing all active objects" << std::endl;
std::vector<u16> objects_to_remove;
- for (std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
+ for (ActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
if (obj->getType() == ACTIVEOBJECT_TYPE_PLAYER)
send_recommended = true;
}
- for(std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
- i != m_active_objects.end(); ++i)
- {
+ for(ActiveObjectMap::iterator i = m_active_objects.begin();
+ i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
// Don't step if is to be removed or stored statically
if(obj->m_removed || obj->m_pending_deactivation)
Manage particle spawner expiration
*/
if (m_particle_management_interval.step(dtime, 1.0)) {
- for (std::map<u32, float>::iterator i = m_particle_spawners.begin();
+ for (UNORDERED_MAP<u32, float>::iterator i = m_particle_spawners.begin();
i != m_particle_spawners.end(); ) {
//non expiring spawners
if (i->second == PARTICLE_SPAWNER_NO_EXPIRY) {
u32 id = 0;
for (;;) { // look for unused particlespawner id
id++;
- std::map<u32, float>::iterator f;
- f = m_particle_spawners.find(id);
+ UNORDERED_MAP<u32, float>::iterator f = m_particle_spawners.find(id);
if (f == m_particle_spawners.end()) {
m_particle_spawners[id] = time;
break;
return id;
}
-void ServerEnvironment::deleteParticleSpawner(u32 id)
-{
- m_particle_spawners.erase(id);
-}
-
ServerActiveObject* ServerEnvironment::getActiveObject(u16 id)
{
- std::map<u16, ServerActiveObject*>::iterator n;
- n = m_active_objects.find(id);
- if(n == m_active_objects.end())
- return NULL;
- return n->second;
+ ActiveObjectMap::iterator n = m_active_objects.find(id);
+ return (n != m_active_objects.end() ? n->second : NULL);
}
-bool isFreeServerActiveObjectId(u16 id,
- std::map<u16, ServerActiveObject*> &objects)
+bool isFreeServerActiveObjectId(u16 id, ActiveObjectMap &objects)
{
- if(id == 0)
+ if (id == 0)
return false;
return objects.find(id) == objects.end();
}
-u16 getFreeServerActiveObjectId(
- std::map<u16, ServerActiveObject*> &objects)
+u16 getFreeServerActiveObjectId(ActiveObjectMap &objects)
{
//try to reuse id's as late as possible
static u16 last_used_id = 0;
- discard objects that are found in current_objects.
- add remaining objects to added_objects
*/
- for(std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
+ for(ActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
u16 id = i->first;
so_it = block->m_static_objects.m_active.begin();
so_it != block->m_static_objects.m_active.end(); ++so_it) {
// Get the ServerActiveObject counterpart to this StaticObject
- std::map<u16, ServerActiveObject *>::iterator ao_it;
- ao_it = m_active_objects.find(so_it->first);
+ ActiveObjectMap::iterator ao_it = m_active_objects.find(so_it->first);
if (ao_it == m_active_objects.end()) {
// If this ever happens, there must be some kind of nasty bug.
errorstream << "ServerEnvironment::setStaticForObjectsInBlock(): "
verbosestream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"supplied with id "<<object->getId()<<std::endl;
}
- if(isFreeServerActiveObjectId(object->getId(), m_active_objects) == false)
- {
+
+ if(!isFreeServerActiveObjectId(object->getId(), m_active_objects)) {
errorstream<<"ServerEnvironment::addActiveObjectRaw(): "
<<"id is not free ("<<object->getId()<<")"<<std::endl;
if(object->environmentDeletes())
void ServerEnvironment::removeRemovedObjects()
{
std::vector<u16> objects_to_remove;
- for(std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
+ for(ActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
u16 id = i->first;
ServerActiveObject* obj = i->second;
We will delete objects that are marked as removed or thatare
waiting for deletion after deactivation
*/
- if(obj->m_removed == false && obj->m_pending_deactivation == false)
+ if (!obj->m_removed && !obj->m_pending_deactivation)
continue;
/*
void ServerEnvironment::deactivateFarObjects(bool force_delete)
{
std::vector<u16> objects_to_remove;
- for(std::map<u16, ServerActiveObject*>::iterator
- i = m_active_objects.begin();
+ for(ActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
ServerActiveObject* obj = i->second;
assert(obj);
This is not thread-safe. Server uses an environment mutex.
*/
+typedef UNORDERED_MAP<u16, ServerActiveObject *> ActiveObjectMap;
+
class ServerEnvironment : public Environment
{
public:
void loadDefaultMeta();
u32 addParticleSpawner(float exptime);
- void deleteParticleSpawner(u32 id);
+ void deleteParticleSpawner(u32 id) { m_particle_spawners.erase(id); }
/*
External ActiveObject interface
// World path
const std::string m_path_world;
// Active object list
- std::map<u16, ServerActiveObject*> m_active_objects;
+ ActiveObjectMap m_active_objects;
// Outgoing network message buffer for active objects
std::queue<ActiveObjectMessage> m_active_object_messages;
// Some timers
// Particles
IntervalLimiter m_particle_management_interval;
- std::map<u32, float> m_particle_spawners;
+ UNORDERED_MAP<u32, float> m_particle_spawners;
};
#ifndef SERVER
void draw(s32 x_left, s32 y_bottom, video::IVideoDriver *driver,
gui::IGUIFont *font) const
{
- std::map<std::string, Meta> m_meta;
+ UNORDERED_MAP<std::string, Meta> m_meta;
for (std::deque<Piece>::const_iterator k = m_log.begin();
k != m_log.end(); ++k) {
i != piece.values.end(); ++i) {
const std::string &id = i->first;
const float &value = i->second;
- std::map<std::string, Meta>::iterator j =
- m_meta.find(id);
+ UNORDERED_MAP<std::string, Meta>::iterator j = m_meta.find(id);
if (j == m_meta.end()) {
m_meta[id] = Meta(value);
sizeof(usable_colors) / sizeof(*usable_colors);
u32 next_color_i = 0;
- for (std::map<std::string, Meta>::iterator i = m_meta.begin();
+ for (UNORDERED_MAP<std::string, Meta>::iterator i = m_meta.begin();
i != m_meta.end(); ++i) {
Meta &meta = i->second;
video::SColor color(255, 200, 200, 200);
s32 textx2 = textx + 200 - 15;
s32 meta_i = 0;
- for (std::map<std::string, Meta>::const_iterator i = m_meta.begin();
+ for (UNORDERED_MAP<std::string, Meta>::const_iterator i = m_meta.begin();
i != m_meta.end(); ++i) {
const std::string &id = i->first;
const Meta &meta = i->second;
}
os<<serializeString(tool_capabilities_s);
writeU16(os, groups.size());
- for(std::map<std::string, int>::const_iterator
+ for (ItemGroupList::const_iterator
i = groups.begin(); i != groups.end(); ++i){
- os<<serializeString(i->first);
+ os << serializeString(i->first);
writeS16(os, i->second);
}
os<<serializeString(node_placement_prediction);
#define ITEMGROUP_HEADER
#include <string>
-#include <map>
+#include "util/cpp11_container.h"
-typedef std::map<std::string, int> ItemGroupList;
+typedef UNORDERED_MAP<std::string, int> ItemGroupList;
static inline int itemgroup_get(const ItemGroupList &groups,
const std::string &name)
{
- std::map<std::string, int>::const_iterator i = groups.find(name);
+ ItemGroupList::const_iterator i = groups.find(name);
if(i == groups.end())
return 0;
return i->second;
m_block_cache = NULL;
// Delete all
- for(std::map<s16, MapBlock*>::iterator i = m_blocks.begin();
- i != m_blocks.end(); ++i)
- {
+ for (UNORDERED_MAP<s16, MapBlock*>::iterator i = m_blocks.begin();
+ i != m_blocks.end(); ++i) {
delete i->second;
}
{
MapBlock *block;
- if(m_block_cache != NULL && y == m_block_cache_y){
+ if (m_block_cache != NULL && y == m_block_cache_y) {
return m_block_cache;
}
// If block doesn't exist, return NULL
- std::map<s16, MapBlock*>::iterator n = m_blocks.find(y);
- if(n == m_blocks.end())
- {
- block = NULL;
- }
- // If block exists, return it
- else{
- block = n->second;
- }
+ UNORDERED_MAP<s16, MapBlock*>::iterator n = m_blocks.find(y);
+ block = (n != m_blocks.end() ? n->second : NULL);
// Cache the last result
m_block_cache_y = y;
void MapSector::getBlocks(MapBlockVect &dest)
{
- for(std::map<s16, MapBlock*>::iterator bi = m_blocks.begin();
- bi != m_blocks.end(); ++bi)
- {
+ for (UNORDERED_MAP<s16, MapBlock*>::iterator bi = m_blocks.begin();
+ bi != m_blocks.end(); ++bi) {
dest.push_back(bi->second);
}
}
-bool MapSector::empty()
-{
- return m_blocks.empty();
-}
-
/*
ServerMapSector
*/
void getBlocks(MapBlockVect &dest);
- bool empty();
+ bool empty() const { return m_blocks.empty(); }
// Always false at the moment, because sector contains no metadata.
bool differs_from_disk;
protected:
// The pile of MapBlocks
- std::map<s16, MapBlock*> m_blocks;
+ UNORDERED_MAP<s16, MapBlock*> m_blocks;
Map *m_parent;
// Position on parent (in MapBlock widths)
void generate_nodelist_and_update_ids(MapNode *nodes, size_t nodecount,
std::vector<std::string> *usednodes, INodeDefManager *ndef)
{
- std::map<content_t, content_t> nodeidmap;
+ UNORDERED_MAP<content_t, content_t> nodeidmap;
content_t numids = 0;
for (size_t i = 0; i != nodecount; i++) {
content_t id;
content_t c = nodes[i].getContent();
- std::map<content_t, content_t>::const_iterator it = nodeidmap.find(c);
+ UNORDERED_MAP<content_t, content_t>::const_iterator it = nodeidmap.find(c);
if (it == nodeidmap.end()) {
id = numids;
numids++;
/******************************************************************************/
/******************************************************************************/
-void read_groups(lua_State *L, int index,
- std::map<std::string, int> &result)
+void read_groups(lua_State *L, int index, ItemGroupList &result)
{
if (!lua_istable(L,index))
return;
}
/******************************************************************************/
-void push_groups(lua_State *L, const std::map<std::string, int> &groups)
+void push_groups(lua_State *L, const ItemGroupList &groups)
{
lua_newtable(L);
- std::map<std::string, int>::const_iterator it;
- for (it = groups.begin(); it != groups.end(); ++it) {
+ for (ItemGroupList::const_iterator it = groups.begin(); it != groups.end(); ++it) {
lua_pushnumber(L, it->second);
lua_setfield(L, -2, it->first.c_str());
}
}
#include <iostream>
-#include <map>
#include <vector>
#include "irrlichttypes_bloated.h"
#include "util/string.h"
+#include "itemgroup.h"
namespace Json { class Value; }
NodeBox read_nodebox (lua_State *L, int index);
void read_groups (lua_State *L, int index,
- std::map<std::string, int> &result);
+ ItemGroupList &result);
void push_groups (lua_State *L,
- const std::map<std::string, int> &groups);
+ const ItemGroupList &groups);
//TODO rename to "read_enum_field"
int getenumfield (lua_State *L, int table,
#define C_CONVERTER_H_
#include <vector>
-#include <map>
+#include "util/cpp11_container.h"
#include "irrlichttypes_bloated.h"
#include "common/c_types.h"
bool getintfield(lua_State *L, int table,
const char *fieldname, u32 &result);
void read_groups(lua_State *L, int index,
- std::map<std::string, int> &result);
+ UNORDERED_MAP<std::string, int> &result);
bool getboolfield(lua_State *L, int table,
const char *fieldname, bool &result);
bool getfloatfield(lua_State *L, int table,
int ModApiUtil::l_get_dig_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- std::map<std::string, int> groups;
+ ItemGroupList groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
int ModApiUtil::l_get_hit_params(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
- std::map<std::string, int> groups;
+ UNORDERED_MAP<std::string, int> groups;
read_groups(L, 1, groups);
ToolCapabilities tp = read_tool_capabilities(L, 2);
if(lua_isnoneornil(L, 3))
MutexAutoLock envlock(m_env_mutex);
m_clients.lock();
- std::map<u16, RemoteClient*> clients = m_clients.getClientList();
+ UNORDERED_MAP<u16, RemoteClient*> clients = m_clients.getClientList();
ScopeProfiler sp(g_profiler, "Server: checking added and deleted objs");
// Radius inside which objects are active
if (player_radius == 0 && is_transfer_limited)
player_radius = radius;
- for (std::map<u16, RemoteClient*>::iterator
- i = clients.begin();
+ for (UNORDERED_MAP<u16, RemoteClient*>::iterator i = clients.begin();
i != clients.end(); ++i) {
RemoteClient *client = i->second;
continue;
Player *player = m_env->getPlayer(client->peer_id);
- if(player == NULL) {
+ if (player == NULL) {
// This can happen if the client timeouts somehow
/*warningstream<<FUNCTION_NAME<<": Client "
<<client->peer_id
}
m_clients.lock();
- std::map<u16, RemoteClient*> clients = m_clients.getClientList();
+ UNORDERED_MAP<u16, RemoteClient*> clients = m_clients.getClientList();
// Route data to every client
- for (std::map<u16, RemoteClient*>::iterator
- i = clients.begin();
+ for (UNORDERED_MAP<u16, RemoteClient*>::iterator i = clients.begin();
i != clients.end(); ++i) {
RemoteClient *client = i->second;
std::string reliable_data;
{
MutexAutoLock lock(m_mutex);
- for (std::map<std::string, SettingsEntry>::const_iterator
- it = m_settings.begin();
- it != m_settings.end(); ++it)
+ for (SettingEntries::const_iterator it = m_settings.begin();
+ it != m_settings.end(); ++it)
printEntry(os, it->first, it->second, tab_depth);
}
bool Settings::updateConfigObject(std::istream &is, std::ostream &os,
const std::string &end, u32 tab_depth)
{
- std::map<std::string, SettingsEntry>::const_iterator it;
+ SettingEntries::const_iterator it;
std::set<std::string> present_entries;
std::string line, name, value;
bool was_modified = false;
{
MutexAutoLock lock(m_mutex);
- std::map<std::string, SettingsEntry>::const_iterator n;
+ SettingEntries::const_iterator n;
if ((n = m_settings.find(name)) == m_settings.end()) {
if ((n = m_defaults.find(name)) == m_defaults.end())
throw SettingNotFoundException("Setting [" + name + "] not found.");
std::vector<std::string> Settings::getNames() const
{
std::vector<std::string> names;
- for (std::map<std::string, SettingsEntry>::const_iterator
- i = m_settings.begin();
- i != m_settings.end(); ++i) {
+ for (SettingEntries::const_iterator i = m_settings.begin();
+ i != m_settings.end(); ++i) {
names.push_back(i->first);
}
return names;
{
MutexAutoLock lock(m_mutex);
- std::map<std::string, SettingsEntry>::iterator it = m_settings.find(name);
+ SettingEntries::iterator it = m_settings.find(name);
if (it != m_settings.end()) {
delete it->second.group;
m_settings.erase(it);
try {
std::string val = other.get(name);
-
m_settings[name] = val;
} catch (SettingNotFoundException &e) {
}
void Settings::clearNoLock()
{
- std::map<std::string, SettingsEntry>::const_iterator it;
- for (it = m_settings.begin(); it != m_settings.end(); ++it)
+
+ for (SettingEntries::const_iterator it = m_settings.begin();
+ it != m_settings.end(); ++it)
delete it->second.group;
m_settings.clear();
void Settings::clearDefaultsNoLock()
{
- std::map<std::string, SettingsEntry>::const_iterator it;
- for (it = m_defaults.begin(); it != m_defaults.end(); ++it)
+ for (SettingEntries::const_iterator it = m_defaults.begin();
+ it != m_defaults.end(); ++it)
delete it->second.group;
m_defaults.clear();
}
bool is_group;
};
+typedef UNORDERED_MAP<std::string, SettingsEntry> SettingEntries;
+
class Settings {
public:
Settings() {}
void doCallbacks(const std::string &name) const;
- std::map<std::string, SettingsEntry> m_settings;
- std::map<std::string, SettingsEntry> m_defaults;
+ SettingEntries m_settings;
+ SettingEntries m_defaults;
SettingsCallbackMap m_callbacks;