cmake/Source/cmPropertyMap.h

56 lines
1.4 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
#include <string>
2020-02-01 23:06:01 +01:00
#include <unordered_map>
#include <utility>
2016-10-30 18:24:19 +01:00
#include <vector>
2021-11-20 13:41:27 +01:00
#include "cmValue.h"
2020-08-30 11:54:41 +02:00
2020-02-01 23:06:01 +01:00
/** \class cmPropertyMap
* \brief String property map.
*/
class cmPropertyMap
{
public:
2020-02-01 23:06:01 +01:00
// -- General
//! Clear property list
void Clear();
2020-02-01 23:06:01 +01:00
// -- Properties
2016-10-30 18:24:19 +01:00
2020-02-01 23:06:01 +01:00
//! Set the property value
2016-07-09 11:21:54 +02:00
void SetProperty(const std::string& name, const char* value);
2021-11-20 13:41:27 +01:00
void SetProperty(const std::string& name, cmValue value);
void SetProperty(const std::string& name, const std::string& value)
{
this->SetProperty(name, cmValue(value));
}
2020-02-01 23:06:01 +01:00
//! Append to the property value
2020-08-30 11:54:41 +02:00
void AppendProperty(const std::string& name, const std::string& value,
2016-07-09 11:21:54 +02:00
bool asString = false);
2020-02-01 23:06:01 +01:00
//! Get the property value
2021-11-20 13:41:27 +01:00
cmValue GetPropertyValue(const std::string& name) const;
2020-02-01 23:06:01 +01:00
//! Remove the property @a name from the map
void RemoveProperty(const std::string& name);
// -- Lists
//! Get a sorted list of property keys
std::vector<std::string> GetKeys() const;
//! Get a sorted by key list of property key,value pairs
std::vector<std::pair<std::string, std::string>> GetList() const;
private:
std::unordered_map<std::string, std::string> Map_;
};