Doxygen
Loading...
Searching...
No Matches
OutputCodeRecorder Class Reference

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

#include <src/outputlist.h>

+ Inheritance diagram for OutputCodeRecorder:
+ Collaboration diagram for OutputCodeRecorder:

Classes

struct  CallInfo
 

Public Member Functions

OutputType type () const override
 
void codify (const QCString &s) override
 
void stripCodeComments (bool) override
 
void startSpecialComment () override
 
void endSpecialComment () override
 
void setStripIndentAmount (size_t) override
 
std::unique_ptr< OutputCodeIntfclone () override
 
void writeCodeLink (CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip) override
 
void writeLineNumber (const QCString &ref, const QCString &file, const QCString &anchor, int lineNumber, bool writeLineAnchor) override
 
void writeTooltip (const QCString &id, const DocLinkInfo &docInfo, const QCString &decl, const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo) override
 
void startCodeLine (int) override
 
void endCodeLine () override
 
void startFontClass (const QCString &c) override
 
void endFontClass () override
 
void writeCodeAnchor (const QCString &name) override
 
void startCodeFragment (const QCString &style) override
 
void endCodeFragment (const QCString &style) override
 
void startFold (int lineNr, const QCString &startMarker, const QCString &endMarker) override
 
void endFold () override
 
void replay (OutputCodeList &ol, int startLine, int endLine, bool showLineNumbers, bool stripComment, size_t stripIndentAmount)
 
- Public Member Functions inherited from OutputCodeIntf
 OutputCodeIntf ()=default
 

Private Member Functions

void startNewLine (int lineNr)
 

Private Attributes

std::vector< CallInfom_calls
 
std::vector< size_t > m_lineOffset
 
bool m_showLineNumbers = false
 
bool m_insideSpecialComment = false
 

Detailed 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.

Member Function Documentation

◆ clone()

std::unique_ptr< OutputCodeIntf > OutputCodeRecorder::clone ( )
inlineoverridevirtual

Implements OutputCodeIntf.

Definition at line 120 of file outputlist.h.

120{ return std::make_unique<OutputCodeRecorder>(*this); }

◆ codify()

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

Implements OutputCodeIntf.

Definition at line 230 of file outputlist.cpp.

231{
232 m_calls.emplace_back([]() { return true; },
233 [=](OutputCodeList *ol) { ol->codify(s); },
235 );
236}
std::vector< CallInfo > m_calls
Definition outputlist.h:152

References m_calls, and m_insideSpecialComment.

◆ endCodeFragment()

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

Implements OutputCodeIntf.

Definition at line 331 of file outputlist.cpp.

332{
333}

◆ endCodeLine()

void OutputCodeRecorder::endCodeLine ( )
overridevirtual

Implements OutputCodeIntf.

Definition at line 295 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ endFold()

void OutputCodeRecorder::endFold ( )
overridevirtual

Implements OutputCodeIntf.

Definition at line 343 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ endFontClass()

void OutputCodeRecorder::endFontClass ( )
overridevirtual

Implements OutputCodeIntf.

Definition at line 311 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ endSpecialComment()

void OutputCodeRecorder::endSpecialComment ( )
overridevirtual

Implements OutputCodeIntf.

Definition at line 247 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ replay()

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

Definition at line 351 of file outputlist.cpp.

353{
354 size_t startIndex = startLine>0 && startLine<=(int)m_lineOffset.size() ? m_lineOffset[startLine-1] : 0;
355 size_t endIndex = endLine>0 && endLine <=(int)m_lineOffset.size() ? m_lineOffset[ endLine-1] : m_calls.size();
356 //printf("startIndex=%zu endIndex=%zu\n",startIndex,endIndex);
357
358 // configure run time properties of the rendering
360 ol.setStripIndentAmount(stripIndentAmount);
361 m_showLineNumbers = showLineNumbers;
362
363 bool insideSpecialComment = false;
364 // in case the start of the special comment marker is outside of the fragment, start it here
365 if (startIndex<endIndex && m_calls[startIndex].insideSpecialComment)
366 {
368 insideSpecialComment = true;
369 }
370
371 // render the requested fragment of the pre-recorded output
372 for (size_t i=startIndex; i<endIndex; i++)
373 {
374 if (m_calls[i].condition())
375 {
376 insideSpecialComment = m_calls[i].insideSpecialComment;
377 m_calls[i].function(&ol);
378 }
379 }
380
381 // if we end the fragment inside a special comment, make sure we end it,
382 // and also the code line
383 if (insideSpecialComment)
384 {
386 ol.endCodeLine();
387 }
388}
void endCodeLine()
Definition outputlist.h:266
void endSpecialComment()
Definition outputlist.h:243
void startSpecialComment()
Definition outputlist.h:240
void setStripIndentAmount(size_t amount)
Definition outputlist.h:246
void stripCodeComments(bool b)
Definition outputlist.h:237
void stripCodeComments(bool) override
Definition outputlist.h:116
std::vector< size_t > m_lineOffset
Definition outputlist.h:153

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 )
inlineoverridevirtual

Implements OutputCodeIntf.

Definition at line 119 of file outputlist.h.

119{}

◆ startCodeFragment()

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

Implements OutputCodeIntf.

Definition at line 327 of file outputlist.cpp.

328{
329}

◆ startCodeLine()

void OutputCodeRecorder::startCodeLine ( int lineNr)
overridevirtual

Implements OutputCodeIntf.

Definition at line 286 of file outputlist.cpp.

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

References m_calls, m_insideSpecialComment, and startNewLine().

◆ startFold()

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

Implements OutputCodeIntf.

Definition at line 335 of file outputlist.cpp.

336{
337 m_calls.emplace_back([]() { return true; },
338 [=](OutputCodeList *ol) { ol->startFold(lineNr,startMarker,endMarker); },
340 );
341}

References m_calls, and m_insideSpecialComment.

◆ startFontClass()

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

Implements OutputCodeIntf.

Definition at line 303 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ startNewLine()

void OutputCodeRecorder::startNewLine ( int lineNr)
private

Definition at line 216 of file outputlist.cpp.

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

References m_calls, and m_lineOffset.

Referenced by startCodeLine(), and writeLineNumber().

◆ startSpecialComment()

void OutputCodeRecorder::startSpecialComment ( )
overridevirtual

Implements OutputCodeIntf.

Definition at line 238 of file outputlist.cpp.

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

References m_calls, and m_insideSpecialComment.

◆ stripCodeComments()

void OutputCodeRecorder::stripCodeComments ( bool )
inlineoverridevirtual

Implements OutputCodeIntf.

Definition at line 116 of file outputlist.h.

116{}

Referenced by replay().

◆ type()

OutputType OutputCodeRecorder::type ( ) const
inlineoverridevirtual

Implements OutputCodeIntf.

Definition at line 114 of file outputlist.h.

114{ return OutputType::Recorder; }

References Recorder.

Referenced by writeCodeLink().

◆ writeCodeAnchor()

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

Implements OutputCodeIntf.

Definition at line 319 of file outputlist.cpp.

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

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 )
overridevirtual

Implements OutputCodeIntf.

Definition at line 256 of file outputlist.cpp.

260{
261 m_calls.emplace_back([](){ return true; },
262 [=](OutputCodeList *ol) { ol->writeCodeLink(type,ref,file,anchor,name,tooltip); },
264 );
265}
OutputType type() const override
Definition outputlist.h:114

References m_calls, m_insideSpecialComment, and type().

◆ writeLineNumber()

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

Implements OutputCodeIntf.

Definition at line 267 of file outputlist.cpp.

269{
270 startNewLine(lineNumber);
271 m_calls.emplace_back([&]() { return m_showLineNumbers; },
272 [=](OutputCodeList *ol) { ol->writeLineNumber(ref,file,anchor,lineNumber,writeLineAnchor); },
274 );
275}

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 )
overridevirtual

Implements OutputCodeIntf.

Definition at line 277 of file outputlist.cpp.

279{
280 m_calls.emplace_back([](){ return true; },
281 [=](OutputCodeList *ol) { ol->writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); },
283 );
284}

References m_calls, and m_insideSpecialComment.

Member Data Documentation

◆ m_calls

◆ m_insideSpecialComment

bool OutputCodeRecorder::m_insideSpecialComment = false
private

◆ m_lineOffset

std::vector<size_t> OutputCodeRecorder::m_lineOffset
private

Definition at line 153 of file outputlist.h.

Referenced by replay(), and startNewLine().

◆ m_showLineNumbers

bool OutputCodeRecorder::m_showLineNumbers = false
private

Definition at line 154 of file outputlist.h.

Referenced by replay(), and writeLineNumber().


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