1
0
Fork 0

Added a function in the attribute parser to transform an expanded attribute to the correct path for pid.

This commit is contained in:
Michael Hackstein 2015-08-11 09:05:03 +02:00
parent 453aa78633
commit 2c0bdb5861
2 changed files with 48 additions and 1 deletions

View File

@ -30,6 +30,8 @@
#include "AttributeNameParser.h"
#include "Exceptions.h"
using AttributeName = triagens::basics::AttributeName;
void triagens::basics::TRI_ParseAttributeString (
std::string const& input,
std::vector<AttributeName>& result
@ -80,5 +82,31 @@ void triagens::basics::TRI_AttributeNamesToString (
}
}
void triagens::basics::TRI_AttributeNamesToPidString (
std::vector<AttributeName> const& input,
std::string& result
) {
TRI_ASSERT(result.size() == 0);
bool isFirst = true;
for (auto& it : input) {
if (! isFirst) {
result += ".";
}
isFirst = false;
result += it.name;
if (it.shouldExpand) {
break;
}
}
}
bool triagens::basics::TRI_AttributeNamesHaveExpansion (
std::vector<AttributeName> const& input
) {
for (auto& it : input) {
if (it.shouldExpand) {
return true;
}
}
return false;
}

View File

@ -90,6 +90,25 @@ namespace triagens {
bool excludeExpansion = false
);
////////////////////////////////////////////////////////////////////////////////
/// @brief Transform a vector of AttributeNames into a pid string.
/// Stops at first expansion
////////////////////////////////////////////////////////////////////////////////
void TRI_AttributeNamesToPidString (
std::vector<AttributeName> const& input,
std::string& result
);
////////////////////////////////////////////////////////////////////////////////
/// @brief Tests if this AttributeName uses an expansion operator
////////////////////////////////////////////////////////////////////////////////
bool TRI_AttributeNamesHaveExpansion (
std::vector<AttributeName> const& input
);
}
}