utility 2026.1.9
A comprehensive C++ utilities library tailored for the development of modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
utility::graphic::CodePoints Class Reference

The CodePoints class manages a mapping from glyph names to Unicode code points. More...

#include <headers/utility/graphic/text/code_points.hpp>

Public Member Functions

 CodePoints ()=default
 Constructs an empty CodePoints object.
 
 CodePoints (const std::string &content)
 Constructs a CodePoints object and populates it from a string containing .codepoints formatted data.
 
 ~CodePoints ()=default
 Default destructor.
 
void parse (const std::string &content)
 Populates the mapping from a .codepoints formatted string.
 
uint32_t getCode (const std::string &name) const
 Retrieves the Unicode code point for a given glyph name.
 

Static Public Member Functions

static std::string toUtf8 (uint32_t codePoint)
 Converts a single Unicode code point to a UTF-8 encoded string.
 

Protected Attributes

std::map< std::string, uint32_t > _codes
 Internal name-to-code mapping.
 

Detailed Description

The CodePoints class manages a mapping from glyph names to Unicode code points.

It parses .codepoints files (space-separated name and hexadecimal code) and provides fast lookup of code points by glyph name, as well as conversion of a single code point to a UTF-8 encoded string.

Definition at line 24 of file code_points.hpp.

Constructor & Destructor Documentation

◆ CodePoints()

utility::graphic::CodePoints::CodePoints ( const std::string &  content)

Constructs a CodePoints object and populates it from a string containing .codepoints formatted data.

Each non-empty line is expected to contain a glyph name followed by a space and a hexadecimal code point.

Parameters
contentThe raw content of a .codepoints file.

Definition at line 13 of file code_points.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ getCode()

uint32_t utility::graphic::CodePoints::getCode ( const std::string &  name) const

Retrieves the Unicode code point for a given glyph name.

Parameters
nameThe glyph name to look up.
Returns
The corresponding code point, or 0 if the name is not found.

Definition at line 33 of file code_points.cpp.

◆ parse()

void utility::graphic::CodePoints::parse ( const std::string &  content)

Populates the mapping from a .codepoints formatted string.

Parameters
contentThe raw content of a .codepoints file.

Definition at line 18 of file code_points.cpp.

Here is the caller graph for this function:

◆ toUtf8()

std::string utility::graphic::CodePoints::toUtf8 ( uint32_t  codePoint)
static

Converts a single Unicode code point to a UTF-8 encoded string.

Parameters
codePointThe Unicode code point to convert.
Returns
A UTF-8 string representing the code point.

Definition at line 42 of file code_points.cpp.

Member Data Documentation

◆ _codes

std::map<std::string, uint32_t> utility::graphic::CodePoints::_codes
protected

Internal name-to-code mapping.

Definition at line 75 of file code_points.hpp.


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