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, const CodeParserOptions &options) 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 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:71
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
std::unique_ptr< Private > p
Definition xmlcode.h:48
void resetCodeParserState() override
Resets the state of the code parser.
Definition xmlcode.l:409

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

◆ ~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,
const CodeParserOptions & options )
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]optionsAdditional options to configure the parser.

Implements CodeParserInterface.

Definition at line 416 of file xmlcode.l.

423{
424 yyscan_t yyscanner = p->yyscanner;
425 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
426
427 if (input.isEmpty()) return;
428
429 DebugLex debugLex(Debug::Lex_xmlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
430 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
431 yyextra->code = &codeOutIntf;
432 yyextra->inputString = input.data();
433 yyextra->inputPosition = 0;
434 yyextra->currentFontClass = nullptr;
435 yyextra->insideCodeLine = false;
436 yyextra->searchCtx = options.searchCtx();
437 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
438 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
439 yyextra->stripCodeComments = stripCodeComments;
440 yyextra->exampleBlock = options.isExample();
441 yyextra->exampleName = options.exampleName();
442 yyextra->sourceFileDef = options.fileDef();
443 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
444
445 if (options.isExample() && options.fileDef()==nullptr)
446 {
447 // create a dummy filedef for the example
448 yyextra->exampleFileDef = createFileDef("",(!options.exampleName().isEmpty()?options.exampleName():QCString("generated")));
449 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
450 }
451
452 if (yyextra->sourceFileDef)
453 {
454 setCurrentDoc(yyscanner,"l00001");
455 }
456
457 yyextra->includeCodeFragment = options.inlineFragment();
458 // Starts line 1 on the output
459 startCodeLine(yyscanner);
460
461 xmlcodeYYrestart( nullptr, yyscanner );
462
463 xmlcodeYYlex(yyscanner);
464
465 if (yyextra->insideCodeLine)
466 {
467 endCodeLine(yyscanner);
468 }
469 if (yyextra->exampleFileDef)
470 {
471 // delete the temporary file definition used for this example
472 yyextra->exampleFileDef.reset();
473 yyextra->sourceFileDef=nullptr;
474 }
475}
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:2489
static void startCodeLine(yyscan_t yyscanner)
Definition code.l:2420
static int countLines(yyscan_t yyscanner)
Definition code.l:3473
yyguts_t * yyscan_t
Definition code.l:24
static void setCurrentDoc(yyscan_t yyscanner, const QCString &anchor)
Definition code.l:2288
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:269
const char * qPrint(const char *s)
Definition qcstring.h:687
bool isExample() const
Definition parserintf.h:81
const Definition * searchCtx() const
Definition parserintf.h:89
const FileDef * fileDef() const
Definition parserintf.h:83
int endLine() const
Definition parserintf.h:85
bool showLineNumbers() const
Definition parserintf.h:88
bool inlineFragment() const
Definition parserintf.h:86
QCString exampleName() const
Definition parserintf.h:82
int startLine() const
Definition parserintf.h:84

References countLines(), createFileDef(), QCString::data(), endCodeLine(), CodeParserOptions::endLine(), CodeParserOptions::exampleName(), CodeParserOptions::fileDef(), FileDef::fileName(), CodeParserOptions::inlineFragment(), QCString::isEmpty(), CodeParserOptions::isExample(), Debug::Lex_xmlcode, p, qPrint(), CodeParserOptions::searchCtx(), setCurrentDoc(), CodeParserOptions::showLineNumbers(), startCodeLine(), and CodeParserOptions::startLine().

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

Member Data Documentation

◆ p

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

Definition at line 48 of file xmlcode.h.

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


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