MD::PosCache

Search for usage in LXR

#include <poscache.h>

Inheritance diagram for MD::PosCache< Trait >:

Public Types

using Items = typename Trait::template Vector<Item<Trait> *>
 

Public Member Functions

 PosCache ()=default
 
 ~PosCache () override=default
 
Items findFirstInCache (const MD::WithPosition &pos) const
 
virtual void initialize (std::shared_ptr< MD::Document< Trait > > doc)
 
- Public Member Functions inherited from MD::Visitor< Trait >
 Visitor ()=default
 
virtual ~Visitor ()=default
 
void process (std::shared_ptr< Document< Trait > > d)
 

Protected Member Functions

void findFirstInCache (const std::vector< details::PosRange< Trait > > &vec, const details::PosRange< Trait > &pos, Items &res) const
 
details::PosRange< Trait > * findInCache (std::vector< details::PosRange< Trait > > &vec, const details::PosRange< Trait > &pos) const
 
void insertInCache (const details::PosRange< Trait > &item, bool sort=false)
 
void onAddLineEnding () override
 
void onAnchor (Anchor< Trait > *) override
 
void onBlockquote (Blockquote< Trait > *b) override
 
void onCode (Code< Trait > *c) override
 
void onFootnote (Footnote< Trait > *f) override
 
void onFootnoteRef (FootnoteRef< Trait > *ref) override
 
void onHeading (Heading< Trait > *h) override
 
void onHorizontalLine (HorizontalLine< Trait > *l) override
 
void onImage (Image< Trait > *i) override
 
void onInlineCode (Code< Trait > *c) override
 
void onLineBreak (LineBreak< Trait > *) override
 
void onLink (Link< Trait > *l) override
 
void onList (List< Trait > *l) override
 
void onListItem (ListItem< Trait > *l, bool first) override
 
void onMath (Math< Trait > *m) override
 
void onParagraph (Paragraph< Trait > *p, bool wrap) override
 
void onRawHtml (RawHtml< Trait > *h) override
 
virtual void onReferenceLink (Link< Trait > *l)
 
void onTable (Table< Trait > *t) override
 
void onText (Text< Trait > *t) override
 
void onUserDefined (Item< Trait > *i) override
 
- Protected Member Functions inherited from MD::Visitor< Trait >
virtual void onTableCell (TableCell< Trait > *c)
 

Protected Attributes

std::vector< details::PosRange< Trait > > m_cache
 
bool m_skipInCache = false
 
- Protected Attributes inherited from MD::Visitor< Trait >
Trait::template Vector< typename Trait::String > m_anchors
 
std::shared_ptr< Document< Trait > > m_doc
 

Detailed Description

template<class Trait>
class MD::PosCache< Trait >

Cache of Markdown items to be accessed via position.

Definition at line 74 of file poscache.h.

Member Typedef Documentation

◆ Items

template<class Trait >
using MD::PosCache< Trait >::Items = typename Trait::template Vector<Item<Trait> *>

Vector with items, where front is a top-level item, and back is most nested child.

Definition at line 101 of file poscache.h.

Constructor & Destructor Documentation

◆ PosCache()

template<class Trait >
MD::PosCache< Trait >::PosCache ( )
default

◆ ~PosCache()

template<class Trait >
MD::PosCache< Trait >::~PosCache ( )
overridedefault

Member Function Documentation

◆ findFirstInCache() [1/2]

template<class Trait >
Items MD::PosCache< Trait >::findFirstInCache ( const MD::WithPosition & pos) const
inline
Returns
First occurense of Markdown item with all first children by the give position.

Definition at line 104 of file poscache.h.

◆ findFirstInCache() [2/2]

template<class Trait >
void MD::PosCache< Trait >::findFirstInCache ( const std::vector< details::PosRange< Trait > > & vec,
const details::PosRange< Trait > & pos,
Items & res ) const
inlineprotected

Find in cache items with the given position with all parents.

Parameters
vecCache.
posPosition of sought-for item.
resReference to result of search.

Definition at line 140 of file poscache.h.

◆ findInCache()

template<class Trait >
details::PosRange< Trait > * MD::PosCache< Trait >::findInCache ( std::vector< details::PosRange< Trait > > & vec,
const details::PosRange< Trait > & pos ) const
inlineprotected

Find in cache an item with the given position.

Parameters
vecCache of position.
posPosition of sought-for item.

Definition at line 118 of file poscache.h.

◆ initialize()

template<class Trait >
virtual void MD::PosCache< Trait >::initialize ( std::shared_ptr< MD::Document< Trait > > doc)
inlinevirtual

Initialize m_cache with the give document.

Note
Document should not be recursive.

Definition at line 82 of file poscache.h.

◆ insertInCache()

template<class Trait >
void MD::PosCache< Trait >::insertInCache ( const details::PosRange< Trait > & item,
bool sort = false )
inlineprotected

Insert in cache.

Parameters
itemPosition for insertion.
sortShould we sord when insert top-level item, or we can be sure that this item is last?

Definition at line 160 of file poscache.h.

◆ onAddLineEnding()

template<class Trait >
void MD::PosCache< Trait >::onAddLineEnding ( )
inlineoverrideprotectedvirtual

For some generator it's important to keep line endings like they were in Markdown.

So onParagraph() method invokes this method when necessary to add line ending.

Implements MD::Visitor< Trait >.

Definition at line 208 of file poscache.h.

◆ onAnchor()

template<class Trait >
void MD::PosCache< Trait >::onAnchor ( Anchor< Trait > * a)
inlineoverrideprotectedvirtual

Handle anchor.

Parameters
aAnchor.

Implements MD::Visitor< Trait >.

Definition at line 369 of file poscache.h.

◆ onBlockquote()

template<class Trait >
void MD::PosCache< Trait >::onBlockquote ( Blockquote< Trait > * b)
inlineoverrideprotectedvirtual

Cache blockquote.

Reimplemented from MD::Visitor< Trait >.

Definition at line 310 of file poscache.h.

◆ onCode()

template<class Trait >
void MD::PosCache< Trait >::onCode ( Code< Trait > * c)
inlineoverrideprotectedvirtual

Cache code.

Implements MD::Visitor< Trait >.

Definition at line 274 of file poscache.h.

◆ onFootnote()

template<class Trait >
void MD::PosCache< Trait >::onFootnote ( Footnote< Trait > * f)
inlineoverrideprotectedvirtual

Cache footnote.

Reimplemented from MD::Visitor< Trait >.

Definition at line 471 of file poscache.h.

◆ onFootnoteRef()

template<class Trait >
void MD::PosCache< Trait >::onFootnoteRef ( FootnoteRef< Trait > * ref)
inlineoverrideprotectedvirtual

Cache footnote reference.

Implements MD::Visitor< Trait >.

Definition at line 448 of file poscache.h.

◆ onHeading()

template<class Trait >
void MD::PosCache< Trait >::onHeading ( Heading< Trait > * h)
inlineoverrideprotectedvirtual

Cache heading.

Implements MD::Visitor< Trait >.

Definition at line 262 of file poscache.h.

◆ onHorizontalLine()

template<class Trait >
void MD::PosCache< Trait >::onHorizontalLine ( HorizontalLine< Trait > * l)
inlineoverrideprotectedvirtual

Cache horizontal line.

Implements MD::Visitor< Trait >.

Definition at line 382 of file poscache.h.

◆ onImage()

template<class Trait >
void MD::PosCache< Trait >::onImage ( Image< Trait > * i)
inlineoverrideprotectedvirtual

Cache image.

Implements MD::Visitor< Trait >.

Definition at line 419 of file poscache.h.

◆ onInlineCode()

template<class Trait >
void MD::PosCache< Trait >::onInlineCode ( Code< Trait > * c)
inlineoverrideprotectedvirtual

Cache inline code.

Implements MD::Visitor< Trait >.

Definition at line 287 of file poscache.h.

◆ onLineBreak()

template<class Trait >
void MD::PosCache< Trait >::onLineBreak ( LineBreak< Trait > * b)
inlineoverrideprotectedvirtual

Handle line break.

Parameters
bLinebreak.

Implements MD::Visitor< Trait >.

Definition at line 247 of file poscache.h.

◆ onLink()

template<class Trait >
void MD::PosCache< Trait >::onLink ( Link< Trait > * l)
inlineoverrideprotectedvirtual

Cache link.

Implements MD::Visitor< Trait >.

Definition at line 390 of file poscache.h.

◆ onList()

template<class Trait >
void MD::PosCache< Trait >::onList ( List< Trait > * l)
inlineoverrideprotectedvirtual

Cache list.

Implements MD::Visitor< Trait >.

Definition at line 320 of file poscache.h.

◆ onListItem()

template<class Trait >
void MD::PosCache< Trait >::onListItem ( ListItem< Trait > * l,
bool first )
inlineoverrideprotectedvirtual

Cache list item.

Reimplemented from MD::Visitor< Trait >.

Definition at line 481 of file poscache.h.

◆ onMath()

template<class Trait >
void MD::PosCache< Trait >::onMath ( Math< Trait > * m)
inlineoverrideprotectedvirtual

Cache LaTeX math expression.

Implements MD::Visitor< Trait >.

Definition at line 225 of file poscache.h.

◆ onParagraph()

template<class Trait >
void MD::PosCache< Trait >::onParagraph ( Paragraph< Trait > * p,
bool wrap )
inlineoverrideprotectedvirtual

Cache paragraph.

Reimplemented from MD::Visitor< Trait >.

Definition at line 252 of file poscache.h.

◆ onRawHtml()

template<class Trait >
void MD::PosCache< Trait >::onRawHtml ( RawHtml< Trait > * h)
inlineoverrideprotectedvirtual

Cache raw HTML.

Implements MD::Visitor< Trait >.

Definition at line 374 of file poscache.h.

◆ onReferenceLink()

template<class Trait >
virtual void MD::PosCache< Trait >::onReferenceLink ( Link< Trait > * l)
inlineprotectedvirtual

Cache shortcut link.

Parameters
lLink.

Definition at line 199 of file poscache.h.

◆ onTable()

template<class Trait >
void MD::PosCache< Trait >::onTable ( Table< Trait > * t)
inlineoverrideprotectedvirtual

Cache table.

Implements MD::Visitor< Trait >.

Definition at line 338 of file poscache.h.

◆ onText()

template<class Trait >
void MD::PosCache< Trait >::onText ( Text< Trait > * t)
inlineoverrideprotectedvirtual

Cache text item.

Implements MD::Visitor< Trait >.

Definition at line 213 of file poscache.h.

◆ onUserDefined()

template<class Trait >
void MD::PosCache< Trait >::onUserDefined ( Item< Trait > * i)
inlineoverrideprotectedvirtual

Cache user defined item.

Reimplemented from MD::Visitor< Trait >.

Definition at line 191 of file poscache.h.

Member Data Documentation

◆ m_cache

template<class Trait >
std::vector<details::PosRange<Trait> > MD::PosCache< Trait >::m_cache
protected

Cache.

Definition at line 492 of file poscache.h.

◆ m_skipInCache

template<class Trait >
bool MD::PosCache< Trait >::m_skipInCache = false
protected

Skip adding in cache.

Definition at line 494 of file poscache.h.


The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.