Rune Caster 1.0.0
Modern C++ Text Processing Framework
Loading...
Searching...
No Matches
rune_caster::Rune Class Reference

Represents a single textual unit with Unicode and linguistic properties. More...

#include <rune.hpp>

Public Member Functions

constexpr Rune () noexcept
 Default constructor (creates null character)
constexpr Rune (char32_t codepoint) noexcept
 Construct a Rune from a Unicode codepoint.
constexpr Rune (char32_t codepoint, language::Code lang) noexcept
 Construct a Rune with explicit language information.
 Rune (char32_t codepoint, language::Code lang, std::string phoneme)
 Construct a Rune with phonetic representation.
constexpr Rune (const Rune &)=default
constexpr Rune (Rune &&) noexcept=default
constexpr Runeoperator= (const Rune &)=default
constexpr Runeoperator= (Rune &&) noexcept=default
 ~Rune ()=default
constexpr char32_t codepoint () const noexcept
 Get the Unicode codepoint.
constexpr language::Code language () const noexcept
 Get the language code.
constexpr unicode::Category category () const noexcept
 Get the Unicode category.
constexpr unicode::Script script () const noexcept
 Get the Unicode script.
const std::string & phoneme () const noexcept
 Get the phonetic representation.
constexpr void set_language (language::Code lang) noexcept
 Set the language code.
void set_phoneme (std::string phoneme)
 Set the phonetic representation.
constexpr bool is_vowel () const noexcept
 Check if this rune represents a vowel.
constexpr bool is_consonant () const noexcept
 Check if this rune represents a consonant.
constexpr bool is_letter () const noexcept
 Check if this rune is a letter.
constexpr bool is_digit () const noexcept
 Check if this rune is a digit.
constexpr bool is_whitespace () const noexcept
 Check if this rune is whitespace.
constexpr bool is_punctuation () const noexcept
 Check if this rune is punctuation.
constexpr bool is_ascii () const noexcept
 Check if this is an ASCII character.
constexpr bool is_latin () const noexcept
 Check if this is a Latin script character.
constexpr bool is_hangul () const noexcept
 Check if this is a Hangul (Korean) character.
constexpr bool is_hiragana () const noexcept
 Check if this is a Hiragana character.
constexpr bool is_katakana () const noexcept
 Check if this is a Katakana character.
constexpr bool is_kanji () const noexcept
 Check if this is a Kanji character.
constexpr bool is_emoji () const noexcept
 Check if this is an emoji character.
std::string to_utf8 () const
 Convert to UTF-8 string.
std::u16string to_utf16 () const
 Convert to UTF-16 string.
constexpr std::u32string to_utf32 () const
 Convert to UTF-32 string.
constexpr auto operator<=> (const Rune &other) const noexcept=default
 Three-way comparison operator (C++20)
constexpr bool operator== (const Rune &other) const noexcept=default
 Equality comparison.

Static Public Member Functions

static Rune from_utf8 (std::string_view utf8_char)
 Create a Rune from a UTF-8 character.
static Rune from_utf8 (std::string_view utf8_char, language::Code lang)
 Create a Rune from a UTF-8 character with language hint.
static Rune from_utf16 (std::u16string_view utf16_char)
 Create a Rune from a UTF-16 character.

Detailed Description

Represents a single textual unit with Unicode and linguistic properties.

The Rune class encapsulates a Unicode codepoint along with its linguistic attributes such as language, category, and phonetic representation. It serves as the fundamental building block for text processing in the rune-caster framework.

C++20 Enhanced: Supports constexpr operations, comprehensive language detection, and modern C++ features for optimal performance.

Definition at line 23 of file rune.hpp.

Constructor & Destructor Documentation

◆ Rune() [1/6]

rune_caster::Rune::Rune ( )
inlineconstexprnoexcept

Default constructor (creates null character)

Definition at line 274 of file rune.hpp.

◆ Rune() [2/6]

rune_caster::Rune::Rune ( char32_t codepoint)
inlineexplicitconstexprnoexcept

Construct a Rune from a Unicode codepoint.

Parameters
codepointThe Unicode codepoint

Definition at line 275 of file rune.hpp.

◆ Rune() [3/6]

rune_caster::Rune::Rune ( char32_t codepoint,
language::Code lang )
inlineconstexprnoexcept

Construct a Rune with explicit language information.

Parameters
codepointThe Unicode codepoint
languageThe language code

Definition at line 276 of file rune.hpp.

◆ Rune() [4/6]

rune_caster::Rune::Rune ( char32_t codepoint,
language::Code lang,
std::string phoneme )

Construct a Rune with phonetic representation.

Parameters
codepointThe Unicode codepoint
languageThe language code
phonemeThe phonetic representation

Definition at line 10 of file rune.cpp.

◆ Rune() [5/6]

rune_caster::Rune::Rune ( const Rune & )
constexprdefault

◆ Rune() [6/6]

rune_caster::Rune::Rune ( Rune && )
constexprdefaultnoexcept

◆ ~Rune()

rune_caster::Rune::~Rune ( )
default

Member Function Documentation

◆ category()

unicode::Category rune_caster::Rune::category ( ) const
nodiscardconstexprnoexcept

Get the Unicode category.

Returns
The Unicode category

Definition at line 19 of file rune.cpp.

◆ codepoint()

char32_t rune_caster::Rune::codepoint ( ) const
inlinenodiscardconstexprnoexcept

Get the Unicode codepoint.

Returns
The Unicode codepoint

Definition at line 66 of file rune.hpp.

◆ from_utf16()

Rune rune_caster::Rune::from_utf16 ( std::u16string_view utf16_char)
static

Create a Rune from a UTF-16 character.

Parameters
utf16_charUTF-16 encoded character
Returns
Rune object
Exceptions
std::invalid_argumentif invalid UTF-16 sequence

Definition at line 200 of file rune.cpp.

◆ from_utf8() [1/2]

Rune rune_caster::Rune::from_utf8 ( std::string_view utf8_char)
static

Create a Rune from a UTF-8 character.

Parameters
utf8_charUTF-8 encoded character (may be multi-byte)
Returns
Rune object
Exceptions
std::invalid_argumentif invalid UTF-8 sequence

Definition at line 140 of file rune.cpp.

◆ from_utf8() [2/2]

Rune rune_caster::Rune::from_utf8 ( std::string_view utf8_char,
language::Code lang )
static

Create a Rune from a UTF-8 character with language hint.

Parameters
utf8_charUTF-8 encoded character
languageLanguage hint for processing
Returns
Rune object
Exceptions
std::invalid_argumentif invalid UTF-8 sequence

Definition at line 194 of file rune.cpp.

◆ is_ascii()

bool rune_caster::Rune::is_ascii ( ) const
nodiscardconstexprnoexcept

Check if this is an ASCII character.

Returns
true if ASCII (0-127), false otherwise

Definition at line 29 of file rune.cpp.

◆ is_consonant()

bool rune_caster::Rune::is_consonant ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune represents a consonant.

Returns
true if consonant, false otherwise

Definition at line 341 of file rune.hpp.

◆ is_digit()

bool rune_caster::Rune::is_digit ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune is a digit.

Returns
true if digit, false otherwise

Definition at line 280 of file rune.hpp.

◆ is_emoji()

bool rune_caster::Rune::is_emoji ( ) const
nodiscardconstexprnoexcept

Check if this is an emoji character.

Returns
true if emoji, false otherwise

Definition at line 71 of file rune.cpp.

◆ is_hangul()

bool rune_caster::Rune::is_hangul ( ) const
nodiscardconstexprnoexcept

Check if this is a Hangul (Korean) character.

Returns
true if Hangul, false otherwise

Definition at line 41 of file rune.cpp.

◆ is_hiragana()

bool rune_caster::Rune::is_hiragana ( ) const
nodiscardconstexprnoexcept

Check if this is a Hiragana character.

Returns
true if Hiragana, false otherwise

Definition at line 50 of file rune.cpp.

◆ is_kanji()

bool rune_caster::Rune::is_kanji ( ) const
nodiscardconstexprnoexcept

Check if this is a Kanji character.

Returns
true if Kanji (CJK Unified Ideographs), false otherwise

Definition at line 62 of file rune.cpp.

◆ is_katakana()

bool rune_caster::Rune::is_katakana ( ) const
nodiscardconstexprnoexcept

Check if this is a Katakana character.

Returns
true if Katakana, false otherwise

Definition at line 55 of file rune.cpp.

◆ is_latin()

bool rune_caster::Rune::is_latin ( ) const
nodiscardconstexprnoexcept

Check if this is a Latin script character.

Returns
true if Latin script, false otherwise

Definition at line 33 of file rune.cpp.

◆ is_letter()

bool rune_caster::Rune::is_letter ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune is a letter.

Returns
true if letter, false otherwise

Definition at line 279 of file rune.hpp.

◆ is_punctuation()

bool rune_caster::Rune::is_punctuation ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune is punctuation.

Returns
true if punctuation, false otherwise

Definition at line 282 of file rune.hpp.

◆ is_vowel()

bool rune_caster::Rune::is_vowel ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune represents a vowel.

Returns
true if vowel, false otherwise

Definition at line 315 of file rune.hpp.

◆ is_whitespace()

bool rune_caster::Rune::is_whitespace ( ) const
inlinenodiscardconstexprnoexcept

Check if this rune is whitespace.

Returns
true if whitespace, false otherwise

Definition at line 281 of file rune.hpp.

◆ language()

language::Code rune_caster::Rune::language ( ) const
inlinenodiscardconstexprnoexcept

Get the language code.

Returns
The language code

Definition at line 72 of file rune.hpp.

◆ operator<=>()

auto rune_caster::Rune::operator<=> ( const Rune & other) const
nodiscardconstexprdefaultnoexcept

Three-way comparison operator (C++20)

◆ operator=() [1/2]

Rune & rune_caster::Rune::operator= ( const Rune & )
constexprdefault

◆ operator=() [2/2]

Rune & rune_caster::Rune::operator= ( Rune && )
constexprdefaultnoexcept

◆ operator==()

bool rune_caster::Rune::operator== ( const Rune & other) const
nodiscardconstexprdefaultnoexcept

Equality comparison.

◆ phoneme()

const std::string & rune_caster::Rune::phoneme ( ) const
inlinenodiscardnoexcept

Get the phonetic representation.

Returns
The phonetic representation as a string

Definition at line 90 of file rune.hpp.

◆ script()

unicode::Script rune_caster::Rune::script ( ) const
nodiscardconstexprnoexcept

Get the Unicode script.

Returns
The Unicode script

Definition at line 23 of file rune.cpp.

◆ set_language()

void rune_caster::Rune::set_language ( language::Code lang)
inlineconstexprnoexcept

Set the language code.

Parameters
languageThe new language code

Definition at line 98 of file rune.hpp.

◆ set_phoneme()

void rune_caster::Rune::set_phoneme ( std::string phoneme)
inline

Set the phonetic representation.

Parameters
phonemeThe new phonetic representation

Definition at line 104 of file rune.hpp.

◆ to_utf16()

std::u16string rune_caster::Rune::to_utf16 ( ) const
nodiscard

Convert to UTF-16 string.

Returns
UTF-16 encoded string representation

Definition at line 114 of file rune.cpp.

◆ to_utf32()

std::u32string rune_caster::Rune::to_utf32 ( ) const
nodiscardconstexpr

Convert to UTF-32 string.

Returns
UTF-32 encoded string representation

Definition at line 134 of file rune.cpp.

◆ to_utf8()

std::string rune_caster::Rune::to_utf8 ( ) const
nodiscard

Convert to UTF-8 string.

Returns
UTF-8 encoded string representation

Definition at line 86 of file rune.cpp.


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