16#ifndef SIMICS_SYSTEMC_INJECTION_ATTR_DICT_PARSER_H
17#define SIMICS_SYSTEMC_INJECTION_ATTR_DICT_PARSER_H
20#include <simics/base/attr-value.h>
21#include <simics/base/log.h>
34#define ATTR_DICT_PARSER_NAMESPACE(ns) \
35virtual std::string prefix() { \
47 attr_value_t *attr) = 0;
56 std::map<std::string, attr_value_t>::iterator entry;
57 entry = key_to_attr_.find(key);
58 if (entry == key_to_attr_.end()) {
59 SIM_LOG_ERROR(obj_, 0,
"Attribute key %s not found", key.c_str());
63 return value(v, key, entry->second);
67 return value(v, entry_->first, entry_->second);
69 template<
typename T,
typename A>
70 bool value(std::vector<T, A> *v, std::string key, attr_value_t
value) {
71 if (!SIM_attr_is_list(
value)) {
72 SIM_LOG_ERROR(obj_, 0,
"%s must be list",
78 for (
unsigned int i = 0; i < SIM_attr_list_size(
value); ++i) {
80 if (this->
value(&t, key, SIM_attr_list_item(
value, i)))
88 bool value(uint64_t *v, std::string key, attr_value_t
value);
89 bool value(uint32_t *v, std::string key, attr_value_t
value);
90 bool value(uint16_t *v, std::string key, attr_value_t
value);
91 bool value(uint8_t *v, std::string key, attr_value_t
value);
92 bool value(int64_t *v, std::string key, attr_value_t
value);
93 bool value(int32_t *v, std::string key, attr_value_t
value);
94 bool value(int16_t *v, std::string key, attr_value_t
value);
95 bool value(int8_t *v, std::string key, attr_value_t
value);
96 bool value(
bool *v, std::string key, attr_value_t
value);
97 bool value(attr_value_t *v, std::string key, attr_value_t
value);
98 bool value(
const char **v, std::string key, attr_value_t
value);
99 bool value(
const unsigned char **v, std::string key, attr_value_t
value);
106 std::set<std::string> parsed_keys_;
107 std::map<std::string, attr_value_t> key_to_attr_;
108 std::map<std::string, attr_value_t>::iterator entry_;
109 static std::string error_msg_;
Definition: attr_dict_parser.h:42
virtual std::string prefix()=0
virtual ~ParserInterface()
Definition: attr_dict_parser.h:44
virtual bool parse(AttrDictParser *parser, const std::string &key, attr_value_t *attr)=0
Definition: attr_dict_parser.h:40
bool value(uint16_t *v, std::string key, attr_value_t value)
bool value(int8_t *v, std::string key, attr_value_t value)
bool value(int16_t *v, std::string key, attr_value_t value)
void reportError(const char *str,...)
bool value(int64_t *v, std::string key, attr_value_t value)
bool value(uint64_t *v, std::string key, attr_value_t value)
bool value(T *v)
Definition: attr_dict_parser.h:66
AttrDictParser(conf_object_t *obj, const attr_value_t *attr)
bool parse(ParserInterface *parser)
bool value(std::vector< T, A > *v, std::string key, attr_value_t value)
Definition: attr_dict_parser.h:70
bool value(const char **v, std::string key, attr_value_t value)
bool value(int32_t *v, std::string key, attr_value_t value)
AttrDictParser init(const attr_value_t *attr)
bool value(const unsigned char **v, std::string key, attr_value_t value)
bool value(attr_value_t *v, std::string key, attr_value_t value)
bool value(uint32_t *v, std::string key, attr_value_t value)
bool value(uint8_t *v, std::string key, attr_value_t value)
bool value(bool *v, std::string key, attr_value_t value)
bool reportInvalidAttrs()
bool lookUp(std::string key, T *v)
Definition: attr_dict_parser.h:55
AttrDictParser(conf_object_t *obj)
Definition: pci_bus_interface.h:24