Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/intl/icu/source/i18n/zrule.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) 2009-2011, International Business Machines Corporation and
6
* others. All Rights Reserved.
7
*******************************************************************************
8
*/
9
10
/**
11
 * \file 
12
 * \brief C API: Time zone rule classes
13
 */
14
15
#include "unicode/utypes.h"
16
17
#if !UCONFIG_NO_FORMATTING
18
19
#include "unicode/uobject.h"
20
#include "zrule.h"
21
#include "unicode/tzrule.h"
22
#include "cmemory.h"
23
#include "unicode/ustring.h"
24
#include "unicode/parsepos.h"
25
26
U_NAMESPACE_USE
27
28
/*********************************************************************
29
 * ZRule API
30
 *********************************************************************/
31
32
U_CAPI void U_EXPORT2
33
0
zrule_close(ZRule* rule) {
34
0
    delete (TimeZoneRule*)rule;
35
0
}
36
37
U_CAPI UBool U_EXPORT2
38
0
zrule_equals(const ZRule* rule1, const ZRule* rule2) {
39
0
    return *(const TimeZoneRule*)rule1 == *(const TimeZoneRule*)rule2;
40
0
}
41
42
U_CAPI void U_EXPORT2
43
0
zrule_getName(ZRule* rule, UChar* name, int32_t nameLength) {
44
0
    UnicodeString s(nameLength==-1, name, nameLength);
45
0
    s = ((TimeZoneRule*)rule)->TimeZoneRule::getName(s);
46
0
    nameLength = s.length();
47
0
    memcpy(name, s.getBuffer(), nameLength);
48
0
    return;
49
0
}
50
51
U_CAPI int32_t U_EXPORT2
52
0
zrule_getRawOffset(ZRule* rule) {
53
0
    return ((TimeZoneRule*)rule)->TimeZoneRule::getRawOffset();
54
0
}
55
56
U_CAPI int32_t U_EXPORT2
57
0
zrule_getDSTSavings(ZRule* rule) {
58
0
    return ((TimeZoneRule*)rule)->TimeZoneRule::getDSTSavings();
59
0
}
60
61
U_CAPI UBool U_EXPORT2
62
0
zrule_isEquivalentTo(ZRule* rule1,  ZRule* rule2) {
63
0
    return ((TimeZoneRule*)rule1)->TimeZoneRule::isEquivalentTo(*(TimeZoneRule*)rule2);
64
0
}
65
66
/*********************************************************************
67
 * IZRule API
68
 *********************************************************************/
69
70
U_CAPI IZRule* U_EXPORT2
71
0
izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
72
0
    UnicodeString s(nameLength==-1, name, nameLength);
73
0
    return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings);
74
0
}
75
76
U_CAPI void U_EXPORT2
77
0
izrule_close(IZRule* rule) {
78
0
    delete (InitialTimeZoneRule*)rule;
79
0
}
80
81
U_CAPI IZRule* U_EXPORT2
82
0
izrule_clone(IZRule *rule) {
83
0
    return (IZRule*) (((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::clone());
84
0
}
85
86
U_CAPI UBool U_EXPORT2
87
0
izrule_equals(const IZRule* rule1, const IZRule* rule2) {
88
0
    return *(const InitialTimeZoneRule*)rule1 == *(const InitialTimeZoneRule*)rule2;
89
0
}
90
91
U_CAPI void U_EXPORT2
92
0
izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength) {
93
0
    // UnicodeString s(nameLength==-1, name, nameLength);
94
0
    UnicodeString s;
95
0
    ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getName(s);
96
0
    nameLength = s.length();
97
0
    name = (UChar*)uprv_malloc(nameLength);
98
0
    memcpy(name, s.getBuffer(), nameLength);
99
0
    return;
100
0
}
101
102
U_CAPI int32_t U_EXPORT2
103
0
izrule_getRawOffset(IZRule* rule) {
104
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getRawOffset();
105
0
}
106
107
U_CAPI int32_t U_EXPORT2
108
0
izrule_getDSTSavings(IZRule* rule) {
109
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDSTSavings();
110
0
}
111
112
U_CAPI UBool U_EXPORT2
113
0
izrule_isEquivalentTo(IZRule* rule1,  IZRule* rule2) {
114
0
    return ((InitialTimeZoneRule*)rule1)->InitialTimeZoneRule::isEquivalentTo(*(InitialTimeZoneRule*)rule2);
115
0
}
116
117
U_CAPI UBool U_EXPORT2
118
izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 
119
0
                    UDate& result) {
120
0
    return ((const InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFirstStart(prevRawOffset, prevDSTSavings, result);
121
0
}
122
123
U_CAPI UBool U_EXPORT2
124
izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 
125
0
                    UDate& result) {
126
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFinalStart(prevRawOffset, prevDSTSavings, result);
127
0
}
128
129
U_CAPI UBool U_EXPORT2
130
izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, 
131
0
                   int32_t prevDSTSavings, UBool inclusive, UDate& result) {
132
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getNextStart(base, prevRawOffset, prevDSTSavings, inclusive, result);
133
0
}
134
135
U_CAPI UBool U_EXPORT2
136
izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, 
137
0
                       int32_t prevDSTSavings, UBool inclusive, UDate& result) {
138
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getPreviousStart(base, prevRawOffset, prevDSTSavings, inclusive, result);
139
0
}
140
141
U_CAPI UClassID U_EXPORT2
142
0
izrule_getStaticClassID(IZRule* rule) {
143
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getStaticClassID();
144
0
}
145
146
U_CAPI UClassID U_EXPORT2
147
0
izrule_getDynamicClassID(IZRule* rule) {
148
0
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDynamicClassID();
149
0
}
150
151
#endif