Debian Codegraph @

include/ikeyvaluestore.h

raw
1 #pragma once
2
3 #include <string>
4 #include <functional>
5
6 /**
7 * Interface for an object supporting storage of string-valued
8 * properties which can be accessed by a key.
9 * The key is treated case-sensitively.
10 * It's not possible to store empty strings in the store.
11 */
12 class IKeyValueStore
13 {
14 public:
15 virtual ~IKeyValueStore() {}
16
17 /**
18 * Retrieves a property value from the store. This will return an empty string
19 * if the property doesn't exist.
20 */
21 virtual std::string getProperty(const std::string& key) const = 0;
22
23 /**
24 * Store a value in the map root's property store. DarkRadiant will persist
25 * these values in the Info file when saving and restore them on loading.
26 * Other map formats without info file are free to use that information
27 * when exporting map data.
28 * Setting a key to an empty string is equivalent to removing it from the store.
29 */
30 virtual void setProperty(const std::string& key, const std::string& value) = 0;
31
32 /**
33 * Removes a property from the value store, if it exists. This is equivalent
34 * to setting a property value to an empty string.
35 */
36 virtual void removeProperty(const std::string& key) = 0;
37
38 /**
39 * Iterates over the property store, hitting the visitor with each value pair.
40 */
41 virtual void foreachProperty(const std::function<void (const std::string&, const std::string&)>& visitor) const = 0;
42
43 /**
44 * Removes all properties from this store
45 */
46 virtual void clearProperties() = 0;
47 };
48