| 15 | namespace gte |
| 16 | { |
| 17 | class ProgramDefines |
| 18 | { |
| 19 | public: |
| 20 | // Construction. |
| 21 | ProgramDefines() = default; |
| 22 | |
| 23 | // Set a definition. Each is stored as a std::pair of std::string. |
| 24 | // The first element of the pair is the 'name' and the second element |
| 25 | // of the pair is the string representation of 'value'. |
| 26 | template <typename T> |
| 27 | inline void Set(std::string const& name, T value) |
| 28 | { |
| 29 | Update(name, std::to_string(value)); |
| 30 | } |
| 31 | |
| 32 | inline void Set(char const* name, std::string const& value) |
| 33 | { |
| 34 | Update(name, std::string(value)); |
| 35 | } |
| 36 | |
| 37 | inline void Set(char const* name, char const* value) |
| 38 | { |
| 39 | Update(std::string(name), std::string(value)); |
| 40 | } |
| 41 | |
| 42 | inline std::vector<std::pair<std::string, std::string>> const& Get() const |
| 43 | { |
| 44 | return mDefinitions; |
| 45 | } |
| 46 | |
| 47 | // Remove definitions, which allows the ProgramDefines object to be |
| 48 | // shared in a scope. |
| 49 | void Remove(std::string const& name); |
| 50 | void Clear(); |
| 51 | |
| 52 | private: |
| 53 | void Update(std::string const& name, std::string const& value); |
| 54 | |
| 55 | std::vector<std::pair<std::string, std::string>> mDefinitions; |
| 56 | }; |
| 57 | |
| 58 | // Specialization of Set(std::string const&, T value) for |
| 59 | // T = char const*. |
no outgoing calls
no test coverage detected