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 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:48
void resetCodeParserState() override
Resets the state of the code parser.
Definition xmlcode.l:408

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

◆ ~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,
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 415 of file xmlcode.l.

422{
423 yyscan_t yyscanner = p->yyscanner;
424 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
425
426 if (input.isEmpty()) return;
427
428 DebugLex debugLex(Debug::Lex_xmlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
429 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
430 yyextra->code = &codeOutIntf;
431 yyextra->inputString = input.data();
432 yyextra->inputPosition = 0;
433 yyextra->currentFontClass = nullptr;
434 yyextra->insideCodeLine = false;
435 yyextra->searchCtx = options.searchCtx();
436 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
437 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
438 yyextra->stripCodeComments = stripCodeComments;
439 yyextra->exampleBlock = options.isExample();
440 yyextra->exampleName = options.exampleName();
441 yyextra->sourceFileDef = options.fileDef();
442
443 if (options.isExample() && options.fileDef()==nullptr)
444 {
445 // create a dummy filedef for the example
446 yyextra->exampleFileDef = createFileDef("",(!options.exampleName().isEmpty()?options.exampleName():QCString("generated")));
447 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
448 }
449
450 if (yyextra->sourceFileDef)
451 {
452 setCurrentDoc(yyscanner,"l00001");
453 }
454
455 yyextra->includeCodeFragment = options.inlineFragment();
456 // Starts line 1 on the output
457 startCodeLine(yyscanner);
458
459 xmlcodeYYrestart( nullptr, yyscanner );
460
461 xmlcodeYYlex(yyscanner);
462
463 if (yyextra->insideCodeLine)
464 {
465 endCodeLine(yyscanner);
466 }
467 if (yyextra->exampleFileDef)
468 {
469 // delete the temporary file definition used for this example
470 yyextra->exampleFileDef.reset();
471 yyextra->sourceFileDef=nullptr;
472 }
473}
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:3462
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
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 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(), 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 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.

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: