intl/icu/source/i18n/windtfmt.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/i18n/windtfmt.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,140 @@
     1.4 +/*
     1.5 +********************************************************************************
     1.6 +*   Copyright (C) 2005-2013, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +********************************************************************************
     1.9 +*
    1.10 +* File WINDTFMT.H
    1.11 +*
    1.12 +********************************************************************************
    1.13 +*/
    1.14 +
    1.15 +#ifndef __WINDTFMT
    1.16 +#define __WINDTFMT
    1.17 +
    1.18 +#include "unicode/utypes.h"
    1.19 +
    1.20 +#if U_PLATFORM_HAS_WIN32_API
    1.21 +
    1.22 +#if !UCONFIG_NO_FORMATTING
    1.23 +
    1.24 +#include "unicode/format.h"
    1.25 +#include "unicode/datefmt.h"
    1.26 +#include "unicode/calendar.h"
    1.27 +#include "unicode/ustring.h"
    1.28 +#include "unicode/locid.h"
    1.29 +
    1.30 +/**
    1.31 + * \file 
    1.32 + * \brief C++ API: Format dates using Windows API.
    1.33 + */
    1.34 +
    1.35 +U_CDECL_BEGIN
    1.36 +// Forward declarations for Windows types...
    1.37 +typedef struct _SYSTEMTIME SYSTEMTIME;
    1.38 +typedef struct _TIME_ZONE_INFORMATION TIME_ZONE_INFORMATION;
    1.39 +U_CDECL_END
    1.40 +
    1.41 +U_NAMESPACE_BEGIN
    1.42 +
    1.43 +class Win32DateFormat : public DateFormat
    1.44 +{
    1.45 +public:
    1.46 +    Win32DateFormat(DateFormat::EStyle timeStyle, DateFormat::EStyle dateStyle, const Locale &locale, UErrorCode &status);
    1.47 +
    1.48 +    Win32DateFormat(const Win32DateFormat &other);
    1.49 +
    1.50 +    virtual ~Win32DateFormat();
    1.51 +
    1.52 +    virtual Format *clone(void) const;
    1.53 +
    1.54 +    Win32DateFormat &operator=(const Win32DateFormat &other);
    1.55 +
    1.56 +    UnicodeString &format(Calendar &cal, UnicodeString &appendTo, FieldPosition &pos) const;
    1.57 +
    1.58 +    UnicodeString& format(UDate date, UnicodeString& appendTo) const;
    1.59 +
    1.60 +    void parse(const UnicodeString& text, Calendar& cal, ParsePosition& pos) const;
    1.61 +
    1.62 +    /**
    1.63 +     * Set the calendar to be used by this date format. Initially, the default
    1.64 +     * calendar for the specified or default locale is used.  The caller should
    1.65 +     * not delete the Calendar object after it is adopted by this call.
    1.66 +     *
    1.67 +     * @param calendarToAdopt    Calendar object to be adopted.
    1.68 +     */
    1.69 +    virtual void adoptCalendar(Calendar* calendarToAdopt);
    1.70 +
    1.71 +    /**
    1.72 +     * Set the calendar to be used by this date format. Initially, the default
    1.73 +     * calendar for the specified or default locale is used.
    1.74 +     *
    1.75 +     * @param newCalendar Calendar object to be set.
    1.76 +     */
    1.77 +    virtual void setCalendar(const Calendar& newCalendar);
    1.78 +
    1.79 +    /**
    1.80 +     * Sets the time zone for the calendar of this DateFormat object. The caller
    1.81 +     * no longer owns the TimeZone object and should not delete it after this call.
    1.82 +     *
    1.83 +     * @param zoneToAdopt the TimeZone to be adopted.
    1.84 +     */
    1.85 +    virtual void adoptTimeZone(TimeZone* zoneToAdopt);
    1.86 +
    1.87 +    /**
    1.88 +     * Sets the time zone for the calendar of this DateFormat object.
    1.89 +     * @param zone the new time zone.
    1.90 +     */
    1.91 +    virtual void setTimeZone(const TimeZone& zone);
    1.92 +
    1.93 +    /**
    1.94 +     * Return the class ID for this class. This is useful only for comparing to
    1.95 +     * a return value from getDynamicClassID(). For example:
    1.96 +     * <pre>
    1.97 +     * .   Base* polymorphic_pointer = createPolymorphicObject();
    1.98 +     * .   if (polymorphic_pointer->getDynamicClassID() ==
    1.99 +     * .       erived::getStaticClassID()) ...
   1.100 +     * </pre>
   1.101 +     * @return          The class ID for all objects of this class.
   1.102 +     */
   1.103 +    U_I18N_API static UClassID U_EXPORT2 getStaticClassID(void);
   1.104 +
   1.105 +    /**
   1.106 +     * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
   1.107 +     * method is to implement a simple version of RTTI, since not all C++
   1.108 +     * compilers support genuine RTTI. Polymorphic operator==() and clone()
   1.109 +     * methods call this method.
   1.110 +     *
   1.111 +     * @return          The class ID for this object. All objects of a
   1.112 +     *                  given class have the same class ID.  Objects of
   1.113 +     *                  other classes have different class IDs.
   1.114 +     */
   1.115 +    virtual UClassID getDynamicClassID(void) const;
   1.116 +
   1.117 +private:
   1.118 +    void formatDate(const SYSTEMTIME *st, UnicodeString &appendTo) const;
   1.119 +    void formatTime(const SYSTEMTIME *st, UnicodeString &appendTo) const;
   1.120 +
   1.121 +    UnicodeString setTimeZoneInfo(TIME_ZONE_INFORMATION *tzi, const TimeZone &zone) const;
   1.122 +    UnicodeString* getTimeDateFormat(const Calendar *cal, const Locale *locale, UErrorCode &status) const;
   1.123 +
   1.124 +    UnicodeString *fDateTimeMsg;
   1.125 +    DateFormat::EStyle fTimeStyle;
   1.126 +    DateFormat::EStyle fDateStyle;
   1.127 +    Locale fLocale;
   1.128 +    int32_t fLCID;
   1.129 +    UnicodeString fZoneID;
   1.130 +    TIME_ZONE_INFORMATION *fTZI;
   1.131 +};
   1.132 +
   1.133 +inline UnicodeString &Win32DateFormat::format(UDate date, UnicodeString& appendTo) const {
   1.134 +    return DateFormat::format(date, appendTo);
   1.135 +}
   1.136 +
   1.137 +U_NAMESPACE_END
   1.138 +
   1.139 +#endif /* #if !UCONFIG_NO_FORMATTING */
   1.140 +
   1.141 +#endif // U_PLATFORM_HAS_WIN32_API
   1.142 +
   1.143 +#endif // __WINDTFMT

mercurial