Skip to content
Snippets Groups Projects
Commit b2efcabd authored by Dennis Gläser's avatar Dennis Gläser
Browse files

Merge branch 'feature/improve-properties-output' into 'master'

[properties] improve the output of the type/property tag tree

See merge request !1120
parents bec23910 a4779380
No related branches found
No related tags found
1 merge request!1120[properties] improve the output of the type/property tag tree
......@@ -994,6 +994,19 @@ const std::string getDiagnostic(std::string propTagName)
return result;
}
std::string::size_type findStartPosAndClutter_(const std::string& propertyValue, std::string& clutter)
{
clutter = "typename ::Dumux::Properties::GetProperty<TypeTag, ::Dumux::Properties::PTag::";
auto startPos = propertyValue.find(clutter);
if (startPos == std::string::npos)
{
clutter = clutter.substr(9);
startPos = propertyValue.find(clutter);
}
return startPos;
}
inline void print_(const std::string &typeTagName,
std::ostream &os,
const std::string &indent,
......@@ -1002,25 +1015,50 @@ inline void print_(const std::string &typeTagName,
if (indent == "")
os << indent << "Properties for " << canonicalTypeTagNameToName_(typeTagName) << ":";
else
os << indent << "Inherited from " << canonicalTypeTagNameToName_(typeTagName) << ":";
os << std::endl << indent << "Inherited from " << canonicalTypeTagNameToName_(typeTagName) << ":";
const PropertyRegistry::KeyList &keys =
PropertyRegistry::getKeys(typeTagName);
PropertyRegistry::KeyList::const_iterator it = keys.begin();
bool somethingPrinted = false;
std::string currentFile;
for (; it != keys.end(); ++it) {
const PropertyRegistryKey &key = it->second;
if (printedProperties.count(key.propertyName()) > 0)
continue; // property already printed
if (key.fileDefined() != currentFile)
{
currentFile = key.fileDefined();
os << std::endl << indent << "defined in " << currentFile << ":" << std::endl;
}
if (!somethingPrinted) {
os << "\n";
somethingPrinted = true;
}
os << indent << " "
<< key.propertyKind() << " " << key.propertyName();
if (key.propertyKind() != "opaque")
os << " = '" << key.propertyValue() << "'";
os << " defined at " << key.fileDefined()
<< ":" << key.lineDefined()
{
// remove unnecessary parts from the property value string
auto propertyValue = key.propertyValue();
std::string propertyClutter;
auto startPos = findStartPosAndClutter_(propertyValue, propertyClutter);
while (startPos != std::string::npos)
{
propertyValue.erase(startPos, propertyClutter.size());
startPos = propertyValue.find(">::p::type");
if (startPos != std::string::npos)
propertyValue.erase(startPos, 10);
startPos = propertyValue.find(">::p::value");
if (startPos != std::string::npos)
propertyValue.erase(startPos, 11);
startPos = findStartPosAndClutter_(propertyValue, propertyClutter);
}
os << " = '" << propertyValue << "'";
}
os << " at line " << key.lineDefined()
<< "\n";
printedProperties.insert(key.propertyName());
};
......@@ -1036,10 +1074,16 @@ inline void print_(const std::string &typeTagName,
}
}
template <class TypeTag>
class TypeTagAncestors;
//! \internal
template <class TypeTag>
void print(std::ostream &os = std::cout)
{
TypeTagAncestors<TypeTag>::addAncestors();
TypeTagAncestors<TypeTag>::print(os);
std::set<std::string> printedProps;
print_(Dune::className<TypeTag>(), os, "", printedProps);
......@@ -1112,6 +1156,8 @@ public:
{
const auto& a = ancestors();
os << "TypeTag tree:" << std::endl;
std::vector<size_t> colSizes;
for (size_t i = 0; i < a.size(); ++i)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment