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

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 DString &scopeName, const DString &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< Private > p

Detailed Description

XML scanner.

Only support syntax highlighting of code at the moment.

Definition at line 24 of file xmlcode.h.

Constructor & Destructor Documentation

◆ XMLCodeParser()

XMLCodeParser::XMLCodeParser ( )

Definition at line 396 of file xmlcode.l.

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

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

◆ ~XMLCodeParser()

XMLCodeParser::~XMLCodeParser ( )
override

Definition at line 405 of file xmlcode.l.

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

References p.

Member Function Documentation

◆ parseCode()

void XMLCodeParser::parseCode ( OutputCodeList & codeOutList,
const DString & scopeName,
const DString & 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 417 of file xmlcode.l.

424{
425 yyscan_t yyscanner = p->yyscanner;
426 struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
427
428 if (input.empty()) return;
429
430 DebugLex debugLex(Debug::Lex_xmlcode, __FILE__, options.fileDef() ? qPrint(options.fileDef()->fileName()): nullptr);
431 yyextra->fileName = options.fileDef() ? options.fileDef()->fileName():"";
432 yyextra->code = &codeOutIntf;
433 yyextra->inputString = input.data();
434 yyextra->inputPosition = 0;
435 yyextra->currentFontClass = nullptr;
436 yyextra->insideCodeLine = false;
437 yyextra->searchCtx = options.searchCtx();
438 yyextra->yyLineNr = options.startLine()!=-1 ? options.startLine() : 1;
439 yyextra->inputLines = options.endLine()!=-1 ? options.endLine()+1 : yyextra->yyLineNr + countLines(yyscanner) - 1;
440 yyextra->stripCodeComments = stripCodeComments;
441 yyextra->exampleBlock = options.isExample();
442 yyextra->exampleName = options.exampleName();
443 yyextra->sourceFileDef = options.fileDef();
444 yyextra->lineNumbers = options.fileDef() && options.showLineNumbers();
445
446 if (options.isExample() && options.fileDef()==nullptr)
447 {
448 // create a dummy filedef for the example
449 yyextra->exampleFileDef = createFileDef("",(!options.exampleName().empty()?options.exampleName():DString("generated")));
450 yyextra->sourceFileDef = yyextra->exampleFileDef.get();
451 }
452
453 if (yyextra->sourceFileDef)
454 {
455 setCurrentDoc(yyscanner,"l00001");
456 }
457
458 yyextra->includeCodeFragment = options.inlineFragment();
459 // Starts line 1 on the output
460 startCodeLine(yyscanner);
461
462 xmlcodeYYrestart( nullptr, yyscanner );
463
464 xmlcodeYYlex(yyscanner);
465
466 if (yyextra->insideCodeLine)
467 {
468 endCodeLine(yyscanner);
469 }
470 if (yyextra->exampleFileDef)
471 {
472 // delete the temporary file definition used for this example
473 yyextra->exampleFileDef.reset();
474 yyextra->sourceFileDef=nullptr;
475 }
476}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
virtual DString fileName() const =0
yyguts_t * yyscan_t
Definition code.l:25
#define yyguts_t
Definition code.l:23
const char * qPrint(const char *s)
Definition dstring.h:783
std::unique_ptr< FileDef > createFileDef(const DString &p, const DString &n, const DString &ref, const DString &dn)
Definition filedef.cpp:270
bool isExample() const
Definition parserintf.h:80
const Definition * searchCtx() const
Definition parserintf.h:88
DString exampleName() const
Definition parserintf.h:81
const FileDef * fileDef() const
Definition parserintf.h:82
int endLine() const
Definition parserintf.h:84
bool showLineNumbers() const
Definition parserintf.h:87
bool inlineFragment() const
Definition parserintf.h:85
int startLine() const
Definition parserintf.h:83
static void endCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:312
static void startCodeLine(yyscan_t yyscanner)
Definition xmlcode.l:254
static void setCurrentDoc(yyscan_t yyscanner, const DString &anchor)
Definition xmlcode.l:234
static int countLines(yyscan_t yyscanner)
Definition xmlcode.l:369

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

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

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

References p, and yyguts_t.

Referenced by XMLCodeParser().

Member Data Documentation

◆ p

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

Definition at line 42 of file xmlcode.h.

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


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