Skip to content

Commit

Permalink
header-only
Browse files Browse the repository at this point in the history
  • Loading branch information
markusicu committed Dec 23, 2024
1 parent 6568b04 commit 1bcd5ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 9 additions & 6 deletions icu4c/source/common/unicode/utf16cppiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@

#include "unicode/utypes.h"

#if U_SHOW_CPLUSPLUS_API
#if U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API

#include "unicode/utf16.h"
#include "unicode/uversion.h"

/**
* \file
* \brief C++ API: C++ iterators over Unicode 16-bit strings (=UTF-16 if well-formed).
* \brief C++ header-only API: C++ iterators over Unicode 16-bit strings (=UTF-16 if well-formed).
*/

#ifndef U_HIDE_DRAFT_API

namespace U_HEADER_ONLY_NAMESPACE {

// Some defined behaviors for handling ill-formed 16-bit strings.
Expand All @@ -44,7 +46,7 @@ enum U16IllFormedBehavior {
*
* TODO: check doxygen syntax for template parameters
* @param Unit16 char16_t or uint16_t or (on Windows) wchar_t
* @draft ICU 76
* @draft ICU 77
*/
template<typename Unit16>
class U16OneSeq {
Expand Down Expand Up @@ -108,7 +110,7 @@ class U16OneSeq {
* TODO: check doxygen syntax for template parameters
* @param Unit16 char16_t or uint16_t or (on Windows) wchar_t
* @param U16IllFormedBehavior TODO
* @draft ICU 76
* @draft ICU 77
*/
template<typename Unit16, U16IllFormedBehavior behavior>
class U16Iterator {
Expand Down Expand Up @@ -161,7 +163,7 @@ class U16Iterator {

// TODO: Non-validating iterator over the code points in a Unicode 16-bit string.
// Assumes well-formed UTF-16. Otherwise the behavior is undefined.
// TODO: all @draft ICU 76
// TODO: all @draft ICU 77
// template<typename Unit16>
// class U16UnsafeIterator
// TODO: only p, no start, no limit
Expand All @@ -170,5 +172,6 @@ class U16Iterator {

} // namespace U_HEADER_ONLY_NAMESPACE

#endif // U_SHOW_CPLUSPLUS_API
#endif // U_HIDE_DRAFT_API
#endif // U_SHOW_CPLUSPLUS_API || U_SHOW_CPLUSPLUS_HEADER_API
#endif // __UTF16CPPITER_H__
6 changes: 6 additions & 0 deletions icu4c/source/test/intltest/utfcppitertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

#include <string_view>

// Test header-only ICU C++ APIs. Do not use other ICU C++ APIs.
// Non-default configuration:
#define U_SHOW_CPLUSPLUS_API 0
// Default configuration:
// #define U_SHOW_CPLUSPLUS_HEADER_API 1

#include "unicode/utypes.h"
#include "unicode/utf16cppiter.h"
#include "intltest.h"
Expand Down

0 comments on commit 1bcd5ee

Please sign in to comment.