Upload UI
[lsnes.git] / src / library / emustatus.cpp
blob53ec72657337da8f2d03eaf8bc4de1b659f48013
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] = to_u32string(value);
17 void emulator_status::set(const std::string& key, const std::u32string& value) throw(std::bad_alloc)
19 umutex_class h(lock);
20 content[key] = value;
23 bool emulator_status::haskey(const std::string& key) throw()
25 umutex_class h(lock);
26 return (content.count(key) != 0);
29 void emulator_status::erase(const std::string& key) throw()
31 umutex_class h(lock);
32 content.erase(key);
35 std::u32string emulator_status::get(const std::string& key) throw(std::bad_alloc)
37 umutex_class h(lock);
38 return content[key];
41 emulator_status::iterator emulator_status::first() throw(std::bad_alloc)
43 iterator i;
44 i.not_valid = true;
45 return i;
48 bool emulator_status::next(iterator& itr) throw(std::bad_alloc)
50 umutex_class h(lock);
51 std::map<std::string, std::u32string>::iterator j;
52 if(itr.not_valid)
53 j = content.lower_bound("");
54 else
55 j = content.upper_bound(itr.key);
56 if(j == content.end()) {
57 itr.not_valid = true;
58 itr.key = "";
59 itr.value = U"";
60 return false;
61 } else {
62 itr.not_valid = false;
63 itr.key = j->first;
64 itr.value = j->second;
65 return true;