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