zynq_7010/Properties.h

56 lines
1.4 KiB
C++

#ifndef PROPERTIES_H_
#define PROPERTIES_H_
#include <string>
#include <vector>
#include <map>
#include "PropertiesException.h"
#include "PropertyNotFoundException.h"
namespace cppproperties {
class Properties {
public:
Properties();
virtual ~Properties();
/**
* Gets the property value from a given key.
*
* This method throws a PropertyNotFoundException when a given key does not
* exist.
*/
std::string GetProperty(const std::string& key) const;
/**
* Gets the property value from a given key. Use a default value if not found.
*/
std::string GetProperty(const std::string& key, const std::string& defaultValue) const;
/**
* Gets the list of property names.
*/
std::vector<std::string> GetPropertyNames() const;
/**
* Adds a new property. If the property already exists, it'll overwrite
* the old one.
*/
void AddProperty(const std::string& key, const std::string& value);
/**
* Removes the property from a given key.
*
* If the property doesn't exist a PropertyNotFoundException will be thrown.
*/
void RemoveProperty(const std::string& key);
private:
// to preserve the order
std::vector<std::string> keys;
std::map<std::string, std::string> properties;
};
} /* namespace cppproperties */
#endif /* PROPERTIES_H_ */