30 #include <json/reader.h>
31 #include <json/writer.h>
44 std::ostringstream ret;
45 if (obj.isObject() && obj.isMember(
"tracker")) {
46 auto tracker = obj[
"tracker"].asString();
47 if (tracker.front() !=
'/') {
52 if (obj.isMember(
"sensor")) {
54 ret << obj[
"sensor"].asInt();
73 if (m_value.isString()) {
74 return m_value.asString();
76 Json::FastWriter writer;
77 std::string ret = writer.write(m_value);
79 while (ret.back() ==
'\n' || ret.back() ==
'\r') {
87 void ParsedAlias::m_parse(std::string
const &src) {
90 if (!reader.parse(src, val)) {
98 static const char CHILD_KEY[] =
"child";
99 static const char SOURCE_KEY[] =
"source";
100 void ParsedAlias::m_parse(Json::Value &val) {
101 if (val.isString()) {
106 if (val.isObject()) {
107 if (val.isMember(SOURCE_KEY)) {
109 m_parse(val[SOURCE_KEY]);
117 auto &leaf = m_leaf();
118 if (leaf.isString()) {
123 if (!trackerEquiv.empty()) {
129 "Couldn't handle transform leaf: " << leaf.toStyledString());
131 m_value = Json::nullValue;
134 Json::Value &ParsedAlias::m_leaf() {
135 Json::Value *current = &m_value;
136 while (current->isObject() && current->isMember(CHILD_KEY)) {
137 current = &(*current)[CHILD_KEY];
141 Json::Value
const &ParsedAlias::m_leaf()
const {
142 Json::Value
const *current = &m_value;
143 while (current->isObject() && current->isMember(CHILD_KEY)) {
144 current = &(*current)[CHILD_KEY];
bool isValid() const
Did the alias parse in a valid way?
ParsedAlias(std::string const &src)
Constructor - performs parse and normalization of format.
Json::Value getAliasValue() const
Gets a copy of the normalized version of the alias as a Json::Value.
std::string getPathFromOldRouteSource(Json::Value obj)
Helper, converts old-style tracker source into normal. For a little backward-compatibility.
std::string getLeaf() const
Get the ultimate source/leaf of the alias.
std::string getAlias() const
Get the normalized, cleaned, compacted version of the alias.
Internal, configured header file for verbosity macros.
void setLeaf(std::string const &leaf)
Set the leaf of the alias: should be an absolute path.
bool isSimple() const
Is this a simple (string-only, no transform) alias?