Adding optional to differentiate between empty sets and unset attributes

Signed-off-by: Ethan Mahintorabi <[email protected]>
This commit is contained in:
Ethan Mahintorabi
2024-03-10 01:56:33 +00:00
parent 36c1bade14
commit 8aef4d549e
8 changed files with 48 additions and 23 deletions
+5 -2
View File
@@ -275,10 +275,13 @@ ConcreteCell::setAttribute(const std::string &key,
attribute_map_.insert(key, value);
}
std::string
std::optional<std::string>
ConcreteCell::getAttribute(const std::string &key) const
{
return attribute_map_.findKey(key);
if (attribute_map_.hasKey(key)) {
return attribute_map_.findKey(key);
}
return {};
}
ConcretePort *
+7 -4
View File
@@ -606,7 +606,7 @@ ConcreteNetwork::filename(const Cell *cell)
return ccell->filename();
}
std::string
std::optional<std::string>
ConcreteNetwork::getAttribute(const Cell *cell,
const std::string &key) const
{
@@ -938,7 +938,7 @@ ConcreteNetwork::id(const Instance *instance) const
return inst->id();
}
std::string
std::optional<std::string>
ConcreteNetwork::getAttribute(const Instance *inst,
const std::string &key) const
{
@@ -1689,10 +1689,13 @@ ConcreteInstance::setAttribute(const std::string &key,
attribute_map_.insert(key, value);
}
std::string
std::optional<std::string>
ConcreteInstance::getAttribute(const std::string &key) const
{
return attribute_map_.findKey(key);
if (attribute_map_.hasKey(key)) {
return attribute_map_.findKey(key);
}
return {};
}
void
+2 -2
View File
@@ -122,7 +122,7 @@ NetworkNameAdapter::id(const Cell *cell) const
return network_->id(cell);
}
std::string
std::optional<std::string>
NetworkNameAdapter::getAttribute(const Cell *cell,
const std::string &key) const
{
@@ -334,7 +334,7 @@ NetworkNameAdapter::cell(const Instance *instance) const
return network_->cell(instance);
}
std::string
std::optional<std::string>
NetworkNameAdapter::getAttribute(const Instance *inst,
const std::string &key) const
{