MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / cover

Method cover

launcher/SeparatorPrefixTree.h:86–127  ·  view source on GitHub ↗

return the contained path that covers the path specified

Source from the content-addressed store, hash-verified

84
85 /// return the contained path that covers the path specified
86 QString cover(QString path) const
87 {
88 // if we found some valid node, it's good enough. the tree covers the path
89 if(m_contained)
90 {
91 return QString("");
92 }
93 auto sepIndex = path.indexOf(Tseparator);
94 if(sepIndex == -1)
95 {
96 auto found = children.find(path);
97 if(found == children.end())
98 {
99 return QString();
100 }
101 auto nested = (*found).cover(QString());
102 if(nested.isNull())
103 {
104 return nested;
105 }
106 if(nested.isEmpty())
107 return path;
108 return path + Tseparator + nested;
109 }
110 else
111 {
112 auto prefix = path.left(sepIndex);
113 auto found = children.find(prefix);
114 if(found == children.end())
115 {
116 return QString();
117 }
118 auto nested = (*found).cover(path.mid(sepIndex + 1));
119 if(nested.isNull())
120 {
121 return nested;
122 }
123 if(nested.isEmpty())
124 return prefix;
125 return prefix + Tseparator + nested;
126 }
127 }
128
129 /// Does the path-specified node exist in the tree? It does not have to be contained.
130 bool exists(QString path) const

Callers 2

dataMethod · 0.80
setFilterStateMethod · 0.80

Calls 4

QStringClass · 0.85
endMethod · 0.80
isEmptyMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected