intl/icu/source/i18n/unicode/dtrule.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/unicode/dtrule.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,250 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +* Copyright (C) 2007-2008, International Business Machines Corporation and         *
     1.7 +* others. All Rights Reserved.                                                *
     1.8 +*******************************************************************************
     1.9 +*/
    1.10 +#ifndef DTRULE_H
    1.11 +#define DTRULE_H
    1.12 +
    1.13 +#include "unicode/utypes.h"
    1.14 +
    1.15 +/**
    1.16 + * \file 
    1.17 + * \brief C++ API: Rule for specifying date and time in an year
    1.18 + */
    1.19 +
    1.20 +#if !UCONFIG_NO_FORMATTING
    1.21 +
    1.22 +#include "unicode/uobject.h"
    1.23 +
    1.24 +U_NAMESPACE_BEGIN
    1.25 +/**
    1.26 + * <code>DateTimeRule</code> is a class representing a time in a year by
    1.27 + * a rule specified by month, day of month, day of week and
    1.28 + * time in the day.
    1.29 + * 
    1.30 + * @stable ICU 3.8
    1.31 + */
    1.32 +class U_I18N_API DateTimeRule : public UObject {
    1.33 +public:
    1.34 +
    1.35 +    /**
    1.36 +     * Date rule type constants.
    1.37 +     * @stable ICU 3.8
    1.38 +     */
    1.39 +    enum DateRuleType {
    1.40 +        DOM = 0,        /**< The exact day of month,
    1.41 +                             for example, March 11. */
    1.42 +        DOW,            /**< The Nth occurence of the day of week,
    1.43 +                             for example, 2nd Sunday in March. */
    1.44 +        DOW_GEQ_DOM,    /**< The first occurence of the day of week on or after the day of monnth,
    1.45 +                             for example, first Sunday on or after March 8. */
    1.46 +        DOW_LEQ_DOM     /**< The last occurence of the day of week on or before the day of month,
    1.47 +                             for example, first Sunday on or before March 14. */
    1.48 +    };
    1.49 +
    1.50 +    /**
    1.51 +     * Time rule type constants.
    1.52 +     * @stable ICU 3.8
    1.53 +     */
    1.54 +    enum TimeRuleType {
    1.55 +        WALL_TIME = 0,  /**< The local wall clock time */
    1.56 +        STANDARD_TIME,  /**< The local standard time */
    1.57 +        UTC_TIME        /**< The UTC time */
    1.58 +    };
    1.59 +
    1.60 +    /**
    1.61 +     * Constructs a <code>DateTimeRule</code> by the day of month and
    1.62 +     * the time rule.  The date rule type for an instance created by
    1.63 +     * this constructor is <code>DOM</code>.
    1.64 +     * 
    1.65 +     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
    1.66 +     * @param dayOfMonth    The day of month, 1-based.
    1.67 +     * @param millisInDay   The milliseconds in the rule date.
    1.68 +     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
    1.69 +     *                      or <code>UTC_TIME</code>.
    1.70 +     * @stable ICU 3.8
    1.71 +     */
    1.72 +    DateTimeRule(int32_t month, int32_t dayOfMonth,
    1.73 +        int32_t millisInDay, TimeRuleType timeType);
    1.74 +
    1.75 +    /**
    1.76 +     * Constructs a <code>DateTimeRule</code> by the day of week and its oridinal
    1.77 +     * number and the time rule.  The date rule type for an instance created
    1.78 +     * by this constructor is <code>DOW</code>.
    1.79 +     * 
    1.80 +     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>.
    1.81 +     * @param weekInMonth   The ordinal number of the day of week.  Negative number
    1.82 +     *                      may be used for specifying a rule date counted from the
    1.83 +     *                      end of the rule month.
    1.84 +     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
    1.85 +     * @param millisInDay   The milliseconds in the rule date.
    1.86 +     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
    1.87 +     *                      or <code>UTC_TIME</code>.
    1.88 +     * @stable ICU 3.8
    1.89 +     */
    1.90 +    DateTimeRule(int32_t month, int32_t weekInMonth, int32_t dayOfWeek,
    1.91 +        int32_t millisInDay, TimeRuleType timeType);
    1.92 +
    1.93 +    /**
    1.94 +     * Constructs a <code>DateTimeRule</code> by the first/last day of week
    1.95 +     * on or after/before the day of month and the time rule.  The date rule
    1.96 +     * type for an instance created by this constructor is either
    1.97 +     * <code>DOM_GEQ_DOM</code> or <code>DOM_LEQ_DOM</code>.
    1.98 +     * 
    1.99 +     * @param month         The rule month, for example, <code>Calendar::JANUARY</code>
   1.100 +     * @param dayOfMonth    The day of month, 1-based.
   1.101 +     * @param dayOfWeek     The day of week, for example, <code>Calendar::SUNDAY</code>.
   1.102 +     * @param after         true if the rule date is on or after the day of month.
   1.103 +     * @param millisInDay   The milliseconds in the rule date.
   1.104 +     * @param timeType      The time type, <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
   1.105 +     *                      or <code>UTC_TIME</code>.
   1.106 +     * @stable ICU 3.8
   1.107 +     */
   1.108 +    DateTimeRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, UBool after,
   1.109 +        int32_t millisInDay, TimeRuleType timeType);
   1.110 +
   1.111 +    /**
   1.112 +     * Copy constructor.
   1.113 +     * @param source    The DateTimeRule object to be copied.
   1.114 +     * @stable ICU 3.8
   1.115 +     */
   1.116 +    DateTimeRule(const DateTimeRule& source);
   1.117 +
   1.118 +    /**
   1.119 +     * Destructor.
   1.120 +     * @stable ICU 3.8
   1.121 +     */
   1.122 +    ~DateTimeRule();
   1.123 +
   1.124 +    /**
   1.125 +     * Clone this DateTimeRule object polymorphically. The caller owns the result and
   1.126 +     * should delete it when done.
   1.127 +     * @return    A copy of the object.
   1.128 +     * @stable ICU 3.8
   1.129 +     */
   1.130 +    DateTimeRule* clone(void) const;
   1.131 +
   1.132 +    /**
   1.133 +     * Assignment operator.
   1.134 +     * @param right The object to be copied.
   1.135 +     * @stable ICU 3.8
   1.136 +     */
   1.137 +    DateTimeRule& operator=(const DateTimeRule& right);
   1.138 +
   1.139 +    /**
   1.140 +     * Return true if the given DateTimeRule objects are semantically equal. Objects
   1.141 +     * of different subclasses are considered unequal.
   1.142 +     * @param that  The object to be compared with.
   1.143 +     * @return  true if the given DateTimeRule objects are semantically equal.
   1.144 +     * @stable ICU 3.8
   1.145 +     */
   1.146 +    UBool operator==(const DateTimeRule& that) const;
   1.147 +
   1.148 +    /**
   1.149 +     * Return true if the given DateTimeRule objects are semantically unequal. Objects
   1.150 +     * of different subclasses are considered unequal.
   1.151 +     * @param that  The object to be compared with.
   1.152 +     * @return  true if the given DateTimeRule objects are semantically unequal.
   1.153 +     * @stable ICU 3.8
   1.154 +     */
   1.155 +    UBool operator!=(const DateTimeRule& that) const;
   1.156 +
   1.157 +    /**
   1.158 +     * Gets the date rule type, such as <code>DOM</code>
   1.159 +     * @return The date rule type.
   1.160 +     * @stable ICU 3.8
   1.161 +     */
   1.162 +    DateRuleType getDateRuleType(void) const;
   1.163 +
   1.164 +    /**
   1.165 +     * Gets the time rule type
   1.166 +     * @return The time rule type, either <code>WALL_TIME</code> or <code>STANDARD_TIME</code>
   1.167 +     *         or <code>UTC_TIME</code>.
   1.168 +     * @stable ICU 3.8
   1.169 +     */
   1.170 +    TimeRuleType getTimeRuleType(void) const;
   1.171 +
   1.172 +    /**
   1.173 +     * Gets the rule month.
   1.174 +     * @return The rule month.
   1.175 +     * @stable ICU 3.8
   1.176 +     */
   1.177 +    int32_t getRuleMonth(void) const;
   1.178 +
   1.179 +    /**
   1.180 +     * Gets the rule day of month.  When the date rule type
   1.181 +     * is <code>DOW</code>, the value is always 0.
   1.182 +     * @return The rule day of month
   1.183 +     * @stable ICU 3.8
   1.184 +     */
   1.185 +    int32_t getRuleDayOfMonth(void) const;
   1.186 +
   1.187 +    /**
   1.188 +     * Gets the rule day of week.  When the date rule type
   1.189 +     * is <code>DOM</code>, the value is always 0.
   1.190 +     * @return The rule day of week.
   1.191 +     * @stable ICU 3.8
   1.192 +     */
   1.193 +    int32_t getRuleDayOfWeek(void) const;
   1.194 +
   1.195 +    /**
   1.196 +     * Gets the ordinal number of the occurence of the day of week
   1.197 +     * in the month.  When the date rule type is not <code>DOW</code>,
   1.198 +     * the value is always 0.
   1.199 +     * @return The rule day of week ordinal number in the month.
   1.200 +     * @stable ICU 3.8
   1.201 +     */
   1.202 +    int32_t getRuleWeekInMonth(void) const;
   1.203 +
   1.204 +    /**
   1.205 +     * Gets the rule time in the rule day.
   1.206 +     * @return The time in the rule day in milliseconds.
   1.207 +     * @stable ICU 3.8
   1.208 +     */
   1.209 +    int32_t getRuleMillisInDay(void) const;
   1.210 +
   1.211 +private:
   1.212 +    int32_t fMonth;
   1.213 +    int32_t fDayOfMonth;
   1.214 +    int32_t fDayOfWeek;
   1.215 +    int32_t fWeekInMonth;
   1.216 +    int32_t fMillisInDay;
   1.217 +    DateRuleType fDateRuleType;
   1.218 +    TimeRuleType fTimeRuleType;
   1.219 +
   1.220 +public:
   1.221 +    /**
   1.222 +     * Return the class ID for this class. This is useful only for comparing to
   1.223 +     * a return value from getDynamicClassID(). For example:
   1.224 +     * <pre>
   1.225 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
   1.226 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
   1.227 +     * .       erived::getStaticClassID()) ...
   1.228 +     * </pre>
   1.229 +     * @return          The class ID for all objects of this class.
   1.230 +     * @stable ICU 3.8
   1.231 +     */
   1.232 +    static UClassID U_EXPORT2 getStaticClassID(void);
   1.233 +
   1.234 +    /**
   1.235 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.236 +     * method is to implement a simple version of RTTI, since not all C++
   1.237 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.238 +     * methods call this method.
   1.239 +     *
   1.240 +     * @return          The class ID for this object. All objects of a
   1.241 +     *                  given class have the same class ID.  Objects of
   1.242 +     *                  other classes have different class IDs.
   1.243 +     * @stable ICU 3.8
   1.244 +     */
   1.245 +    virtual UClassID getDynamicClassID(void) const;
   1.246 +};
   1.247 +
   1.248 +U_NAMESPACE_END
   1.249 +
   1.250 +#endif /* #if !UCONFIG_NO_FORMATTING */
   1.251 +
   1.252 +#endif // DTRULE_H
   1.253 +//eof

mercurial