MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / indentProject

Function indentProject

src/util.cpp:185–206  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Accept a list of projects, and return an indented list that reflects the hierarchy. Input - "one" "one.two" "one.two.three" "one.four" "two" Output - "one" " one.two" " one.two.three" " one.four" "two" There are two optional arguments, 'whitespace', and 'delimiter', - whitespace is the string used to build the pre

Source from the content-addressed store, hash-verified

183// - defaults to the period, '.'
184//
185const std::string indentProject(const std::string& project,
186 const std::string& whitespace /* = " " */,
187 char delimiter /* = '.' */) {
188 // Count the delimiters in *i.
189 std::string prefix = "";
190 std::string::size_type pos = 0;
191 std::string::size_type lastpos = 0;
192 while ((pos = project.find(delimiter, pos + 1)) != std::string::npos) {
193 if (pos != project.size() - 1) {
194 prefix += whitespace;
195 lastpos = pos;
196 }
197 }
198
199 std::string child = "";
200 if (lastpos == 0)
201 child = project;
202 else
203 child = project.substr(lastpos + 1);
204
205 return prefix + child;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209const std::vector<std::string> extractParents(const std::string& project,

Callers 5

TEST_NAMEFunction · 0.85
executeMethod · 0.85
executeMethod · 0.85
measureMethod · 0.85
renderMethod · 0.85

Calls 1

findMethod · 0.80

Tested by 1

TEST_NAMEFunction · 0.68