Merge branch 'rr1-maint'
[lsnes.git] / src / library / emustatus.cpp
blob4ec53a4715f5d43ec1da141b11b042ff7a5dd608
1 #include "emustatus.hpp"
3 emulator_status::emulator_status() throw(std::bad_alloc)
7 emulator_status::~emulator_status() throw()
11 void emulator_status::set(const std::string& key, const std::string& value) throw(std::bad_alloc)
13 umutex_class h(lock);
14 content[key] = value;
17 bool emulator_status::haskey(const std::string& key) throw()
19 umutex_class h(lock);
20 return (content.count(key) != 0);
23 void emulator_status::erase(const std::string& key) throw()
25 umutex_class h(lock);
26 content.erase(key);
29 std::string emulator_status::get(const std::string& key) throw(std::bad_alloc)
31 umutex_class h(lock);
32 return content[key];
35 emulator_status::iterator emulator_status::first() throw(std::bad_alloc)
37 iterator i;
38 i.not_valid = true;
39 return i;
42 bool emulator_status::next(iterator& itr) throw(std::bad_alloc)
44 umutex_class h(lock);
45 std::map<std::string, std::string>::iterator j;
46 if(itr.not_valid)
47 j = content.lower_bound("");
48 else
49 j = content.upper_bound(itr.key);
50 if(j == content.end()) {
51 itr.not_valid = true;
52 itr.key = "";
53 itr.value = "";
54 return false;
55 } else {
56 itr.not_valid = false;
57 itr.key = j->first;
58 itr.value = j->second;
59 return true;