mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-4078 split uset_props.cpp from uset.cpp to disentangle properties code from core UnicodeSet/USet
X-SVN-Rev: 16212
This commit is contained in:
parent
1fcd7ea903
commit
3cb19a531f
4 changed files with 138 additions and 109 deletions
|
@ -71,7 +71,7 @@ utf_impl.o ustring.o ustr_cnv.o ustrcase.o cstring.o ustrfmt.o ustrtrns.o \
|
|||
normlzr.o unorm.o unorm_it.o chariter.o schriter.o uchriter.o uiter.o \
|
||||
uchar.o uprops.o propname.o ubidi.o ubidiwrt.o ubidiln.o ushape.o unames.o \
|
||||
ucln_cmn.o uscript.o usc_impl.o uvector.o ustack.o uvectr32.o ucmp8.o \
|
||||
uarrsort.o utrie.o uset.o uniset.o uniset_props.o ruleiter.o caniter.o unifilt.o unifunct.o usetiter.o \
|
||||
uarrsort.o utrie.o uset.o uset_props.o uniset.o uniset_props.o ruleiter.o caniter.o unifilt.o unifunct.o usetiter.o \
|
||||
brkiter.o brkdict.o ubrk.o dbbi.o dbbi_tbl.o \
|
||||
rbbi.o rbbidata.o rbbinode.o rbbirb.o rbbiscan.o rbbisetb.o rbbistbl.o rbbitblb.o \
|
||||
icuserv.o iculserv.o icunotif.o uenum.o ustrenum.o \
|
||||
|
|
|
@ -1512,6 +1512,9 @@
|
|||
<File
|
||||
RelativePath=".\uset.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\uset_props.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\unicode\uset.h">
|
||||
<FileConfiguration
|
||||
|
|
|
@ -34,46 +34,6 @@ uset_open(UChar32 start, UChar32 end) {
|
|||
return (USet*) new UnicodeSet(start, end);
|
||||
}
|
||||
|
||||
U_CAPI USet* U_EXPORT2
|
||||
uset_openPattern(const UChar* pattern, int32_t patternLength,
|
||||
UErrorCode* ec)
|
||||
{
|
||||
UnicodeString pat(patternLength==-1, pattern, patternLength);
|
||||
UnicodeSet* set = new UnicodeSet(pat, *ec);
|
||||
/* test for NULL */
|
||||
if(set == 0) {
|
||||
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(*ec)) {
|
||||
delete set;
|
||||
set = NULL;
|
||||
}
|
||||
return (USet*) set;
|
||||
}
|
||||
|
||||
U_CAPI USet* U_EXPORT2
|
||||
uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
|
||||
uint32_t options,
|
||||
UErrorCode* ec)
|
||||
{
|
||||
UnicodeString pat(patternLength==-1, pattern, patternLength);
|
||||
UnicodeSet* set = new UnicodeSet(pat, options, NULL, *ec);
|
||||
/* test for NULL */
|
||||
if(set == 0) {
|
||||
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(*ec)) {
|
||||
delete set;
|
||||
set = NULL;
|
||||
}
|
||||
return (USet*) set;
|
||||
}
|
||||
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_close(USet* set) {
|
||||
delete (UnicodeSet*) set;
|
||||
|
@ -85,74 +45,6 @@ uset_set(USet* set,
|
|||
((UnicodeSet*) set)->set(start, end);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
uset_applyPattern(USet *set,
|
||||
const UChar *pattern, int32_t patternLength,
|
||||
uint32_t options,
|
||||
UErrorCode *status){
|
||||
|
||||
// status code needs to be checked since we
|
||||
// dereference it
|
||||
if(status == NULL || U_FAILURE(*status)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check only the set paramenter
|
||||
// if pattern is NULL or null terminate
|
||||
// UnicodeString constructor takes care of it
|
||||
if(set == NULL){
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UnicodeString pat(pattern, patternLength);
|
||||
|
||||
ParsePosition pos;
|
||||
|
||||
((UnicodeSet*) set)->applyPattern(pat, pos, options, NULL, *status);
|
||||
|
||||
return pos.getIndex();
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_applyIntPropertyValue(USet* set,
|
||||
UProperty prop, int32_t value, UErrorCode* ec) {
|
||||
((UnicodeSet*) set)->applyIntPropertyValue(prop, value, *ec);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_applyPropertyAlias(USet* set,
|
||||
const UChar *prop, int32_t propLength,
|
||||
const UChar *value, int32_t valueLength,
|
||||
UErrorCode* ec) {
|
||||
|
||||
UnicodeString p(prop, propLength);
|
||||
UnicodeString v(value, valueLength);
|
||||
|
||||
((UnicodeSet*) set)->applyPropertyAlias(p, v, *ec);
|
||||
}
|
||||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
|
||||
int32_t pos) {
|
||||
|
||||
UnicodeString pat(pattern, patternLength);
|
||||
|
||||
return ((pos+1) < pat.length() &&
|
||||
pat.charAt(pos) == (UChar)91/*[*/) ||
|
||||
UnicodeSet::resemblesPattern(pat, pos);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
uset_toPattern(const USet* set,
|
||||
UChar* result, int32_t resultCapacity,
|
||||
UBool escapeUnprintable,
|
||||
UErrorCode* ec) {
|
||||
UnicodeString pat;
|
||||
((const UnicodeSet*) set)->toPattern(pat, escapeUnprintable);
|
||||
return pat.extract(result, resultCapacity, *ec);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_addAll(USet* set, const USet *additionalSet) {
|
||||
((UnicodeSet*) set)->addAll(*((const UnicodeSet*)additionalSet));
|
||||
|
|
134
icu4c/source/common/uset_props.cpp
Normal file
134
icu4c/source/common/uset_props.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2002-2004, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
*
|
||||
*******************************************************************************
|
||||
* file name: uset_props.cpp
|
||||
* encoding: US-ASCII
|
||||
* tab size: 8 (not used)
|
||||
* indentation:4
|
||||
*
|
||||
* created on: 2004aug30
|
||||
* created by: Markus W. Scherer
|
||||
*
|
||||
* C wrappers around UnicodeSet functions that are implemented in
|
||||
* uniset_props.cpp, split off for modularization.
|
||||
*/
|
||||
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uobject.h"
|
||||
#include "unicode/uset.h"
|
||||
#include "unicode/uniset.h"
|
||||
#include "cmemory.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/parsepos.h"
|
||||
|
||||
U_CAPI USet* U_EXPORT2
|
||||
uset_openPattern(const UChar* pattern, int32_t patternLength,
|
||||
UErrorCode* ec)
|
||||
{
|
||||
UnicodeString pat(patternLength==-1, pattern, patternLength);
|
||||
UnicodeSet* set = new UnicodeSet(pat, *ec);
|
||||
/* test for NULL */
|
||||
if(set == 0) {
|
||||
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(*ec)) {
|
||||
delete set;
|
||||
set = NULL;
|
||||
}
|
||||
return (USet*) set;
|
||||
}
|
||||
|
||||
U_CAPI USet* U_EXPORT2
|
||||
uset_openPatternOptions(const UChar* pattern, int32_t patternLength,
|
||||
uint32_t options,
|
||||
UErrorCode* ec)
|
||||
{
|
||||
UnicodeString pat(patternLength==-1, pattern, patternLength);
|
||||
UnicodeSet* set = new UnicodeSet(pat, options, NULL, *ec);
|
||||
/* test for NULL */
|
||||
if(set == 0) {
|
||||
*ec = U_MEMORY_ALLOCATION_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (U_FAILURE(*ec)) {
|
||||
delete set;
|
||||
set = NULL;
|
||||
}
|
||||
return (USet*) set;
|
||||
}
|
||||
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
uset_applyPattern(USet *set,
|
||||
const UChar *pattern, int32_t patternLength,
|
||||
uint32_t options,
|
||||
UErrorCode *status){
|
||||
|
||||
// status code needs to be checked since we
|
||||
// dereference it
|
||||
if(status == NULL || U_FAILURE(*status)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check only the set paramenter
|
||||
// if pattern is NULL or null terminate
|
||||
// UnicodeString constructor takes care of it
|
||||
if(set == NULL){
|
||||
*status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
UnicodeString pat(pattern, patternLength);
|
||||
|
||||
ParsePosition pos;
|
||||
|
||||
((UnicodeSet*) set)->applyPattern(pat, pos, options, NULL, *status);
|
||||
|
||||
return pos.getIndex();
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_applyIntPropertyValue(USet* set,
|
||||
UProperty prop, int32_t value, UErrorCode* ec) {
|
||||
((UnicodeSet*) set)->applyIntPropertyValue(prop, value, *ec);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
uset_applyPropertyAlias(USet* set,
|
||||
const UChar *prop, int32_t propLength,
|
||||
const UChar *value, int32_t valueLength,
|
||||
UErrorCode* ec) {
|
||||
|
||||
UnicodeString p(prop, propLength);
|
||||
UnicodeString v(value, valueLength);
|
||||
|
||||
((UnicodeSet*) set)->applyPropertyAlias(p, v, *ec);
|
||||
}
|
||||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
uset_resemblesPattern(const UChar *pattern, int32_t patternLength,
|
||||
int32_t pos) {
|
||||
|
||||
UnicodeString pat(pattern, patternLength);
|
||||
|
||||
return ((pos+1) < pat.length() &&
|
||||
pat.charAt(pos) == (UChar)91/*[*/) ||
|
||||
UnicodeSet::resemblesPattern(pat, pos);
|
||||
}
|
||||
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
uset_toPattern(const USet* set,
|
||||
UChar* result, int32_t resultCapacity,
|
||||
UBool escapeUnprintable,
|
||||
UErrorCode* ec) {
|
||||
UnicodeString pat;
|
||||
((const UnicodeSet*) set)->toPattern(pat, escapeUnprintable);
|
||||
return pat.extract(result, resultCapacity, *ec);
|
||||
}
|
Loading…
Add table
Reference in a new issue