OpenTTD Source 20241224-master-gee860a5c8e
OSXStringIterator Class Reference

String iterator using CoreText as a backend. More...

#include <string_osx.h>

Inheritance diagram for OSXStringIterator:
StringIterator

Data Structures

struct  CharInfo
 Break info for a character. More...
 

Public Member Functions

void SetString (const char *s) override
 Set a new iteration string.
 
size_t SetCurPosition (size_t pos) override
 Change the current string cursor.
 
size_t Next (IterType what) override
 Advance the cursor by one iteration unit.
 
size_t Prev (IterType what) override
 Move the cursor back by one iteration unit.
 

Static Public Member Functions

static std::unique_ptr< StringIteratorCreate ()
 
- Static Public Member Functions inherited from StringIterator
static std::unique_ptr< StringIteratorCreate ()
 Create a new iterator instance.
 

Private Attributes

std::vector< CharInfostr_info
 Break information for each code point.
 
std::vector< size_t > utf16_to_utf8
 Mapping from UTF-16 code point position to index in the UTF-8 source string.
 
size_t cur_pos
 Current iteration position.
 

Additional Inherited Members

- Public Types inherited from StringIterator
enum  IterType { ITER_CHARACTER , ITER_WORD }
 Type of the iterator. More...
 
- Static Public Attributes inherited from StringIterator
static const size_t END = SIZE_MAX
 Sentinel to indicate end-of-iteration.
 

Detailed Description

String iterator using CoreText as a backend.

Definition at line 17 of file string_osx.h.

Member Function Documentation

◆ Create()

std::unique_ptr< StringIterator > OSXStringIterator::Create ( )
static

Definition at line 476 of file string_osx.cpp.

◆ Next()

size_t OSXStringIterator::Next ( IterType  what)
overridevirtual

Advance the cursor by one iteration unit.

Returns
New cursor position (in bytes) or END if the cursor is already at the end of the string.

Implements StringIterator.

Definition at line 448 of file string_osx.cpp.

References StringIterator::ITER_CHARACTER, and StringIterator::ITER_WORD.

◆ Prev()

size_t OSXStringIterator::Prev ( IterType  what)
overridevirtual

Move the cursor back by one iteration unit.

Returns
New cursor position (in bytes) or END if the cursor is already at the start of the string.

Implements StringIterator.

Definition at line 462 of file string_osx.cpp.

References StringIterator::ITER_CHARACTER, and StringIterator::ITER_WORD.

◆ SetCurPosition()

size_t OSXStringIterator::SetCurPosition ( size_t  pos)
overridevirtual

Change the current string cursor.

Parameters
posNew cursor position.
Returns
Actual new cursor position at the next valid character boundary.
Precondition
pos has to be inside the current string.

Implements StringIterator.

Definition at line 430 of file string_osx.cpp.

◆ SetString()

void OSXStringIterator::SetString ( const char *  s)
overridevirtual

Set a new iteration string.

Must also be called if the string contents changed. The cursor is reset to the start of the string.

Parameters
sNew string.

< UTF-16 copy of the string.

Implements StringIterator.

Definition at line 371 of file string_osx.cpp.

References _osx_locale.

Field Documentation

◆ cur_pos

size_t OSXStringIterator::cur_pos
private

Current iteration position.

Definition at line 27 of file string_osx.h.

◆ str_info

std::vector<CharInfo> OSXStringIterator::str_info
private

Break information for each code point.

Definition at line 24 of file string_osx.h.

◆ utf16_to_utf8

std::vector<size_t> OSXStringIterator::utf16_to_utf8
private

Mapping from UTF-16 code point position to index in the UTF-8 source string.

Definition at line 25 of file string_osx.h.


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