ICU-10286 initial stub checkin of FilteredBreakIteratorBuilder (todo: windows proj files)

X-SVN-Rev: 35346
This commit is contained in:
Steven R. Loomis 2014-03-05 20:44:47 +00:00
parent 285f95b7fd
commit d6d65ed16b
3 changed files with 138 additions and 1 deletions

View file

@ -94,7 +94,7 @@ uspoof.o uspoof_impl.o uspoof_build.o uspoof_conf.o uspoof_wsconf.o decfmtst.o s
ztrans.o zrule.o vzone.o fphdlimp.o fpositer.o locdspnm.o \
decNumber.o decContext.o alphaindex.o tznames.o tznames_impl.o tzgnames.o \
tzfmt.o compactdecimalformat.o gender.o region.o scriptset.o identifier_info.o \
uregion.o reldatefmt.o quantityformatter.o measunit.o
uregion.o reldatefmt.o quantityformatter.o measunit.o filteredbrk.o
## Header files to install
HEADERS = $(srcdir)/unicode/*.h

View file

@ -0,0 +1,33 @@
/*
*******************************************************************************
* Copyright (C) 2014, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/
#include "unicode/filteredbrk.h"
U_NAMESPACE_BEGIN
FilteredBreakIteratorBuilder::FilteredBreakIteratorBuilder() {
}
FilteredBreakIteratorBuilder::~FilteredBreakIteratorBuilder() {
}
FilteredBreakIteratorBuilder *
FilteredBreakIteratorBuilder::createInstance(const Locale& /*where*/, UErrorCode& status) {
if (U_FAILURE(status)) return NULL;
status = U_UNSUPPORTED_ERROR;
return NULL;
}
FilteredBreakIteratorBuilder *
FilteredBreakIteratorBuilder::createInstance(UErrorCode& status) {
status = U_UNSUPPORTED_ERROR;
return NULL;
}
U_NAMESPACE_END

View file

@ -0,0 +1,104 @@
/*
********************************************************************************
* Copyright (C) 1997-2014, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*/
#ifndef FILTEREDBRK_H
#define FILTEREDBRK_H
#include "unicode/brkiter.h"
#if !UCONFIG_NO_BREAK_ITERATION
U_NAMESPACE_BEGIN
/**
* \file
* \brief C++ API: FilteredBreakIteratorBuilder
*/
/**
* The BreakIteratorFilter is used to modify the behavior of a BreakIterator
* by constructing a new BreakIterator which skips certain breaks as "exceptions".
* See http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions .
* For example, a typical English Sentence Break Iterator would break on the space
* in the string "Mr. Smith" (resulting in two segments),
* but with "Mr." as an exception, a filtered break iterator
* would consider the string "Mr. Smith" to be a single segment.
*
* @internal technology preview
*/
class U_COMMON_API FilteredBreakIteratorBuilder : public UObject {
public:
/**
* destructor.
*/
virtual ~FilteredBreakIteratorBuilder();
/**
* Construct a FilteredBreakIteratorBuilder based on rules in a locale.
* The rules are taken from CLDR exception data for the locale,
* see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exceptions
* This is the equivalent of calling createInstance(UErrorCode&)
* and then repeatedly calling addNoBreakAfter(...) with the contents
* of the CLDR exception data.
* @param where the locale.
* @param status The error code.
* @return the new builder
*/
static FilteredBreakIteratorBuilder *createInstance(const Locale& where, UErrorCode& status);
/**
* Construct an empty FilteredBreakIteratorBuilder. It will have an empty
* exception list.
* @param status The error code.
* @return the new builder
*/
static FilteredBreakIteratorBuilder *createInstance(UErrorCode &status);
/**
* Add an exception. The break iterator will not break after this string.
* @param exception the exception string
* @param status error code
* @return returns TRUE if the exception was not present and added,
* FALSE if the call was a no-op because the exception was already present.
*/
virtual UBool suppressBreakAfter(const UnicodeString& exception, UErrorCode& status) = 0;
/**
* Remove a single exception.
* @param exception the exception to remove
* @param status error code
* @return returns TRUE if the exception was present and removed,
* FALSE if the call was a no-op because the exception was not present.
*/
virtual UBool unsuppressBreakAfter(const UnicodeString& exception, UErrorCode& status) = 0;
/**
* build a BreakIterator from this builder.
* The resulting BreakIterator is owned by the caller.
* The BreakIteratorFilter may be destroyed before the BreakIterator is.
* Note that the adoptBreakIterator is adopted by the new BreakIterator
* and should no longer be used by the caller.
* @param adoptBreakIterator the break iterator to adopt
* @param status error code
* @return the new BreakIterator, owned by the caller.
*/
virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& status) = 0;
protected:
/**
* For subclass use
*/
FilteredBreakIteratorBuilder();
};
U_NAMESPACE_END
#endif // #if !UCONFIG_NO_BREAK_ITERATION
#endif // #ifndef FILTEREDBRK_H