ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::utf8_char_t Class Reference

#include <utf8_char.hpp>

Collaboration diagram for Ark::internal::utf8_char_t:
[legend]

Public Types

using codepoint_t = int
 
using length_t = unsigned char
 
using repr_t = std::array<unsigned char, 5>
 

Public Member Functions

 utf8_char_t ()
 
 utf8_char_t (const codepoint_t cp, const length_t len, const repr_t repr)
 
bool isPrintable () const
 
const char * c_str () const
 
std::size_t size () const
 
codepoint_t codepoint () const
 

Static Public Member Functions

static std::pair< std::string::iterator, utf8_char_tat (const std::string::iterator it, const std::string::iterator end)
 Parse a codepoint and compute its length and representation.
 

Private Attributes

codepoint_t m_codepoint
 
length_t m_length
 
repr_t m_repr
 

Detailed Description

Definition at line 12 of file utf8_char.hpp.

Member Typedef Documentation

◆ codepoint_t

Definition at line 15 of file utf8_char.hpp.

◆ length_t

using Ark::internal::utf8_char_t::length_t = unsigned char

Definition at line 16 of file utf8_char.hpp.

◆ repr_t

using Ark::internal::utf8_char_t::repr_t = std::array<unsigned char, 5>

Definition at line 17 of file utf8_char.hpp.

Constructor & Destructor Documentation

◆ utf8_char_t() [1/2]

Ark::internal::utf8_char_t::utf8_char_t ( )
inline

Definition at line 19 of file utf8_char.hpp.

Referenced by at().

◆ utf8_char_t() [2/2]

Ark::internal::utf8_char_t::utf8_char_t ( const codepoint_t cp,
const length_t len,
const repr_t repr )
inline

Definition at line 22 of file utf8_char.hpp.

Member Function Documentation

◆ at()

static std::pair< std::string::iterator, utf8_char_t > Ark::internal::utf8_char_t::at ( const std::string::iterator it,
const std::string::iterator end )
inlinestatic

Parse a codepoint and compute its length and representation.

https://github.com/sheredom/utf8.h/blob/4e4d828174c35e4564c31a9e35580c299c69a063/utf8.h#L1178

Parameters
ititerator in a string
endend iterator, used to avoid going out of bound
Returns
std::pair<std::string::iterator, utf8_char_t> the iterator points to the beginning of the next codepoint, the utf8_char_t represents the parsed codepoint

Definition at line 32 of file utf8_char.hpp.

References utf8_char_t().

Referenced by Ark::internal::BaseParser::backtrack(), and Ark::internal::BaseParser::next().

◆ c_str()

const char * Ark::internal::utf8_char_t::c_str ( ) const
inlinenodiscard

Definition at line 92 of file utf8_char.hpp.

References m_repr.

Referenced by Ark::internal::BaseParser::accept(), and Ark::internal::BaseParser::expect().

◆ codepoint()

codepoint_t Ark::internal::utf8_char_t::codepoint ( ) const
inlinenodiscard

Definition at line 94 of file utf8_char.hpp.

References m_codepoint.

Referenced by Ark::internal::BaseParser::accept(), and Ark::internal::BaseParser::expect().

◆ isPrintable()

bool Ark::internal::utf8_char_t::isPrintable ( ) const
inlinenodiscard
Returns
true if the given codepoint is printable according to std::isprint

Definition at line 85 of file utf8_char.hpp.

References m_codepoint.

Referenced by Ark::internal::BaseParser::next().

◆ size()

std::size_t Ark::internal::utf8_char_t::size ( ) const
inlinenodiscard

Definition at line 93 of file utf8_char.hpp.

References m_length.

Referenced by Ark::internal::BaseParser::next().

Member Data Documentation

◆ m_codepoint

codepoint_t Ark::internal::utf8_char_t::m_codepoint
private

Definition at line 97 of file utf8_char.hpp.

Referenced by codepoint(), and isPrintable().

◆ m_length

length_t Ark::internal::utf8_char_t::m_length
private

Definition at line 98 of file utf8_char.hpp.

Referenced by size().

◆ m_repr

repr_t Ark::internal::utf8_char_t::m_repr
private

Definition at line 99 of file utf8_char.hpp.

Referenced by c_str().


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