Doxygen
Loading...
Searching...
No Matches
EmojiEntityMapper Class Reference

Singleton helper class to map emoji entities to other formats. More...

#include <src/emoji.h>

+ Collaboration diagram for EmojiEntityMapper:

Public Member Functions

const char * name (int index) const
 Access routine to the name of the Emoji entity.
 
const char * unicode (int index) const
 Access routine to the unicode sequence for the Emoji entity.
 
void writeEmojiFile (TextStream &t)
 Writes the list of supported emojis to the given file.
 
int symbol2index (const std::string &symName) const
 Returns a code for the requested Emoji entity name.
 

Static Public Member Functions

static EmojiEntityMapperinstance ()
 Returns the one and only instance of the Emoji entity mapper.
 

Private Member Functions

 EmojiEntityMapper ()
 
 ~EmojiEntityMapper ()
 

Private Attributes

std::map< std::string, int > m_name2symGh
 

Static Private Attributes

static EmojiEntityMappers_instance = nullptr
 

Detailed Description

Singleton helper class to map emoji entities to other formats.

Definition at line 26 of file emoji.h.

Constructor & Destructor Documentation

◆ EmojiEntityMapper()

EmojiEntityMapper::EmojiEntityMapper ( )
private

Definition at line 1960 of file emoji.cpp.

1961{
1962 for (size_t i = 0; i < g_numEmojiEntities; i++)
1963 {
1964 m_name2symGh.emplace(g_emojiEntities[i].name, static_cast<int>(i));
1965 }
1966 for (size_t i = 0; i < g_numEmojiCompatibilityEntities; i++)
1967 {
1968 int ii = symbol2index(g_emojiCompatibilityEntities[i].newName);
1969 if (ii != -1) m_name2symGh.emplace(g_emojiCompatibilityEntities[i].oldName, ii);
1970 }
1971}
const char * name(int index) const
Access routine to the name of the Emoji entity.
Definition emoji.cpp:2026
std::map< std::string, int > m_name2symGh
Definition emoji.h:40
int symbol2index(const std::string &symName) const
Returns a code for the requested Emoji entity name.
Definition emoji.cpp:1990
static const size_t g_numEmojiCompatibilityEntities
Definition emoji.cpp:1956
static struct emojiEntityCompatibility g_emojiCompatibilityEntities[]
static struct emojiEntityInfo g_emojiEntities[]
static const size_t g_numEmojiEntities
Definition emoji.cpp:1955

References g_emojiCompatibilityEntities, g_emojiEntities, g_numEmojiCompatibilityEntities, g_numEmojiEntities, m_name2symGh, name(), and symbol2index().

Referenced by instance().

◆ ~EmojiEntityMapper()

EmojiEntityMapper::~EmojiEntityMapper ( )
private

Definition at line 1973 of file emoji.cpp.

1974{
1975}

Member Function Documentation

◆ instance()

◆ name()

const char * EmojiEntityMapper::name ( int index) const

Access routine to the name of the Emoji entity.

Parameters
indexcode of the requested Emoji entity returned by symbol2index()
Returns
the name of the Emoji entity in GitHub format (i.e. :smile:)

Definition at line 2026 of file emoji.cpp.

2027{
2028 return index>=0 && static_cast<size_t>(index)<g_numEmojiEntities ? g_emojiEntities[index].name : nullptr;
2029}

References g_emojiEntities, g_numEmojiEntities, and name().

Referenced by EmojiEntityMapper(), name(), LatexDocVisitor::operator()(), ManDocVisitor::operator()(), PerlModDocVisitor::operator()(), PrintDocVisitor::operator()(), and XmlDocVisitor::operator()().

◆ symbol2index()

int EmojiEntityMapper::symbol2index ( const std::string & symName) const

Returns a code for the requested Emoji entity name.

Parameters
symNameEmoji entity name
Returns
the code for the requested Emoji entity name, in case the requested Emoji item does not exist -1 is returned.

Definition at line 1990 of file emoji.cpp.

1991{
1992 auto it = m_name2symGh.find(symName);
1993 return it!=m_name2symGh.end() ? it->second : -1;
1994}

References m_name2symGh.

Referenced by DocEmoji::DocEmoji(), and EmojiEntityMapper().

◆ unicode()

const char * EmojiEntityMapper::unicode ( int index) const

Access routine to the unicode sequence for the Emoji entity.

Parameters
indexcode of the requested Emoji entity returned by symbol2index()
Returns
the unicode sequence of the Emoji entity,

Definition at line 2016 of file emoji.cpp.

2017{
2018 return index>=0 && static_cast<size_t>(index)<g_numEmojiEntities ? g_emojiEntities[index].unicode : nullptr;
2019}
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
Definition emoji.cpp:2016

References g_emojiEntities, g_numEmojiEntities, and unicode().

Referenced by DocbookDocVisitor::operator()(), HtmlDocVisitor::operator()(), RTFDocVisitor::operator()(), TextDocVisitor::operator()(), and unicode().

◆ writeEmojiFile()

void EmojiEntityMapper::writeEmojiFile ( TextStream & t)

Writes the list of supported emojis to the given file.

Definition at line 1999 of file emoji.cpp.

2000{
2001 for (size_t i = 0; i < g_numEmojiEntities; i++)
2002 {
2003 t << g_emojiEntities[i].name << "\n";
2004 }
2005 for (size_t i = 0; i < g_numEmojiCompatibilityEntities; i++)
2006 {
2007 t << g_emojiCompatibilityEntities[i].oldName << "\n";
2008 }
2009}
const char * name
Definition emoji.cpp:23

References g_emojiCompatibilityEntities, g_emojiEntities, g_numEmojiCompatibilityEntities, and g_numEmojiEntities.

Referenced by readConfiguration().

Member Data Documentation

◆ m_name2symGh

std::map<std::string,int> EmojiEntityMapper::m_name2symGh
private

Definition at line 40 of file emoji.h.

Referenced by EmojiEntityMapper(), and symbol2index().

◆ s_instance

EmojiEntityMapper * EmojiEntityMapper::s_instance = nullptr
staticprivate

Definition at line 39 of file emoji.h.


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