#include <pp/Format.h>
+#include <stdex/Memory.h>
+
#include <map>
#include <set>
namespace
{
+using OpName = std::string;
using ArgName = std::string;
using ArgValue = std::string;
using ArgDesc = std::pair<ArgName, ArgValue>;
};
public:
- NodeDesc(const std::string &name) : _name{name}
- {
- // DO NOTHING
- }
+ NodeDesc() = default;
+ NodeDesc(const OpName &opname) { this->opname(opname); }
public:
- const std::string &name(void) const { return _name; }
+ const OpName &name(void) const { return opname(); }
+
+ const OpName &opname(void) const;
+ void opname(const OpName &value);
uint32_t arg_size(void) const { return _args.size(); }
const ArgDesc &arg(uint32_t n) const { return _args.at(n); }
void state(const State &s) { _state = s; }
private:
- std::string _name;
+ std::unique_ptr<OpName> _name = nullptr;
std::vector<ArgDesc> _args;
State _state = State::Invalid;
};
+const std::string &NodeDesc::opname(void) const
+{
+ // _name SHOULD BE set before use
+ assert(_name != nullptr);
+ return *_name;
+}
+
+void NodeDesc::opname(const std::string &v) { _name = stdex::make_unique<std::string>(v); }
+
std::ostream &operator<<(std::ostream &os, const NodeDesc &d)
{
assert(d.state() != NodeDesc::State::Invalid);