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 1963 of file emoji.cpp.

1964{
1965 for (size_t i = 0; i < g_numEmojiEntities; i++)
1966 {
1967 m_name2symGh.emplace(g_emojiEntities[i].name, static_cast<int>(i));
1968 }
1969 for (size_t i = 0; i < g_numEmojiCompatibilityEntities; i++)
1970 {
1971 int ii = symbol2index(g_emojiCompatibilityEntities[i].newName);
1972 if (ii != -1) m_name2symGh.emplace(g_emojiCompatibilityEntities[i].oldName, ii);
1973 }
1974}
const char * name(int index) const
Access routine to the name of the Emoji entity.
Definition emoji.cpp:2029
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:1993
static const size_t g_numEmojiCompatibilityEntities
Definition emoji.cpp:1959
static struct emojiEntityCompatibility g_emojiCompatibilityEntities[]
static struct emojiEntityInfo g_emojiEntities[]
static const size_t g_numEmojiEntities
Definition emoji.cpp:1958

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

Referenced by instance().

◆ ~EmojiEntityMapper()

EmojiEntityMapper::~EmojiEntityMapper ( )
private

Definition at line 1976 of file emoji.cpp.

1977{
1978}

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 2029 of file emoji.cpp.

2030{
2031 return index>=0 && static_cast<size_t>(index)<g_numEmojiEntities ? g_emojiEntities[index].name : nullptr;
2032}

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 1993 of file emoji.cpp.

1994{
1995 auto it = m_name2symGh.find(symName);
1996 return it!=m_name2symGh.end() ? it->second : -1;
1997}

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 2019 of file emoji.cpp.

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

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 2002 of file emoji.cpp.

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

References g_emojiCompatibilityEntities, g_emojiEntities, g_numEmojiCompatibilityEntities, g_numEmojiEntities, emojiEntityInfo::name, and emojiEntityCompatibility::oldName.

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: