|
degate 0.1.1
|
Helper class to handle attributes for the dot language. More...
#include <DOTAttributes.h>
Public Member Functions | |
| DOTAttributes () | |
| The constructor. | |
| ~DOTAttributes () | |
| The destructor, that destroys a DOTAttributes object. | |
| void | add (std::string const &attribute_name, std::string const &value) |
| Add a key/value attribute. | |
| template<typename T > | |
| void | add_number (std::string const &attribute_name, T value) |
| Add a key/value attribute. | |
| void | add_position (long center_x, long center_y, bool preserve_position=true) |
| Add a position attertribute. | |
| std::string | get_string () const |
| Get the attributes as a string. | |
Private Attributes | |
| std::map< std::string, std::string > | attributes |
Helper class to handle attributes for the dot language.
Definition at line 40 of file DOTAttributes.h.
| degate::DOTAttributes::DOTAttributes | ( | ) | [inline] |
| degate::DOTAttributes::~DOTAttributes | ( | ) | [inline] |
The destructor, that destroys a DOTAttributes object.
Definition at line 55 of file DOTAttributes.h.
{};
| void DOTAttributes::add | ( | std::string const & | attribute_name, |
| std::string const & | value | ||
| ) |
Add a key/value attribute.
If this method is called multiple times with the same attribute name, the last value is accepted.
The value string should not contain quotation marks. If it has one, you should handle the escaping by yourself.
| attribute_name | The attribute name as a string. |
| value | The string value. You don't have to add opening and closing quotation marks. |
Definition at line 26 of file DOTAttributes.cc.
References attributes.
Referenced by degate::LogicModelDOTExporter::add_connection(), degate::LogicModelDOTExporter::add_gate(), degate::LogicModelDOTExporter::add_implicit_net(), degate::LogicModelDOTExporter::add_net(), and degate::LogicModelDOTExporter::add_via().
{
std::ostringstream stm;
stm << attribute_name << "=\"" << value << "\"";
attributes[attribute_name] = stm.str();
}

| void degate::DOTAttributes::add_number | ( | std::string const & | attribute_name, |
| T | value | ||
| ) | [inline] |
Add a key/value attribute.
If this method is called multiple times with the same attribute name, the last value is accepted.
| attribute_name | The attribute name as a string. |
| value | The parameter value. |
Definition at line 83 of file DOTAttributes.h.
References attributes.
Referenced by degate::LogicModelDOTExporter::add_via().
{
std::ostringstream stm;
stm << attribute_name << "=\"" << value << "\"";
attributes[attribute_name] = stm.str();
}

| void DOTAttributes::add_position | ( | long | center_x, |
| long | center_y, | ||
| bool | preserve_position = true |
||
| ) |
Add a position attertribute.
If this method is called multiple times with the same attribute name, the last value is accepted.
| center_x | The x-coordinate for the center. Value and unit are the one from the dot coordinate system. |
| center_y | The y-coordinate for the center. Value and unit are the one from the dot coordinate system. |
| preserve_position | A boolean value that indicates if positions should be preserved. In the dot language this is expressed with a '!' flag. |
Definition at line 35 of file DOTAttributes.cc.
References attributes.
{
std::ostringstream stm;
stm << "pos" << "=\"" << center_x << "," << center_y;
if(preserve_position) stm << "!";
stm << "\"";
attributes["pos"] = stm.str();
}
| std::string DOTAttributes::get_string | ( | ) | const |
Get the attributes as a string.
Definition at line 45 of file DOTAttributes.cc.
References attributes.
Referenced by degate::LogicModelDOTExporter::add_connection(), degate::LogicModelDOTExporter::add_implicit_net(), degate::LogicModelDOTExporter::add_net(), and degate::LogicModelDOTExporter::add_via().
{
std::string result;
for(std::map<std::string, std::string>::const_iterator iter = attributes.begin();
iter != attributes.end(); ++iter) {
if(result.size() > 0) result += ",";
result += (*iter).second;
}
return std::string("[") + result + std::string("];");
}

std::map<std::string, std::string> degate::DOTAttributes::attributes [private] |
Definition at line 43 of file DOTAttributes.h.
Referenced by add(), add_number(), add_position(), and get_string().
1.7.4