Newer
Older
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
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 2001, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Id$
* $Log$
* Revision 1.10 2003/05/15 19:07:46 knoaman
* Partial implementation of the configurable memory manager.
*
* Revision 1.9 2003/05/15 16:32:19 gareth
* We did not allow dateTimes with a timezone due to the last seconds fix.
*
* Revision 1.8 2003/03/23 22:54:49 peiyongz
* invalid second values
*
* Revision 1.7 2003/02/22 22:49:09 peiyongz
* Schema Errata E2-45 24:00:00 allowed
*
* Revision 1.6 2003/02/02 23:54:43 peiyongz
* getFormattedString() added to return original and converted value.
*
* Revision 1.5 2003/01/30 21:55:22 tng
* Performance: create getRawData which is similar to toString but return the internal data directly, user is not required to delete the returned memory.
*
PeiYong Zhang
committed
* Revision 1.4 2002/11/28 20:39:27 peiyongz
* Schema Errata: E2-23 seconds part shall have at least one digit after the dot
* if it appears.
*
* Revision 1.3 2002/11/06 22:22:21 peiyongz
* Schema-Errata: E2-12: gMonth
*
* Revision 1.2 2002/11/04 15:22:05 tng
* C++ Namespace Support.
*
* Revision 1.1.1.1 2002/02/01 22:22:14 peiyongz
* sane_include
*
* Revision 1.4 2001/11/14 22:04:03 peiyongz
* Patch to apply check on Year and more rigorous on other fields as well.
*
* Revision 1.3 2001/11/12 20:36:54 peiyongz
* SchemaDateTimeException defined
*
* Revision 1.2 2001/11/09 20:41:45 peiyongz
* Fix: compilation error on Solaris and AIX.
*
* Revision 1.1 2001/11/07 19:16:03 peiyongz
* DateTime Port
*
*
*/
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include <stdlib.h>
#include <xercesc/util/XMLDateTime.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/Janitor.hpp>
//
// constants used to process raw data (fBuffer)
//
// [-]{CCYY-MM-DD}'T'{HH:MM:SS.MS}['Z']
// [{+|-}hh:mm']
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
150
static const XMLCh DURATION_STARTER = chLatin_P; // 'P'
static const XMLCh DURATION_Y = chLatin_Y; // 'Y'
static const XMLCh DURATION_M = chLatin_M; // 'M'
static const XMLCh DURATION_D = chLatin_D; // 'D'
static const XMLCh DURATION_H = chLatin_H; // 'H'
static const XMLCh DURATION_S = chLatin_S; // 'S'
static const XMLCh DATE_SEPARATOR = chDash; // '-'
static const XMLCh TIME_SEPARATOR = chColon; // ':'
static const XMLCh TIMEZONE_SEPARATOR = chColon; // ':'
static const XMLCh DATETIME_SEPARATOR = chLatin_T; // 'T'
static const XMLCh MILISECOND_SEPARATOR = chPeriod; // '.'
static const XMLCh UTC_STD_CHAR = chLatin_Z; // 'Z'
static const XMLCh UTC_POS_CHAR = chPlus; // '+'
static const XMLCh UTC_NEG_CHAR = chDash; // '-'
static const XMLCh UTC_SET[] = {UTC_STD_CHAR //"Z+-"
, UTC_POS_CHAR
, UTC_NEG_CHAR
, chNull};
static const int YMD_MIN_SIZE = 10; // CCYY-MM-DD
static const int YMONTH_MIN_SIZE = 7; // CCYY_MM
static const int TIME_MIN_SIZE = 8; // hh:mm:ss
static const int TIMEZONE_SIZE = 5; // hh:mm
static const int DAY_SIZE = 5; // ---DD
//static const int MONTH_SIZE = 6; // --MM--
//define constants to be used in assigning default values for
//all date/time excluding duration
static const int YEAR_DEFAULT = 2000;
static const int MONTH_DEFAULT = 01;
static const int DAY_DEFAULT = 15;
// order-relation on duration is a partial order. The dates below are used to
// for comparison of 2 durations, based on the fact that
// duration x and y is x<=y iff s+x<=s+y
// see 3.2.6 duration W3C schema datatype specs
//
// the dates are in format: {CCYY,MM,DD, H, S, M, MS, timezone}
static const int DATETIMES[][XMLDateTime::TOTAL_SIZE] =
{1697, 2, 1, 0, 0, 0, 0, XMLDateTime::UTC_STD},
{1903, 3, 1, 0, 0, 0, 0, XMLDateTime::UTC_STD},
{1903, 7, 1, 0, 0, 0, 0, XMLDateTime::UTC_STD}
};
// ---------------------------------------------------------------------------
// local methods
// ---------------------------------------------------------------------------
static inline int fQuotient(int a, int b)
{
div_t div_result = div(a, b);
return div_result.quot;
}
static inline int fQuotient(int temp, int low, int high)
{
return fQuotient(temp - low, high - low);
}
static inline int modulo (int temp, int low, int high)
int a = temp - low;
int b = high - low;
return (mod (a, b, fQuotient(a, b)) + low) ;
}
Loading
Loading full blame...