mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-2209 make canonical iterator public
X-SVN-Rev: 9866
This commit is contained in:
parent
a298df56b3
commit
0fb205837f
5 changed files with 190 additions and 168 deletions
|
@ -9,7 +9,7 @@
|
|||
#include "unicode/ustring.h"
|
||||
#include "hash.h"
|
||||
#include "unormimp.h"
|
||||
#include "caniter.h"
|
||||
#include "unicode/caniter.h"
|
||||
#include "unicode/normlzr.h"
|
||||
#include "unicode/uchar.h"
|
||||
#include "cmemory.h"
|
||||
|
@ -81,7 +81,7 @@ const char CanonicalIterator::fgClassID=0;
|
|||
/**
|
||||
*@param source string to get results for
|
||||
*/
|
||||
CanonicalIterator::CanonicalIterator(UnicodeString sourceStr, UErrorCode &status) :
|
||||
CanonicalIterator::CanonicalIterator(const UnicodeString &sourceStr, UErrorCode &status) :
|
||||
pieces(NULL),
|
||||
pieces_length(0),
|
||||
pieces_lengths(NULL),
|
||||
|
@ -141,12 +141,15 @@ void CanonicalIterator::reset() {
|
|||
*/
|
||||
UnicodeString CanonicalIterator::next() {
|
||||
int32_t i = 0;
|
||||
if (done)
|
||||
return "";
|
||||
buffer.truncate(0); //buffer.setLength(0); // delete old contents
|
||||
|
||||
if (done) {
|
||||
buffer.setToBogus();
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// construct return value
|
||||
|
||||
buffer.truncate(0); //buffer.setLength(0); // delete old contents
|
||||
for (i = 0; i < pieces_length; ++i) {
|
||||
buffer.append(pieces[i][current[i]]);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,7 +29,7 @@
|
|||
#include "unicode/normlzr.h"
|
||||
#include "ucol_elm.h"
|
||||
#include "unormimp.h"
|
||||
#include "caniter.h"
|
||||
#include "unicode/caniter.h"
|
||||
#include "cmemory.h"
|
||||
|
||||
U_NAMESPACE_BEGIN
|
||||
|
@ -1121,7 +1121,7 @@ uprv_uca_addAnElement(tempUCATable *t, UCAElements *element, UErrorCode *status)
|
|||
UnicodeString source(element->cPoints, element->cSize);
|
||||
CanonicalIterator it(source, *status);
|
||||
source = it.next();
|
||||
while(source.length() > 0) {
|
||||
while(!source.isBogus()) {
|
||||
if(Normalizer::quickCheck(source, UNORM_FCD, *status) != UNORM_NO) {
|
||||
element->cSize = source.extract(element->cPoints, 128, *status);
|
||||
uprv_uca_finalizeAddition(t, element, status);
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
*@param source string to get results for
|
||||
*@param status Fill-in parameter which receives the status of this operation.
|
||||
*/
|
||||
CanonicalIterator(UnicodeString source, UErrorCode &status);
|
||||
CanonicalIterator(const UnicodeString &source, UErrorCode &status);
|
||||
|
||||
/** Destructor
|
||||
* Cleans pieces
|
|
@ -12,7 +12,7 @@
|
|||
#include "intltest.h"
|
||||
#include "cstring.h"
|
||||
#include "canittst.h"
|
||||
#include "caniter.h"
|
||||
#include "unicode/caniter.h"
|
||||
#include "unicode/uchar.h"
|
||||
|
||||
#define ARRAY_LENGTH(array) ((int32_t)(sizeof (array) / sizeof (*array)))
|
||||
|
@ -98,7 +98,7 @@ void CanonicalIteratorTest::TestExhaustive() {
|
|||
|
||||
while (TRUE) {
|
||||
UnicodeString item = it.next();
|
||||
if (item == "") break;
|
||||
if (item.isBogus()) break;
|
||||
if (item == s) gotSource = TRUE;
|
||||
if (item == decomp) gotDecomp = TRUE;
|
||||
if (item == comp) gotComp = TRUE;
|
||||
|
@ -164,7 +164,7 @@ void CanonicalIteratorTest::TestBasic() {
|
|||
while (TRUE) {
|
||||
//UnicodeString *result = new UnicodeString(it.next());
|
||||
UnicodeString result(it.next());
|
||||
if (result == "") {
|
||||
if (result.isBogus()) {
|
||||
break;
|
||||
}
|
||||
set->put(result, new UnicodeString(result), status); // Add result to the table
|
||||
|
|
Loading…
Add table
Reference in a new issue