/src/CMake/Source/cmPropertyMap.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <string> |
8 | | #include <unordered_map> |
9 | | #include <utility> |
10 | | #include <vector> |
11 | | |
12 | | #include "cmValue.h" |
13 | | |
14 | | /** \class cmPropertyMap |
15 | | * \brief String property map. |
16 | | */ |
17 | | class cmPropertyMap |
18 | | { |
19 | | public: |
20 | | // -- General |
21 | | |
22 | | //! Clear property list |
23 | | void Clear(); |
24 | | |
25 | | // -- Properties |
26 | | |
27 | | //! Set the property value |
28 | | void SetProperty(std::string const& name, cmValue value); |
29 | | void SetProperty(std::string const& name, std::string const& value) |
30 | 4 | { |
31 | 4 | this->SetProperty(name, cmValue(value)); |
32 | 4 | } |
33 | | |
34 | | //! Append to the property value |
35 | | void AppendProperty(std::string const& name, std::string const& value, |
36 | | bool asString = false); |
37 | | |
38 | | //! Get the property value |
39 | | cmValue GetPropertyValue(std::string const& name) const; |
40 | | |
41 | | //! Remove the property @a name from the map |
42 | | void RemoveProperty(std::string const& name); |
43 | | |
44 | | // -- Lists |
45 | | |
46 | | //! Get a sorted list of property keys |
47 | | std::vector<std::string> GetKeys() const; |
48 | | |
49 | | //! Get a sorted by key list of property key,value pairs |
50 | | std::vector<std::pair<std::string, std::string>> GetList() const; |
51 | | |
52 | | private: |
53 | | std::unordered_map<std::string, std::string> Map_; |
54 | | }; |