Skip to main content

The XMLCodeParser Class Reference

XML scanner. More...

Declaration

class XMLCodeParser { ... }

Included Headers

#include <src/xmlcode.h>

Base class

classCodeParserInterface

Abstract interface for code parsers. More...

Public Constructors Index

XMLCodeParser ()

Public Destructor Index

~XMLCodeParser () override

Public Member Functions Index

voidparseCode (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. More...

voidresetCodeParserState () override

Resets the state of the code parser. More...

Private Member Attributes Index

std::unique_ptr< Private >p

Description

XML scanner.

Only support syntax highlighting of code at the moment.

Definition at line 30 of file xmlcode.h.

Public Constructors

XMLCodeParser()

XMLCodeParser::XMLCodeParser ()

Declaration at line 33 of file xmlcode.h, definition at line 395 of file xmlcode.l.

395XMLCodeParser::XMLCodeParser() : 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}

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

Public Destructor

~XMLCodeParser()

XMLCodeParser::~XMLCodeParser ()

Declaration at line 34 of file xmlcode.h, definition at line 404 of file xmlcode.l.

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

Reference p.

Public Member Functions

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

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

Parameters
[in] codeOutList

interface for writing the result.

[in] scopeName

Name of scope to which the code belongs.

[in] input

Actual code in the form of a string

[in] lang

The programming language of the code fragment.

[in] stripCodeComments

signals whether or not for the code block the doxygen comments should be stripped.

[in] isExampleBlock

TRUE iff the code is part of an example.

[in] exampleName

Name of the example.

[in] fileDef

File definition to which the code is associated.

[in] startLine

Starting line in case of a code fragment.

[in] endLine

Ending line of the code fragment.

[in] inlineFragment

Code fragment that is to be shown inline as part of the documentation.

[in] memberDef

Member definition to which the code is associated (non null in case of an inline fragment for a member).

[in] showLineNumbers

if set to TRUE and also fileDef is not 0, line numbers will be added to the source fragment

[in] searchCtx

context under which search data has to be stored.

[in] collectXRefs

collect cross-reference relations.

Declaration at line 37 of file xmlcode.h, definition at line 416 of file xmlcode.l.

417 const QCString &/* scopeName */,
418 const QCString &input,
420 bool stripCodeComments,
421 bool isExampleBlock,
422 const QCString &exampleName,
423 const FileDef *fileDef,
424 int startLine,
425 int endLine,
426 bool inlineFragment,
427 const MemberDef * /* memberDef */,
428 bool /* showLineNumbers */,
429 const Definition *searchCtx,
430 bool/* collectXRefs */
431 )
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}

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

resetCodeParserState()

void XMLCodeParser::resetCodeParserState ()
virtual

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

Declaration at line 53 of file xmlcode.h, 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}

Reference p.

Referenced by XMLCodeParser.

Private Member Attributes

p

std::unique_ptr<Private> XMLCodeParser::p

Definition at line 57 of file xmlcode.h.

57 std::unique_ptr<Private> p;

Referenced by parseCode, resetCodeParserState, XMLCodeParser and ~XMLCodeParser.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.