Skip to main content

The OutputCodeRecorder Class Reference

Implementation that allows capturing calls made to the code interface to later invoke them on a OutputCodeList via replay(). More...

Declaration

class OutputCodeRecorder { ... }

Included Headers

#include <src/outputlist.h>

Base class

classOutputCodeIntf

Base class for code generators. More...

Public Member Functions Index

OutputTypetype () const override
voidcodify (const QCString &s) override
voidstripCodeComments (bool) override
voidstartSpecialComment () override
voidendSpecialComment () override
voidsetStripIndentAmount (size_t) override
std::unique_ptr< OutputCodeIntf >clone () override
voidwriteCodeLink (CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip) override
voidwriteLineNumber (const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor) override
voidwriteTooltip (const QCString &id, const DocLinkInfo &docInfo, const QCString &decl, const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo) override
voidstartCodeLine (int) override
voidendCodeLine () override
voidstartFontClass (const QCString &c) override
voidendFontClass () override
voidwriteCodeAnchor (const QCString &name) override
voidstartCodeFragment (const QCString &style) override
voidendCodeFragment (const QCString &style) override
voidstartFold (int lineNr, const QCString &startMarker, const QCString &endMarker) override
voidendFold () override
voidreplay (OutputCodeList &ol, int startLine, int endLine, bool showLineNumbers, bool stripComment, size_t stripIndentAmount)

Private Member Functions Index

voidstartNewLine (int lineNr)

Private Member Attributes Index

std::vector< CallInfo >m_calls
std::vector< size_t >m_lineOffset
boolm_showLineNumbers = false
boolm_insideSpecialComment = false

Description

Implementation that allows capturing calls made to the code interface to later invoke them on a OutputCodeList via replay().

Definition at line 111 of file outputlist.h.

Public Member Functions

clone()

std::unique_ptr< OutputCodeIntf > OutputCodeRecorder::clone ()
inline virtual

Definition at line 120 of file outputlist.h.

120 std::unique_ptr<OutputCodeIntf> clone() override { return std::make_unique<OutputCodeRecorder>(*this); }

codify()

void OutputCodeRecorder::codify (const QCString & s)
virtual

Declaration at line 115 of file outputlist.h, definition at line 231 of file outputlist.cpp.

232{
233 m_calls.emplace_back([]() { return true; },
234 [=](OutputCodeList *ol) { ol->codify(s); },
236 );
237}

References m_calls and m_insideSpecialComment.

endCodeFragment()

void OutputCodeRecorder::endCodeFragment (const QCString & style)
virtual

Declaration at line 135 of file outputlist.h, definition at line 332 of file outputlist.cpp.

333{
334}

endCodeLine()

void OutputCodeRecorder::endCodeLine ()
virtual

Declaration at line 130 of file outputlist.h, definition at line 296 of file outputlist.cpp.

297{
298 m_calls.emplace_back([](){ return true; },
299 [=](OutputCodeList *ol) { ol->endCodeLine(); },
301 );
302}

References m_calls and m_insideSpecialComment.

endFold()

void OutputCodeRecorder::endFold ()
virtual

Declaration at line 137 of file outputlist.h, definition at line 344 of file outputlist.cpp.

345{
346 m_calls.emplace_back([]() { return true; },
347 [=](OutputCodeList *ol) { ol->endFold(); },
349 );
350}

References m_calls and m_insideSpecialComment.

endFontClass()

void OutputCodeRecorder::endFontClass ()
virtual

Declaration at line 132 of file outputlist.h, definition at line 312 of file outputlist.cpp.

313{
314 m_calls.emplace_back([]() { return true; },
315 [=](OutputCodeList *ol){ ol->endFontClass(); },
317 );
318}

References m_calls and m_insideSpecialComment.

endSpecialComment()

void OutputCodeRecorder::endSpecialComment ()
virtual

Declaration at line 118 of file outputlist.h, definition at line 248 of file outputlist.cpp.

249{
250 m_calls.emplace_back([]() { return true; },
251 [=](OutputCodeList *ol) { ol->endSpecialComment(); },
252 true
253 );
255}

References m_calls and m_insideSpecialComment.

replay()

void OutputCodeRecorder::replay (OutputCodeList & ol, int startLine, int endLine, bool showLineNumbers, bool stripComment, size_t stripIndentAmount)

Declaration at line 139 of file outputlist.h, definition at line 352 of file outputlist.cpp.

352void OutputCodeRecorder::replay(OutputCodeList &ol,int startLine,int endLine,bool showLineNumbers,bool
353 stripCodeComments,size_t stripIndentAmount)
354{
355 size_t startIndex = startLine>0 && startLine<=(int)m_lineOffset.size() ? m_lineOffset[startLine-1] : 0;
356 size_t endIndex = endLine>0 && endLine <=(int)m_lineOffset.size() ? m_lineOffset[ endLine-1] : m_calls.size();
357 //printf("startIndex=%zu endIndex=%zu\n",startIndex,endIndex);
358
359 // configure run time properties of the rendering
361 ol.setStripIndentAmount(stripIndentAmount);
362 m_showLineNumbers = showLineNumbers;
363
364 bool insideSpecialComment = false;
365 // in case the start of the special comment marker is outside of the fragment, start it here
366 if (startIndex<endIndex && m_calls[startIndex].insideSpecialComment)
367 {
369 insideSpecialComment = true;
370 }
371
372 // render the requested fragment of the pre-recorded output
373 for (size_t i=startIndex; i<endIndex; i++)
374 {
375 if (m_calls[i].condition())
376 {
377 insideSpecialComment = m_calls[i].insideSpecialComment;
378 m_calls[i].function(&ol);
379 }
380 }
381
382 // if we end the fragment inside a special comment, make sure we end it,
383 // and also the code line
384 if (insideSpecialComment)
385 {
387 ol.endCodeLine();
388 }
389
390 ol.stripCodeComments(false);
392}

References OutputCodeList::endCodeLine, OutputCodeList::endSpecialComment, m_calls, m_lineOffset, m_showLineNumbers, OutputCodeList::setStripIndentAmount, OutputCodeList::startSpecialComment, OutputCodeList::stripCodeComments and stripCodeComments.

Referenced by CodeFragmentManager::parseCodeFragment.

setStripIndentAmount()

void OutputCodeRecorder::setStripIndentAmount (size_t)
inline virtual

Definition at line 119 of file outputlist.h.

119 void setStripIndentAmount(size_t) override {}

startCodeFragment()

void OutputCodeRecorder::startCodeFragment (const QCString & style)
virtual

Declaration at line 134 of file outputlist.h, definition at line 328 of file outputlist.cpp.

329{
330}

startCodeLine()

void OutputCodeRecorder::startCodeLine (int lineNr)
virtual

Declaration at line 129 of file outputlist.h, definition at line 287 of file outputlist.cpp.

288{
289 startNewLine(lineNr);
290 m_calls.emplace_back([](){ return true; },
291 [=](OutputCodeList *ol) { ol->startCodeLine(lineNr); },
293 );
294}

References m_calls, m_insideSpecialComment and startNewLine.

startFold()

void OutputCodeRecorder::startFold (int lineNr, const QCString & startMarker, const QCString & endMarker)
virtual

Declaration at line 136 of file outputlist.h, definition at line 336 of file outputlist.cpp.

336void OutputCodeRecorder::startFold(int lineNr,const QCString &startMarker,const QCString &endMarker)
337{
338 m_calls.emplace_back([]() { return true; },
339 [=](OutputCodeList *ol) { ol->startFold(lineNr,startMarker,endMarker); },
341 );
342}

References m_calls and m_insideSpecialComment.

startFontClass()

void OutputCodeRecorder::startFontClass (const QCString & c)
virtual

Declaration at line 131 of file outputlist.h, definition at line 304 of file outputlist.cpp.

305{
306 m_calls.emplace_back([]() { return true; },
307 [=](OutputCodeList *ol) { ol->startFontClass(c); },
309 );
310}

References m_calls and m_insideSpecialComment.

startSpecialComment()

void OutputCodeRecorder::startSpecialComment ()
virtual

Declaration at line 117 of file outputlist.h, definition at line 239 of file outputlist.cpp.

240{
242 m_calls.emplace_back([]() { return true; },
243 [=](OutputCodeList *ol) { ol->startSpecialComment(); },
244 true
245 );
246}

References m_calls and m_insideSpecialComment.

stripCodeComments()

void OutputCodeRecorder::stripCodeComments (bool)
inline virtual

Definition at line 116 of file outputlist.h.

116 void stripCodeComments(bool) override {}

Referenced by replay.

type()

OutputType OutputCodeRecorder::type ()
inline virtual

Definition at line 114 of file outputlist.h.

114 OutputType type() const override { return OutputType::Recorder; }

Reference Recorder.

Referenced by writeCodeLink.

writeCodeAnchor()

void OutputCodeRecorder::writeCodeAnchor (const QCString & name)
virtual

Declaration at line 133 of file outputlist.h, definition at line 320 of file outputlist.cpp.

321{
322 m_calls.emplace_back([]() { return true; },
323 [=](OutputCodeList *ol){ ol->writeCodeAnchor(name); },
325 );
326}

References m_calls and m_insideSpecialComment.

writeCodeLink()

void OutputCodeRecorder::writeCodeLink (CodeSymbolType type, const QCString & ref, const QCString & file, const QCString & anchor, const QCString & name, const QCString & tooltip)
virtual

Declaration at line 121 of file outputlist.h, definition at line 257 of file outputlist.cpp.

258 const QCString &ref,const QCString &file,
259 const QCString &anchor,const QCString &name,
260 const QCString &tooltip)
261{
262 m_calls.emplace_back([](){ return true; },
263 [=](OutputCodeList *ol) { ol->writeCodeLink(type,ref,file,anchor,name,tooltip); },
265 );
266}

References m_calls, m_insideSpecialComment and type.

writeLineNumber()

void OutputCodeRecorder::writeLineNumber (const QCString & ref, const QCString & file, const QCString & anchor, int lineNumber, bool writeLineAnchor)
virtual

Declaration at line 125 of file outputlist.h, definition at line 268 of file outputlist.cpp.

268void OutputCodeRecorder::writeLineNumber(const QCString &ref,const QCString &file,const QCString &anchor,
269 int lineNumber, bool writeLineAnchor)
270{
271 startNewLine(lineNumber);
272 m_calls.emplace_back([&]() { return m_showLineNumbers; },
273 [=](OutputCodeList *ol) { ol->writeLineNumber(ref,file,anchor,lineNumber,writeLineAnchor); },
275 );
276}

References m_calls, m_insideSpecialComment, m_showLineNumbers and startNewLine.

writeTooltip()

void OutputCodeRecorder::writeTooltip (const QCString & id, const DocLinkInfo & docInfo, const QCString & decl, const QCString & desc, const SourceLinkInfo & defInfo, const SourceLinkInfo & declInfo)
virtual

Declaration at line 127 of file outputlist.h, definition at line 278 of file outputlist.cpp.

278void OutputCodeRecorder::writeTooltip(const QCString &id, const DocLinkInfo &docInfo, const QCString &decl,
279 const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo)
280{
281 m_calls.emplace_back([](){ return true; },
282 [=](OutputCodeList *ol) { ol->writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); },
284 );
285}

References m_calls and m_insideSpecialComment.

Private Member Functions

startNewLine()

void OutputCodeRecorder::startNewLine (int lineNr)

Declaration at line 141 of file outputlist.h, definition at line 217 of file outputlist.cpp.

218{
219 int orgSize = static_cast<int>(m_lineOffset.size());
220 if (orgSize<lineNr)
221 {
222 m_lineOffset.resize(lineNr);
223 for (int i=orgSize;i<lineNr;i++) // output lines can be skipped due to hidden comments so fill in the gap
224 {
225 //printf("%p: startCodeLine(%d) offset=%zu\n",(void*)this,i,m_calls.size());
226 m_lineOffset[i]=m_calls.size();
227 }
228 }
229}

References m_calls and m_lineOffset.

Referenced by startCodeLine and writeLineNumber.

Private Member Attributes

m_calls

std::vector<CallInfo> OutputCodeRecorder::m_calls

m_insideSpecialComment

bool OutputCodeRecorder::m_insideSpecialComment = false

m_lineOffset

std::vector<size_t> OutputCodeRecorder::m_lineOffset

Definition at line 153 of file outputlist.h.

153 std::vector<size_t> m_lineOffset;

Referenced by replay and startNewLine.

m_showLineNumbers

bool OutputCodeRecorder::m_showLineNumbers = false

Definition at line 154 of file outputlist.h.

154 bool m_showLineNumbers = false;

Referenced by replay and writeLineNumber.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.