Skip to content

Commit bc9e84a

Browse files
Extending scan API documentation a bit
Signed-off-by: Christian Parpart <[email protected]>
1 parent 8066f10 commit bc9e84a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/libunicode/scan.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,22 @@ class grapheme_cluster_receiver
5656
public:
5757
virtual ~grapheme_cluster_receiver() = default;
5858

59+
// Event handler for US-ASCII sequences received.
60+
//
61+
// @param codepoints US-ASCII codepoints
5962
virtual void receiveAsciiSequence(std::string_view codepoints) noexcept = 0;
63+
64+
// Event handler for grapheme clusters received.
65+
//
66+
// @param codepoints UTF-8 encoded grapheme cluster
67+
// @param columnCount number of columns this grapheme cluster spans
6068
virtual void receiveGraphemeCluster(std::string_view codepoints, size_t columnCount) noexcept = 0;
69+
70+
// Event handler for invalid UTF-8 byte sequence received.
71+
//
72+
// @param sequence invalid UTF-8 byte sequence
73+
//
74+
// This is usually called when the input sequence contains an invalid UTF-8 byte sequence.
6175
virtual void receiveInvalidGraphemeCluster(std::string_view sequence) noexcept = 0;
6276
};
6377

@@ -78,7 +92,22 @@ class null_receiver final: public grapheme_cluster_receiver
7892

7993
namespace detail
8094
{
95+
// Scans ASCII text for grapheme clusters.
96+
//
97+
// @param text UTF-8 text to be (resumed) to be scanned
98+
// @param maxColumnCount number of columns to be scanned at most
99+
//
100+
// @return Number of US-ASCII text columns scanned.
81101
size_t scan_for_text_ascii(std::string_view text, size_t maxColumnCount) noexcept;
102+
103+
// Scans non-ASCII text for grapheme clusters.
104+
//
105+
// @param state scan state to be used
106+
// @param text UTF-8 text to be (resumed) to be scanned
107+
// @param maxColumnCount number of columns to be scanned at most
108+
// @param receiver event listener to be informed about
109+
//
110+
// @return scanned textual result.
82111
scan_result scan_for_text_nonascii(scan_state& state,
83112
std::string_view text,
84113
size_t maxColumnCount,
@@ -104,6 +133,14 @@ namespace detail
104133
/// but not incomplete codepoints at the end.
105134
scan_result scan_text(scan_state& state, std::string_view text, size_t maxColumnCount) noexcept;
106135

136+
/// Scans the text until the next control character,
137+
/// or the maximum number of columns have been processed.
138+
///
139+
/// @param state
140+
/// @param text UTF-8 text to be (resumed) to be scanned
141+
/// @param maxColumnCount number of columns to be scanned at most
142+
/// @param receiver event listener to be informed about
143+
/// new grapheme clusters etc
107144
scan_result scan_text(scan_state& state,
108145
std::string_view text,
109146
size_t maxColumnCount,

0 commit comments

Comments
 (0)