Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
ParsedText Class Reference

#include <guiHyperText.h>

+ Collaboration diagram for ParsedText:

Classes

struct  Element
 
struct  Paragraph
 
struct  Tag
 

Public Types

enum  ElementType { ELEMENT_TEXT , ELEMENT_SEPARATOR , ELEMENT_IMAGE , ELEMENT_ITEM }
 
enum  BackgroundType { BACKGROUND_NONE , BACKGROUND_COLOR }
 
enum  FloatType { FLOAT_NONE , FLOAT_RIGHT , FLOAT_LEFT }
 
enum  HalignType { HALIGN_CENTER , HALIGN_LEFT , HALIGN_RIGHT , HALIGN_JUSTIFY }
 
enum  ValignType { VALIGN_MIDDLE , VALIGN_TOP , VALIGN_BOTTOM }
 
typedef std::unordered_map< std::string, std::string > StyleList
 
typedef std::unordered_map< std::string, std::string > AttrsList
 

Public Member Functions

 ParsedText (const wchar_t *text)
 
 ~ParsedText ()
 

Public Attributes

std::vector< Paragraphm_paragraphs
 
s32 margin = 3
 
ValignType valign = VALIGN_TOP
 
BackgroundType background_type = BACKGROUND_NONE
 
irr::video::SColor background_color
 
Tag m_root_tag
 

Protected Types

enum  EndReason { ER_NONE , ER_TAG , ER_NEWLINE }
 

Protected Member Functions

void enterElement (ElementType type)
 
void endElement ()
 
void enterParagraph ()
 
void endParagraph (EndReason reason)
 
void pushChar (wchar_t c)
 
ParsedText::TagnewTag (const std::string &name, const AttrsList &attrs)
 
ParsedText::TagopenTag (const std::string &name, const AttrsList &attrs)
 
bool closeTag (const std::string &name)
 
void parseGenericStyleAttr (const std::string &name, const std::string &value, StyleList &style)
 
void parseStyles (const AttrsList &attrs, StyleList &style)
 
void globalTag (const ParsedText::AttrsList &attrs)
 
u32 parseTag (const wchar_t *text, u32 cursor)
 
void parse (const wchar_t *text)
 

Protected Attributes

std::unordered_map< std::string, StyleListm_elementtags
 
std::unordered_map< std::string, StyleListm_paragraphtags
 
std::vector< Tag * > m_not_root_tags
 
std::list< Tag * > m_active_tags
 
StyleList m_style
 
Elementm_element
 
Paragraphm_paragraph
 
bool m_empty_paragraph
 
EndReason m_end_paragraph_reason
 

Member Typedef Documentation

◆ AttrsList

typedef std::unordered_map<std::string, std::string> ParsedText::AttrsList

◆ StyleList

typedef std::unordered_map<std::string, std::string> ParsedText::StyleList

Member Enumeration Documentation

◆ BackgroundType

Enumerator
BACKGROUND_NONE 
BACKGROUND_COLOR 

◆ ElementType

Enumerator
ELEMENT_TEXT 
ELEMENT_SEPARATOR 
ELEMENT_IMAGE 
ELEMENT_ITEM 

◆ EndReason

enum ParsedText::EndReason
protected
Enumerator
ER_NONE 
ER_TAG 
ER_NEWLINE 

◆ FloatType

Enumerator
FLOAT_NONE 
FLOAT_RIGHT 
FLOAT_LEFT 

◆ HalignType

Enumerator
HALIGN_CENTER 
HALIGN_LEFT 
HALIGN_RIGHT 
HALIGN_JUSTIFY 

◆ ValignType

Enumerator
VALIGN_MIDDLE 
VALIGN_TOP 
VALIGN_BOTTOM 

Constructor & Destructor Documentation

◆ ParsedText()

ParsedText::ParsedText ( const wchar_t * text)

References ER_NONE, m_active_tags, m_element, m_elementtags, m_end_paragraph_reason, m_paragraph, m_paragraphtags, m_root_tag, m_style, ParsedText::Tag::name, parse(), and ParsedText::Tag::style.

+ Here is the call graph for this function:

◆ ~ParsedText()

ParsedText::~ParsedText ( )

References m_not_root_tags.

Member Function Documentation

◆ closeTag()

bool ParsedText::closeTag ( const std::string & name)
protected

References m_active_tags.

Referenced by parseTag().

+ Here is the caller graph for this function:

◆ endElement()

void ParsedText::endElement ( )
protected

References m_element.

Referenced by endParagraph(), newTag(), and parseTag().

+ Here is the caller graph for this function:

◆ endParagraph()

void ParsedText::endParagraph ( EndReason reason)
protected

References endElement(), ER_NEWLINE, ER_TAG, m_empty_paragraph, m_end_paragraph_reason, m_paragraph, and m_paragraphs.

Referenced by parse(), and parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterElement()

void ParsedText::enterElement ( ElementType type)
protected

References ParsedText::Paragraph::elements, enterParagraph(), m_active_tags, m_element, m_paragraph, m_style, ParsedText::Element::setStyle(), ParsedText::Element::tags, and ParsedText::Element::type.

Referenced by parse(), parseTag(), and pushChar().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterParagraph()

void ParsedText::enterParagraph ( )
protected

References m_empty_paragraph, m_paragraph, m_paragraphs, m_style, and ParsedText::Paragraph::setStyle().

Referenced by enterElement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ globalTag()

void ParsedText::globalTag ( const ParsedText::AttrsList & attrs)
protected

References BACKGROUND_COLOR, background_color, BACKGROUND_NONE, background_type, check_integer(), m_root_tag, margin, parseColorString(), parseGenericStyleAttr(), stoi, ParsedText::Tag::style, valign, VALIGN_BOTTOM, VALIGN_MIDDLE, and VALIGN_TOP.

Referenced by parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ newTag()

ParsedText::Tag * ParsedText::newTag ( const std::string & name,
const AttrsList & attrs )
protected

References ParsedText::Tag::attrs, endElement(), m_not_root_tags, and ParsedText::Tag::name.

Referenced by openTag(), and parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openTag()

ParsedText::Tag * ParsedText::openTag ( const std::string & name,
const AttrsList & attrs )
protected

References m_active_tags, and newTag().

Referenced by parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse()

void ParsedText::parse ( const wchar_t * text)
protected

References ELEMENT_SEPARATOR, endParagraph(), enterElement(), ER_NEWLINE, ER_NONE, m_paragraph, parseTag(), and pushChar().

Referenced by ParsedText().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseGenericStyleAttr()

void ParsedText::parseGenericStyleAttr ( const std::string & name,
const std::string & value,
StyleList & style )
protected

References check_color(), check_integer(), and is_yes().

Referenced by globalTag(), and parseStyles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseStyles()

void ParsedText::parseStyles ( const AttrsList & attrs,
StyleList & style )
protected

References parseGenericStyleAttr().

Referenced by parseTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseTag()

u32 ParsedText::parseTag ( const wchar_t * text,
u32 cursor )
protected

References ParsedText::Element::angle, closeTag(), ParsedText::Element::dim, ELEMENT_IMAGE, ELEMENT_ITEM, endElement(), endParagraph(), enterElement(), ER_TAG, FLOAT_LEFT, FLOAT_RIGHT, ParsedText::Element::floating, globalTag(), is_yes(), m_active_tags, m_element, m_elementtags, m_paragraphtags, m_style, newTag(), openTag(), parseStyles(), rangelim, ParsedText::Element::rotation, split(), stoi, ParsedText::Tag::style, ParsedText::Element::text, and wide_to_utf8().

Referenced by parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pushChar()

void ParsedText::pushChar ( wchar_t c)
protected

References ELEMENT_SEPARATOR, ELEMENT_TEXT, enterElement(), m_element, m_empty_paragraph, and ParsedText::Element::text.

Referenced by parse().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ background_color

irr::video::SColor ParsedText::background_color

Referenced by TextDrawer::draw(), and globalTag().

◆ background_type

BackgroundType ParsedText::background_type = BACKGROUND_NONE

Referenced by TextDrawer::draw(), and globalTag().

◆ m_active_tags

std::list<Tag *> ParsedText::m_active_tags
protected

◆ m_element

Element* ParsedText::m_element
protected

◆ m_elementtags

std::unordered_map<std::string, StyleList> ParsedText::m_elementtags
protected

Referenced by ParsedText(), and parseTag().

◆ m_empty_paragraph

bool ParsedText::m_empty_paragraph
protected

◆ m_end_paragraph_reason

EndReason ParsedText::m_end_paragraph_reason
protected

Referenced by ParsedText(), and endParagraph().

◆ m_not_root_tags

std::vector<Tag *> ParsedText::m_not_root_tags
protected

Referenced by ~ParsedText(), and newTag().

◆ m_paragraph

Paragraph* ParsedText::m_paragraph
protected

◆ m_paragraphs

◆ m_paragraphtags

std::unordered_map<std::string, StyleList> ParsedText::m_paragraphtags
protected

Referenced by ParsedText(), and parseTag().

◆ m_root_tag

Tag ParsedText::m_root_tag

Referenced by ParsedText(), and globalTag().

◆ m_style

StyleList ParsedText::m_style
protected

◆ margin

s32 ParsedText::margin = 3

Referenced by globalTag(), and TextDrawer::place().

◆ valign

ValignType ParsedText::valign = VALIGN_TOP

Referenced by globalTag(), and TextDrawer::place().


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