blob: 69b69965880cffe15c5d0106c3e61425826fb0b4 (
plain)
ofs | hex dump | ascii |
---|
0000 | 42 42 33 44 63 8d 00 00 01 00 00 00 42 52 55 53 2e 00 00 00 01 00 00 00 42 72 75 73 68 2e 30 30 | BB3Dc.......BRUS........Brush.00 |
0020 | 31 00 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 00 00 01 00 00 00 00 00 00 00 ff ff | 1....?...?...?...?.............. |
0040 | ff ff 4e 4f 44 45 21 8d 00 00 64 74 72 61 63 6b 5f 73 77 72 73 74 00 00 00 00 00 00 00 00 bf 00 | ..NODE!...dtrack_swrst.......... |
0060 | 00 00 00 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 80 3f 00 00 00 00 a4 85 08 b3 00 00 00 00 4d | ......?...?...?...?............M |
0080 | 45 53 48 e4 8c 00 00 ff ff ff ff 56 52 54 53 0c 77 00 00 01 00 00 00 01 00 00 00 02 00 00 00 74 | ESH........VRTS.w..............t |
00a0 | d4 02 bf 28 5c 0f 3e b4 1b 7c 3d 70 c1 37 bf 5d 8f 2e 3f 20 f1 0f 3e a5 ff 00 3e 24 e4 04 3f 01 | ...(\.>..|=p.7.]..?...>...>$..?. |
00c0 | db 04 bf 28 5c 0f 3e f2 5d 27 bd 6c 1f 36 bf 67 a3 33 3f 35 a1 1a 3d a4 ff 00 3e 2e 13 dd 3e 02 | ...(\.>.]'.l.6.g.3?5..=...>...>. |
00e0 | bf e3 be 28 5c 0f 3e 86 df 06 bd 69 af 34 3f 6b 55 35 3f fe 01 ff 3b 4c 1f 37 3e 34 13 dd 3e 34 | ...(\.>/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef NAMEIDMAPPING_HEADER
#define NAMEIDMAPPING_HEADER
#include <string>
#include <iostream>
#include <set>
#include <map>
#include "irrlichttypes_bloated.h"
class NameIdMapping
{
public:
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is);
void clear(){
m_id_to_name.clear();
m_name_to_id.clear();
}
void set(u16 id, const std::string &name){
m_id_to_name[id] = name;
m_name_to_id[name] = id;
}
void removeId(u16 id){
std::string name;
bool found = getName(id, name);
if(!found) return;
m_id_to_name.erase(id);
m_name_to_id.erase(name);
}
void eraseName(const std::string &name){
u16 id;
bool found = getId(name, id);
if(!found) return;
m_id_to_name.erase(id);
m_name_to_id.erase(name);
}
bool getName(u16 id, std::string &result) const{
std::map<u16, std::string>::const_iterator i;
i = m_id_to_name.find(id);
if(i == m_id_to_name.end())
return false;
result = i->second;
return true;
}
bool getId(const std::string &name, u16 &result) const{
std::map<std::string, u16>::const_iterator i;
i = m_name_to_id.find(name);
if(i == m_name_to_id.end())
return false;
result = i->second;
return true;
}
u16 size() const{
return m_id_to_name.size();
}
private:
std::map<u16, std::string> m_id_to_name;
std::map<std::string, u16> m_name_to_id;
};
#endif
|