10 #include "hal_version.h"
25 mGuiLoaded = (plugins.find(std::string(
"hal_gui")) != plugins.end());
30 if (netlist ==
nullptr)
32 return ERR(
"could not write netlist to GEXF file '" + file_path.string() +
"': netlist is a 'nullptr'");
36 if (file_path.empty())
38 return ERR(
"could not write netlist to GEXF file '" + file_path.string() +
"': file path is empty");
53 return ERR(
"could not write netlist to GEXF file '" + file_path.string() +
"': failed to open file");
61 xmlOut.
writeNamespace(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi");
62 xmlOut.
writeAttribute(
"http://www.w3.org/2001/XMLSchema-instance",
"schemaLocation",
"http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd");
75 xmlOut.
writeTextElement(
"creator",
QString(
"hal %1.%2.%3").arg(hal_version::major).arg(hal_version::minor).arg(hal_version::patch));
88 writeAttribute(xmlOut, 3,
"label",
"string");
89 writeAttribute(xmlOut, 4,
"hal_id",
"long");
90 writeAttribute(xmlOut, 5,
"source_pin",
"string");
91 writeAttribute(xmlOut, 6,
"destination_pin",
"string");
92 writeAttribute(xmlOut, 7,
"networkx_key",
"long");
98 writeAttribute(xmlOut, 0,
"type",
"string");
99 writeAttribute(xmlOut, 1,
"module",
"string");
100 writeAttribute(xmlOut, 2,
"INIT",
"string");
105 for (
const Gate* g : mNetlist->
get_gates())
106 writeNode(xmlOut, g);
110 for (
const Net* n : mNetlist->
get_nets())
111 writeEdge(xmlOut, n);
129 writeColor(xmlOut, g);
131 writeNodeAttribute(xmlOut, g, 0);
132 writeNodeAttribute(xmlOut, g, 1);
133 writeNodeAttribute(xmlOut, g, 2);
157 void GexfWriter::writeNodeAttribute(
QXmlStreamWriter& xmlOut,
const Gate* g,
int inx)
const
169 for (
const auto& [key, val] : g->get_data_map())
172 if (keyTxt ==
"INIT")
192 for (
const Endpoint* epSrc : n->get_sources())
194 Gate* gSrc = epSrc->get_gate();
198 for (
const Endpoint* epDst : n->get_destinations())
200 Gate* gDst = epDst->get_gate();
209 writeEdgeAttribute(xmlOut, n, 3);
210 writeEdgeAttribute(xmlOut, n, 4);
211 writeEdgeAttribute(xmlOut, n, 5, epSrc->get_pin()->get_name());
212 writeEdgeAttribute(xmlOut, n, 6, epDst->get_pin()->get_name());
213 writeEdgeAttribute(xmlOut, n, 7);
220 void GexfWriter::writeEdgeAttribute(
QXmlStreamWriter& xmlOut,
const Net* n,
int inx,
const std::string pin)
const
Result< std::monostate > write(Netlist *netlist, const std::filesystem::path &file_path) override
const std::vector< Gate * > & get_gates() const
const std::vector< Net * > & get_nets() const
QColor getModuleColor(const u32 id)
std::set< std::string > get_plugin_names()
NetlistRelay * gNetlistRelay
bool isValid() const const
virtual bool open(QIODevice::OpenMode mode) override
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString fromStdString(const std::string &str)
bool isEmpty() const const
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
QString number(int n, int base)
QString & remove(int position, int n)
void writeAttribute(const QString &qualifiedName, const QString &value)
void writeNamespace(const QString &namespaceUri, const QString &prefix)
void writeStartDocument()
void writeStartElement(const QString &qualifiedName)
void writeTextElement(const QString &qualifiedName, const QString &text)