Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/intl/icu/source/i18n/ufieldpositer.cpp
Line
Count
Source (jump to first uncovered line)
1
// © 2016 and later: Unicode, Inc. and others.
2
// License & terms of use: http://www.unicode.org/copyright.html
3
/*
4
*****************************************************************************************
5
* Copyright (C) 2015, International Business Machines
6
* Corporation and others. All Rights Reserved.
7
*****************************************************************************************
8
*/
9
10
#include "unicode/utypes.h"
11
12
#if !UCONFIG_NO_FORMATTING
13
14
#include "unicode/ufieldpositer.h"
15
#include "unicode/fpositer.h"
16
#include "unicode/localpointer.h"
17
18
U_NAMESPACE_USE
19
20
21
U_CAPI UFieldPositionIterator* U_EXPORT2
22
ufieldpositer_open(UErrorCode* status)
23
0
{
24
0
    if (U_FAILURE(*status)) {
25
0
        return NULL;
26
0
    }
27
0
    FieldPositionIterator* fpositer = new FieldPositionIterator();
28
0
    if (fpositer == NULL) {
29
0
        *status = U_MEMORY_ALLOCATION_ERROR;
30
0
    }
31
0
    return (UFieldPositionIterator*)fpositer;
32
0
}
33
34
35
U_CAPI void U_EXPORT2
36
ufieldpositer_close(UFieldPositionIterator *fpositer)
37
0
{
38
0
    delete (FieldPositionIterator*)fpositer;
39
0
}
40
41
42
U_CAPI int32_t U_EXPORT2
43
ufieldpositer_next(UFieldPositionIterator *fpositer,
44
                   int32_t *beginIndex, int32_t *endIndex)
45
0
{
46
0
    FieldPosition fp;
47
0
    int32_t field = -1;
48
0
    if (((FieldPositionIterator*)fpositer)->next(fp)) {
49
0
        field = fp.getField();
50
0
        if (beginIndex) {
51
0
            *beginIndex = fp.getBeginIndex();
52
0
        }
53
0
        if (endIndex) {
54
0
            *endIndex = fp.getEndIndex();
55
0
        }
56
0
    }
57
0
    return field;
58
0
}
59
60
61
#endif /* #if !UCONFIG_NO_FORMATTING */