DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (31ec81b5d7bb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
/*
*******************************************************************************
* Copyright (C) 2009-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/

/**
 * \file 
 * \brief C API: Time zone rule classes
 */

#include "unicode/utypes.h"

#if !UCONFIG_NO_FORMATTING

#include "unicode/uobject.h"
#include "zrule.h"
#include "unicode/tzrule.h"
#include "cmemory.h"
#include "unicode/ustring.h"
#include "unicode/parsepos.h"

U_NAMESPACE_USE

/*********************************************************************
 * ZRule API
 *********************************************************************/

U_CAPI void U_EXPORT2
zrule_close(ZRule* rule) {
    delete (TimeZoneRule*)rule;
}

U_CAPI UBool U_EXPORT2
zrule_equals(const ZRule* rule1, const ZRule* rule2) {
    return *(const TimeZoneRule*)rule1 == *(const TimeZoneRule*)rule2;
}

U_CAPI void U_EXPORT2
zrule_getName(ZRule* rule, UChar* name, int32_t nameLength) {
    UnicodeString s(nameLength==-1, name, nameLength);
    s = ((TimeZoneRule*)rule)->TimeZoneRule::getName(s);
    nameLength = s.length();
    memcpy(name, s.getBuffer(), nameLength);
    return;
}

U_CAPI int32_t U_EXPORT2
zrule_getRawOffset(ZRule* rule) {
    return ((TimeZoneRule*)rule)->TimeZoneRule::getRawOffset();
}

U_CAPI int32_t U_EXPORT2
zrule_getDSTSavings(ZRule* rule) {
    return ((TimeZoneRule*)rule)->TimeZoneRule::getDSTSavings();
}

U_CAPI UBool U_EXPORT2
zrule_isEquivalentTo(ZRule* rule1,  ZRule* rule2) {
    return ((TimeZoneRule*)rule1)->TimeZoneRule::isEquivalentTo(*(TimeZoneRule*)rule2);
}

/*********************************************************************
 * IZRule API
 *********************************************************************/

U_CAPI IZRule* U_EXPORT2
izrule_open(const UChar* name, int32_t nameLength, int32_t rawOffset, int32_t dstSavings) {
    UnicodeString s(nameLength==-1, name, nameLength);
    return (IZRule*) new InitialTimeZoneRule(s, rawOffset, dstSavings);
}

U_CAPI void U_EXPORT2
izrule_close(IZRule* rule) {
    delete (InitialTimeZoneRule*)rule;
}

U_CAPI IZRule* U_EXPORT2
izrule_clone(IZRule *rule) {
    return (IZRule*) (((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::clone());
}

U_CAPI UBool U_EXPORT2
izrule_equals(const IZRule* rule1, const IZRule* rule2) {
    return *(const InitialTimeZoneRule*)rule1 == *(const InitialTimeZoneRule*)rule2;
}

U_CAPI void U_EXPORT2
izrule_getName(IZRule* rule, UChar* & name, int32_t & nameLength) {
    // UnicodeString s(nameLength==-1, name, nameLength);
    UnicodeString s;
    ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getName(s);
    nameLength = s.length();
    name = (UChar*)uprv_malloc(nameLength);
    memcpy(name, s.getBuffer(), nameLength);
    return;
}

U_CAPI int32_t U_EXPORT2
izrule_getRawOffset(IZRule* rule) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getRawOffset();
}

U_CAPI int32_t U_EXPORT2
izrule_getDSTSavings(IZRule* rule) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDSTSavings();
}

U_CAPI UBool U_EXPORT2
izrule_isEquivalentTo(IZRule* rule1,  IZRule* rule2) {
    return ((InitialTimeZoneRule*)rule1)->InitialTimeZoneRule::isEquivalentTo(*(InitialTimeZoneRule*)rule2);
}

U_CAPI UBool U_EXPORT2
izrule_getFirstStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 
                    UDate& result) {
    return ((const InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFirstStart(prevRawOffset, prevDSTSavings, result);
}

U_CAPI UBool U_EXPORT2
izrule_getFinalStart(IZRule* rule, int32_t prevRawOffset, int32_t prevDSTSavings, 
                    UDate& result) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getFinalStart(prevRawOffset, prevDSTSavings, result);
}

U_CAPI UBool U_EXPORT2
izrule_getNextStart(IZRule* rule, UDate base, int32_t prevRawOffset, 
                   int32_t prevDSTSavings, UBool inclusive, UDate& result) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getNextStart(base, prevRawOffset, prevDSTSavings, inclusive, result);
}

U_CAPI UBool U_EXPORT2
izrule_getPreviousStart(IZRule* rule, UDate base, int32_t prevRawOffset, 
                       int32_t prevDSTSavings, UBool inclusive, UDate& result) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getPreviousStart(base, prevRawOffset, prevDSTSavings, inclusive, result);
}

U_CAPI UClassID U_EXPORT2
izrule_getStaticClassID(IZRule* rule) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getStaticClassID();
}

U_CAPI UClassID U_EXPORT2
izrule_getDynamicClassID(IZRule* rule) {
    return ((InitialTimeZoneRule*)rule)->InitialTimeZoneRule::getDynamicClassID();
}

#endif