SC2API
An API for AI for StarCraft II
sc2_property_reader.h
1 #pragma once
2 
3 #include <string>
4 #include <unordered_map>
5 #include <functional>
6 
7 namespace sc2 {
8 
10 {
11 public:
12  typedef std::unordered_map<std::string, std::string>::const_iterator ConstMapIterator;
13  typedef std::unordered_map<std::string, std::string> PropertiesMap;
14 
16  PropertyReader(const std::string& file_name);
17  ~PropertyReader();
18 
19  bool IsLoaded() const;
20  bool LoadFile(const std::string& file_name);
21  void Free();
22 
23  // Return false if no properties loaded or value does not exist in file
24  bool Read(const std::string& key, std::function<void(const std::string& v)> convert);
25  bool ReadInt(const std::string& key, int& value);
26  bool ReadFloat(const std::string& key, float& value);
27  bool ReadString(const std::string& key, std::string& value);
28 
29 private:
30  PropertiesMap properties_;
31  bool file_read_;
32 };
33 
34 }
Definition: sc2_action.h:9
Definition: sc2_property_reader.h:9