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

XML scanner. More...

#include <src/xmlcode.h>

Inheritance diagram for XMLCodeParser:
Collaboration diagram for XMLCodeParser:

Classes

struct  Private

Public Member Functions

 XMLCodeParser ()
 ~XMLCodeParser () override
void parseCode (OutputCodeList &codeOutIntf, const QCString &scopeName, const QCString &input, SrcLangExt, bool stripCodeComments, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE) override
 Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
void resetCodeParserState () override
 Resets the state of the code parser.

Private Attributes

std::unique_ptr< Privatep

Detailed Description

XML scanner.

Only support syntax highlighting of code at the moment.

Definition at line 30 of file xmlcode.h.

Constructor & Destructor Documentation

◆ XMLCodeParser()

XMLCodeParser::XMLCodeParser ( )

Definition at line 394 of file xmlcode.l.

394 : p(std::make_unique<Private>())
395{
396 xmlcodeYYlex_init_extra(&p->state,&p->yyscanner);
397#ifdef FLEX_DEBUG
398 xmlcodeYYset_debug(Debug::isFlagSet(Debug::Lex_xmlcode)?1:0,p->yyscanner);
399#endif
401}
@ Lex_xmlcode
Definition debug.h:71
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
std::unique_ptr< Private > p
Definition xmlcode.h:57
void resetCodeParserState() override
Resets the state of the code parser.
Definition xmlcode.l:408

References Debug::isFlagSet(), Debug::Lex_xmlcode, p, and resetCodeParserState().

◆ ~XMLCodeParser()

XMLCodeParser::~XMLCodeParser ( )
override

Definition at line 403 of file xmlcode.l.

404{
405 xmlcodeYYlex_destroy(p->yyscanner);
406}

References p.

Member Function Documentation

◆ parseCode()

void XMLCodeParser::parseCode ( OutputCodeList & codeOutList,
const QCString & scopeName,
const QCString & input,
SrcLangExt lang,
bool stripCodeComments,
bool isExampleBlock,
const QCString & exampleName = QCString(),
const FileDef * fileDef = nullptr,
int startLine = -1,
int endLine = -1,
bool inlineFragment = FALSE,
const MemberDef * memberDef = nullptr,
bool showLineNumbers = TRUE,
const Definition * searchCtx = nullptr,
bool collectXRefs = TRUE )
overridevirtual

Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.

Parameters
[in]codeOutListinterface for writing the result.
[in]scopeNameName of scope to which the code belongs.
[in]inputActual code in the form of a string
[in]langThe programming language of the code fragment.
[in]stripCodeCommentssignals whether or not for the code block the doxygen comments should be stripped.
[in]isExampleBlockTRUE iff the code is part of an example.
[in]exampleNameName of the example.
[in]fileDefFile definition to which the code is associated.
[in]startLineStarting line in case of a code fragment.
[in]endLineEnding line of the code fragment.
[in]inlineFragmentCode fragment that is to be shown inline as part of the documentation.
[in]memberDefMember definition to which the code is associated (non null in case of an inline fragment for a member).
[in]showLineNumbersif set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment
[in]searchCtxcontext under which search data has to be stored.
[in]collectXRefscollect cross-reference relations.

Implements CodeParserInterface.

Definition at line 415 of file xmlcode.l.

431{
432 yyscan_t yyscanner = p->yyscanner;
433 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
434
435 if (input.isEmpty()) return;
436
437 DebugLex debugLex(Debug::Lex_xmlcode, __FILE__, fileDef ? qPrint(fileDef->fileName()): nullptr);
438 yyextra->fileName = fileDef ? fileDef->fileName():"";
439
440 yyextra->code = &codeOutIntf;
441 yyextra->inputString = input.data();
442 yyextra->inputPosition = 0;
443 yyextra->currentFontClass = nullptr;
444 yyextra->insideCodeLine = false;
445 yyextra->searchCtx = searchCtx;
446
447 if (startLine!=-1)
448 yyextra->yyLineNr = startLine;
449 else
450 yyextra->yyLineNr = 1;
451
452 if (endLine!=-1)
453 yyextra->inputLines = endLine+1;
454 else
455 yyextra->inputLines = yyextra->yyLineNr + countLines(yyscanner) - 1;
456
457 yyextra->stripCodeComments = stripCodeComments;
458 yyextra->exampleBlock = isExampleBlock;
459 yyextra->exampleName = exampleName;
460 yyextra->sourceFileDef = fileDef;
461
462 if (isExampleBlock && fileDef==0)
463 {
464 // create a dummy filedef for the example
465 yyextra->exampleFileDef = createFileDef("",(!exampleName.isEmpty()?exampleName:QCString("generated")));
466 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
467 }
468
469 if (yyextra->sourceFileDef)
470 {
471 setCurrentDoc(yyscanner,"l00001");
472 }
473
474 yyextra->includeCodeFragment = inlineFragment;
475 // Starts line 1 on the output
476 startCodeLine(yyscanner);
477
478 xmlcodeYYrestart( nullptr, yyscanner );
479
480 xmlcodeYYlex(yyscanner);
481
482 if (yyextra->insideCodeLine)
483 {
484 endCodeLine(yyscanner);
485 }
486 if (yyextra->exampleFileDef)
487 {
488 // delete the temporary file definition used for this example
489 yyextra->exampleFileDef.reset();
490 yyextra->sourceFileDef=nullptr;
491 }
492}
virtual QCString fileName() const =0
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
static void endCodeLine(yyscan_t yyscanner)
Definition code.l:2478
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2409
static int countLines(yyscan_t yyscanner)
Definition code.l:3454
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2277
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
const char * qPrint(const char *s)
Definition qcstring.h:687

References countLines(), createFileDef(), QCString::data(), endCodeLine(), FileDef::fileName(), QCString::isEmpty(), Debug::Lex_xmlcode, p, qPrint(), setCurrentDoc(), and startCodeLine().

◆ resetCodeParserState()

void XMLCodeParser::resetCodeParserState ( )
overridevirtual

Resets the state of the code parser.

Since multiple code fragments can together form a single example, an explicit function is used to reset the code parser state.

See also
parseCode()

Implements CodeParserInterface.

Definition at line 408 of file xmlcode.l.

409{
410 struct yyguts_t *yyg = (struct yyguts_t*)p->yyscanner;
411 yyextra->currentDefinition = nullptr;
412 yyextra->currentMemberDef = nullptr;
413}

References p.

Referenced by XMLCodeParser().

Member Data Documentation

◆ p

std::unique_ptr<Private> XMLCodeParser::p
private

Definition at line 57 of file xmlcode.h.

Referenced by parseCode(), resetCodeParserState(), XMLCodeParser(), and ~XMLCodeParser().


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