로딩중...
검색중...
일치하는것 없음
by::cpIter 클래스 참조

Codepoint-based string iterator 더 자세히 ...

#include <cpIter.hpp>

Public 멤버 함수

 cpIter (const nchar *begin, const nchar *from)
 Constructs iterator from pointer range
 
 cpIter (const std::string &from, nbool isReversed=false)
 Constructs iterator from string reference
 
 cpIter (std::string &&from, nbool isReversed=false)=delete
 
me operator+ (ncnt step)
 
me & operator++ ()
 
me operator++ (int)
 
me & operator+= (ncnt step)
 
std::string operator* () const
 
 operator nbool () const
 
nbool operator== (const me &rhs) const
 
nbool isEnd () const
 
void rel ()
 
ncnt next (ncnt step)
 Advances iterator in its default direction
 
ncnt stepForward (ncnt step)
 Unconditionally advances iterator forward
 
ncnt stepBackward (ncnt step)
 Unconditionally advances iterator backward
 
std::string get () const
 
ncnt remainLen () const
 

상세한 설명

Codepoint-based string iterator

Handles codepoint-based iteration for strings. Primarily used in nStr for traversing multibyte strings like UTF-8 Unicode.

Like typical iterators, it supports prefix/postfix increment operators, dereference operator, and bool conversion operator. When creating a cpIter, you can specify the string to traverse along with the default iteration direction.

Remarks
Direction and initial position The direction specified during cpIter creation defines the iterator's default direction and initial position. If you pass reverse = true as argument, cpIter starts from the end of the string in reverse direction. However, if you explicitly call stepBackward() or stepForward(), it will move in that direction regardless of the default direction.
Past-the-end semantics Like STL, begin points to the first element, but end points to the position after the last element (past-the-end). Therefore, when traversing in reverse, you must call next() first.

Usage

Basic usage example:

std::string src = "abcd🏁efg"; // In UTF-8, 🏁 is represented by 3 characters
cpIter e4(src, true); // Define default iteration as reverse.
// At this point, it points to past-the-end position
while(*e4 != "") // Currently at end position, so "" is returned
++e4; // Same as calling e4.next(). Moves in default reverse direction
// But this code never actually executes
ASSERT_EQ(*e4, "");
std::string expects[] = {"g", "f", "e", "🏁", "d", "c", "b", "a"};
for(int n = 0; n < 8; n++) {
// Explicitly specify direction to traverse iterator.
// Unconditionally moves backward regardless of e4's direction
e4.stepBackward(1);
// For reverse traversal, you must step first
}
Codepoint-based string iterator
Definition cpIter.hpp:51
Source location information
Definition src.hpp:15
Rich logging support with polymorphic type conversion
Definition richLog.hpp:34

생성자 & 소멸자 문서화

◆ cpIter() [1/2]

by::cpIter::cpIter ( const nchar * begin,
const nchar * from )

Constructs iterator from pointer range

주의
Direction automatically determined: reverse if begin > from, forward otherwise

◆ cpIter() [2/2]

by::cpIter::cpIter ( const std::string & from,
nbool isReversed = false )
explicit

Constructs iterator from string reference

매개변수
fromString must outlive this iterator
isReversedtrue for reverse iteration (starts at end), false for forward

멤버 함수 문서화

◆ next()

ncnt by::cpIter::next ( ncnt step)

Advances iterator in its default direction

반환값
Actual codepoints moved (may be less if end reached)
주의
Moves forward for forward iterators, backward for reverse iterators

◆ stepBackward()

ncnt by::cpIter::stepBackward ( ncnt step)

Unconditionally advances iterator backward

반환값
Actual codepoints moved (may be less if beginning reached)
주의
Direction is absolute, unaffected by iterator's reverse flag

◆ stepForward()

ncnt by::cpIter::stepForward ( ncnt step)

Unconditionally advances iterator forward

반환값
Actual codepoints moved (may be less if end reached)
주의
Direction is absolute, unaffected by iterator's reverse flag

이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: