OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ********************************************************************************
********* |
| 3 * Copyright (C) 2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************************
********* |
| 6 */ |
| 7 |
| 8 #include "unicode/utypes.h" |
| 9 |
| 10 #if !UCONFIG_NO_FORMATTING |
| 11 |
| 12 #include "unicode/ufieldpositer.h" |
| 13 #include "unicode/fpositer.h" |
| 14 #include "unicode/localpointer.h" |
| 15 |
| 16 U_NAMESPACE_USE |
| 17 |
| 18 |
| 19 U_CAPI UFieldPositionIterator* U_EXPORT2 |
| 20 ufieldpositer_open(UErrorCode* status) |
| 21 { |
| 22 if (U_FAILURE(*status)) { |
| 23 return NULL; |
| 24 } |
| 25 FieldPositionIterator* fpositer = new FieldPositionIterator(); |
| 26 if (fpositer == NULL) { |
| 27 *status = U_MEMORY_ALLOCATION_ERROR; |
| 28 } |
| 29 return (UFieldPositionIterator*)fpositer; |
| 30 } |
| 31 |
| 32 |
| 33 U_CAPI void U_EXPORT2 |
| 34 ufieldpositer_close(UFieldPositionIterator *fpositer) |
| 35 { |
| 36 delete (FieldPositionIterator*)fpositer; |
| 37 } |
| 38 |
| 39 |
| 40 U_CAPI int32_t U_EXPORT2 |
| 41 ufieldpositer_next(UFieldPositionIterator *fpositer, |
| 42 int32_t *beginIndex, int32_t *endIndex) |
| 43 { |
| 44 FieldPosition fp; |
| 45 int32_t field = -1; |
| 46 if (((FieldPositionIterator*)fpositer)->next(fp)) { |
| 47 field = fp.getField(); |
| 48 if (beginIndex) { |
| 49 *beginIndex = fp.getBeginIndex(); |
| 50 } |
| 51 if (endIndex) { |
| 52 *endIndex = fp.getEndIndex(); |
| 53 } |
| 54 } |
| 55 return field; |
| 56 } |
| 57 |
| 58 |
| 59 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |