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.
 
- Public Member Functions inherited from CodeParserInterface

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 395 of file xmlcode.l.

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

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

◆ ~XMLCodeParser()

XMLCodeParser::~XMLCodeParser ( )
override

Definition at line 404 of file xmlcode.l.

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

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 416 of file xmlcode.l.

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

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 409 of file xmlcode.l.

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

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: