MCPcopy Create free account
hub / github.com/Kitware/CMake / OutputLine

Method OutputLine

Source/cmRST.cxx:251–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251void cmRST::OutputLine(std::string const& line_in, bool inlineMarkup)
252{
253 if (this->OutputLinePending) {
254 this->OS << "\n";
255 this->OutputLinePending = false;
256 }
257 if (inlineMarkup) {
258 std::string line = this->ReplaceSubstitutions(line_in);
259 std::string::size_type pos = 0;
260 for (;;) {
261 std::string::size_type* first = nullptr;
262 std::string::size_type role_start = std::string::npos;
263 std::string::size_type link_start = std::string::npos;
264 std::string::size_type lit_start = std::string::npos;
265 if (this->CMakeRole.find(line.c_str() + pos)) {
266 role_start = this->CMakeRole.start();
267 first = &role_start;
268 }
269 if (this->InlineLiteral.find(line.c_str() + pos)) {
270 lit_start = this->InlineLiteral.start();
271 if (!first || lit_start < *first) {
272 first = &lit_start;
273 }
274 }
275 if (this->InlineLink.find(line.c_str() + pos)) {
276 link_start = this->InlineLink.start();
277 if (!first || link_start < *first) {
278 first = &link_start;
279 }
280 }
281 if (first == &role_start) {
282 this->OS << line.substr(pos, role_start);
283 std::string text = this->CMakeRole.match(3);
284 // If a command reference has no explicit target and
285 // no explicit "(...)" then add "()" to the text.
286 if (this->CMakeRole.match(2) == "command" &&
287 this->CMakeRole.match(5).empty() &&
288 text.find_first_of("()") == std::string::npos) {
289 text += "()";
290 }
291 this->OS << "``" << text << "``";
292 pos += this->CMakeRole.end();
293 } else if (first == &lit_start) {
294 this->OS << line.substr(pos, lit_start);
295 std::string text = this->InlineLiteral.match(1);
296 pos += this->InlineLiteral.end();
297 this->OS << "``" << text << "``";
298 } else if (first == &link_start) {
299 this->OS << line.substr(pos, link_start);
300 std::string text = this->InlineLink.match(1);
301 bool escaped = false;
302 for (char c : text) {
303 if (escaped) {
304 escaped = false;
305 this->OS << c;
306 } else if (c == '\\') {
307 escaped = true;
308 } else {

Callers 3

ProcessLineMethod · 0.95
NormalLineMethod · 0.95
OutputMarkupLinesMethod · 0.95

Calls 9

ReplaceSubstitutionsMethod · 0.95
c_strMethod · 0.80
find_first_ofMethod · 0.80
findMethod · 0.45
startMethod · 0.45
substrMethod · 0.45
matchMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected