home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 79 / IOPROG_79.ISO / soft / Tools / XMLSPYEnt2004 / XMLSPYEntComplete2004.exe / Data1.cab / _0EE41CE902F048D0A79AD490C429378D < prev    next >
Encoding:
Text File  |  2003-10-17  |  41.3 KB  |  1,369 lines

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // SchemaTypes.h
  4. //
  5. // This file was generated by [=$Host].
  6. //
  7. // YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
  8. // OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
  9. //
  10. // Refer to the [=$HostShort] Documentation for further details.
  11. // [=$HostURL]
  12. //
  13. ////////////////////////////////////////////////////////////////////////
  14.  
  15.  
  16. #ifndef ALTOVA_SCHEMATYPES_H_INCLUDED
  17. #define ALTOVA_SCHEMATYPES_H_INCLUDED
  18.  
  19. #if _MSC_VER > 1000
  20.     #pragma once
  21. #endif // _MSC_VER > 1000
  22.  
  23. namespace altova {
  24.  
  25.  
  26. #ifndef _USRDLL
  27.     #define ALTOVA_DECLSPECIFIER
  28. #else
  29.     #ifdef ALTOVA_EXPORTS
  30.         #define ALTOVA_DECLSPECIFIER __declspec(dllexport)
  31.         #define ALTOVA_EXPIMP_TEMPLATE
  32.     #else
  33.         #define ALTOVA_DECLSPECIFIER __declspec(dllimport)
  34.         #define ALTOVA_EXPIMP_TEMPLATE extern
  35.     #endif
  36.  
  37.     #ifndef _MFC_VER
  38.         #pragma warning(disable: 4660)
  39.         #pragma warning(disable: 4231)
  40.         #pragma warning(disable: 4251)
  41.     #endif
  42. #endif
  43.  
  44.  
  45. #if defined(UNICODE) || defined(_UNICODE)
  46.     #define tstring        std::wstring
  47.     #define tcin        std::wcin
  48.     #define tcout        std::wcout
  49.     #define tcerr        std::wcerr
  50.     #define tclog        std::wclog
  51.     #define tostream    std::wostream
  52. #else
  53.     #define tstring        std::string
  54.     #define tcin        std::cin
  55.     #define tcout        std::cout
  56.     #define tcerr        std::cerr
  57.     #define tclog        std::clog
  58.     #define tostream    std::ostream
  59. #endif
  60.  
  61.  
  62. #ifdef _XERCES_VERSION
  63.  
  64.     #if defined(UNICODE) || defined(_UNICODE)
  65.         #define XC2TS(x) x
  66.     #else
  67.         #define XC2TS(x) StrX(x).localForm()
  68.     #endif
  69.  
  70.     class XStr
  71.     {
  72.     public:
  73.         XStr(const char* const toTranscode) { m_bClone = true; fUnicodeForm = xercesc::XMLString::transcode(toTranscode); }
  74.         XStr(const std::string& toTranscode) { m_bClone = true; fUnicodeForm = xercesc::XMLString::transcode(toTranscode.c_str()); }
  75.         XStr(const wchar_t* const toTranscode) { m_bClone = false; fUnicodeForm = (XMLCh*)toTranscode; }
  76.         XStr(const std::wstring& toTranscode) { m_bClone = false; fUnicodeForm = (XMLCh*)(toTranscode.c_str()); }
  77.         ~XStr() { if (m_bClone && fUnicodeForm) xercesc::XMLString::release(&fUnicodeForm); }
  78.         const XMLCh* unicodeForm() const { return fUnicodeForm; }
  79.     protected:
  80.         bool m_bClone;
  81.         XMLCh* fUnicodeForm;
  82.     };
  83.  
  84.     #define X(str) XStr(str).unicodeForm()
  85.  
  86.     class StrX
  87.     {
  88.     public:
  89.         StrX(const XMLCh* const toTranscode) { fLocalForm = xercesc::XMLString::transcode(toTranscode); }
  90.         ~StrX() { xercesc::XMLString::release(&fLocalForm); }
  91.         const char* localForm() const { return fLocalForm; }
  92.     protected:
  93.         char* fLocalForm;
  94.     };
  95.  
  96. #endif
  97. #ifdef _MFC_VER
  98.     inline tostream& operator<<(tostream& out, const CString& sText)
  99.     {
  100.         return tcout << (LPCTSTR)sText;
  101.     }
  102. #endif // _MFC_VER
  103.  
  104.  
  105. ////////////////////////////////////////////////////////////////////////
  106. //
  107. //  Utility functions and templates
  108. //
  109. ////////////////////////////////////////////////////////////////////////
  110.  
  111. template<typename TValue>
  112. TValue InRangeInt(TValue nValue, __int64 nMin, __int64 nMax)
  113. {
  114.     if( nValue < nMin || nValue > nMax )
  115.         throw new CAltovaException(CAltovaException::eError1, _T("Out of range!"));
  116.     return nValue;
  117. }
  118.  
  119.  
  120. template<typename TValue>
  121. TValue InRangeDbl(TValue nValue, const double nPosMin, const double nPosMax)
  122. {
  123.     TValue nTmpValue = nValue;
  124.     if( nTmpValue == 0 )
  125.         return nValue;
  126.     if( nTmpValue < 0 )
  127.         nTmpValue = -nTmpValue;
  128.     if( nTmpValue >= nPosMin  &&  nTmpValue <= nPosMax )
  129.         return nValue;
  130.     throw new CAltovaException(CAltovaException::eError1, _T("Out of range!"));
  131. }
  132.  
  133. ////////////////////////////////////////////////////////////////////////
  134. //
  135. //  CBaseObject
  136. //
  137. ////////////////////////////////////////////////////////////////////////
  138.  
  139.  
  140. class ALTOVA_DECLSPECIFIER CBaseObject
  141. {
  142. };
  143.  
  144.  
  145. ////////////////////////////////////////////////////////////////////////
  146. //
  147. //  CSchemaType
  148. //
  149. ////////////////////////////////////////////////////////////////////////
  150.  
  151.  
  152.  
  153. class ALTOVA_DECLSPECIFIER CSchemaType : public CBaseObject
  154. {
  155. public:
  156.     typedef enum {
  157.         // numeric types
  158.         k_bool,
  159.         k_byte,
  160.         k_unsigned_byte,
  161.         k_short,
  162.         k_unsigned_short,
  163.         k_int,
  164.         k_unsigned_int,
  165.         k_long,
  166.         k_unsigned_long,
  167.         k_float,
  168.         k_double,
  169.         k_decimal,
  170.         // calendar types
  171.         k_Duration,
  172.         k_Time,
  173.         k_Day,
  174.         k_Month,
  175.         k_MonthDay,
  176.         k_Year,
  177.         k_YearMonth,
  178.         k_Date,
  179.         k_DateTime,
  180.         // else
  181.         k_String,
  182.         k_Base64Binary,
  183.         k_HexBinary,
  184.         // ----------
  185.         k_count,
  186.         k_unknown = -1
  187.     } ETypes ;
  188.  
  189.     CSchemaType(const bool isEmpty = true) : m_bIsEmpty( isEmpty ) {};
  190.  
  191.     enum { TYPE = k_unknown };
  192.  
  193.     virtual operator tstring() const = 0;
  194. [if $mfc]
  195.     virtual operator CString() { return operator tstring().c_str(); }
  196. [endif]
  197.     virtual bool ToBool() const = 0;    // like XPATH function boolean()
  198.  
  199.     virtual void Empty()    { m_bIsEmpty = true; }
  200.     virtual void Parse(const TCHAR* szValue) = 0;
  201.     virtual CSchemaType& Assign(const CSchemaType& rOther) = 0;
  202.  
  203.     bool    IsEmpty() const { return m_bIsEmpty; }
  204.  
  205.     enum {
  206.         WHITESPACE_PRESERVE,
  207.         WHITESPACE_REPLACE,
  208.         WHITESPACE_COLLAPSE
  209.     };
  210.  
  211.     static bool    CompareEqual(const CSchemaType& rObj1, const CSchemaType& rObj2);
  212.     static bool    CompareLess(const CSchemaType& rObj1, const CSchemaType& rObj2);
  213.  
  214.     static bool CompareNotEqual(const CSchemaType& rObj1, const CSchemaType& rObj2)    { return !CompareEqual(rObj1, rObj2); }
  215.     static bool CompareGreater(const CSchemaType& rObj1, const CSchemaType& rObj2)    { return CompareLess(rObj2, rObj1); }
  216.     static bool CompareLessEqual(const CSchemaType& rObj1, const CSchemaType& rObj2)    { return CompareLess(rObj1, rObj2) || CompareEqual(rObj1, rObj2); }
  217.     static bool CompareGreaterEqual(const CSchemaType& rObj1, const CSchemaType& rObj2)    { return CompareLess(rObj2, rObj1) || CompareEqual(rObj1, rObj2); }
  218.  
  219. protected:
  220.     bool    m_bIsEmpty;
  221. };
  222.  
  223.  
  224. inline tostream& operator<<(tostream& os, CSchemaType& t)
  225. {
  226.     return os << ((tstring)t).c_str();
  227. }
  228.  
  229.  
  230. ////////////////////////////////////////////////////////////////////////
  231. //
  232. //  CSchemaTypeNumber
  233. //
  234. ////////////////////////////////////////////////////////////////////////
  235.  
  236. class ALTOVA_DECLSPECIFIER CSchemaTypeNumber
  237. {
  238. public:
  239.     CSchemaTypeNumber() {};
  240.  
  241.     // architecture used is min. 32-bit so all smaller datatypes are omitted for calculation purposes
  242.     // Note: unsigned datatypes have to be casted explicitly
  243.     virtual long        ToLong() const = 0;        // 32 Bit integer
  244.     virtual __int64        ToInt64() const = 0;    // 64 Bit integer
  245.     virtual float        ToFloat() const = 0;    // 32 Bit floating-point
  246.     virtual double        ToDouble() const = 0;    // 64 Bit floating-point
  247.  
  248.     virtual CSchemaType::ETypes NumericType() const = 0;
  249.     static TCHAR* GetFormatString(CSchemaType::ETypes eType)
  250.     {
  251.         switch( eType )
  252.         {
  253.         case CSchemaType::k_byte:            return    _T("%hi");
  254.         case CSchemaType::k_unsigned_byte:    return    _T("%hu");
  255.         case CSchemaType::k_short:            return    _T("%hi");
  256.         case CSchemaType::k_unsigned_short:    return    _T("%hu");
  257.         case CSchemaType::k_int:            return    _T("%li");
  258.         case CSchemaType::k_unsigned_int:    return    _T("%lu");
  259.         case CSchemaType::k_long:            return    _T("%I64i");
  260.         case CSchemaType::k_unsigned_long:    return    _T("%I64u");
  261.         case CSchemaType::k_float:            return    _T("%G");
  262.         case CSchemaType::k_double:            return    _T("%lG");
  263.         case CSchemaType::k_decimal:        return    _T("%f");
  264.         }
  265.         return _T("");
  266.     }
  267.  
  268. };
  269.  
  270.  
  271. //    calctype and ToCalcType() below are used for numerical operations with
  272. //  CSchema... types (containing a value possible to be represented as number)
  273. //  All numerical calculation functions access the value via ToCalcType().
  274. //    Calculation-type is minimum 32 Bit (because we've 32 Bit processors) and
  275. //    must be always signed (for unsigned use the next bigger type).
  276.  
  277. ////////////////////////////////////////////////////////////////////////
  278. //
  279. //  template CSchemaNumber<..>
  280. //
  281. ////////////////////////////////////////////////////////////////////////
  282.  
  283.  
  284. template <typename TValue, typename TCalcValue, CSchemaType::ETypes eNumericType[if $DBLibraryCount > 0], typename TVariant[endif]> 
  285. class CSchemaNumber : public CSchemaTypeNumber, public CSchemaType
  286. {
  287. public:
  288.     CSchemaNumber() : m_Value(0) {};
  289.     CSchemaNumber(const TValue value) : CSchemaType( false ), m_Value(value) {};
  290.     CSchemaNumber(const TCHAR* szValue) { Parse(szValue); }
  291.     CSchemaNumber(const CSchemaType& rOther) { *this = rOther; }
  292. [if $DBLibraryCount > 0]
  293.     CSchemaNumber(const _variant_t& vValue) : CSchemaType(false), m_Value(0)
  294.     {
  295.         if( vValue.vt == VT_NULL || vValue.vt == VT_EMPTY )
  296.             return ;
  297.         m_Value = (TVariant)vValue;
  298.     }
  299.     virtual operator _variant_t() const 
  300.     { 
  301.         if( m_bIsEmpty )
  302.             return _variant_t();
  303.         return (TVariant)m_Value; 
  304.     }
  305. [endif]
  306.     enum { TYPE = eNumericType };
  307.  
  308.     virtual operator TValue() const            { return m_bIsEmpty ? (TValue)0    : m_Value; }
  309.     virtual CSchemaNumber& operator=(const TValue nValue)    { m_bIsEmpty = false; m_Value = nValue; return *this; }
  310.     virtual CSchemaNumber& operator=(const CSchemaType& rOther)    { return (CSchemaNumber&)Assign(rOther); }
  311.  
  312.     TCalcValue ToCalcValue() const { return (TCalcValue)m_Value; }
  313.  
  314.     // from CSchemaType
  315.     virtual bool ToBool() const            { return m_bIsEmpty ? (bool)0    : m_Value != 0; }
  316.     virtual operator tstring() const        
  317.     { 
  318.         if( m_bIsEmpty )
  319.             return _T("");
  320.         TCHAR szValue\[32\];
  321.         _sntprintf(szValue, 32, GetFormatString(eNumericType), m_Value);
  322.         return szValue;
  323.     }
  324.  
  325.     void    Empty() { m_Value = 0; m_bIsEmpty = 1; }
  326.     virtual void Parse(const TCHAR* szValue)
  327.     {
  328.         if( szValue\[0\] == 0 )
  329.         {
  330.             Empty();
  331.             return;
  332.         }
  333.         m_bIsEmpty = false;
  334.         InternalParse( szValue );
  335.     }
  336.     virtual CSchemaType& Assign(const CSchemaType& rOther )
  337.     {
  338.         Empty();
  339.         const CSchemaTypeNumber* pNumberType = dynamic_cast<const CSchemaTypeNumber*>(&rOther);
  340.         if( pNumberType == NULL )
  341.             throw CAltovaException(CAltovaException::eError1, _T("Types incompatible!"));
  342.         m_bIsEmpty = rOther.IsEmpty();
  343.         switch( TYPE )
  344.         {
  345.         case CSchemaType::k_float:            m_Value = (TValue)pNumberType->ToFloat();    break;
  346.         case CSchemaType::k_double:
  347.         case CSchemaType::k_decimal:        m_Value = (TValue)pNumberType->ToDouble();    break;
  348.         case CSchemaType::k_long:
  349.         case CSchemaType::k_unsigned_long:    m_Value = (TValue)pNumberType->ToInt64();    break;
  350.         default:
  351.             m_Value = (TValue)pNumberType->ToLong();
  352.         }
  353.         return *this;
  354.     }
  355.  
  356.     // from CSchemaTypeNumber
  357.     virtual ETypes    NumericType() const    { return (CSchemaType::ETypes)TYPE; }
  358.     virtual long    ToLong() const        { return m_bIsEmpty ? (long)0    : InRangeInt<long>((long)m_Value, LONG_MIN, LONG_MAX); }
  359.     virtual __int64 ToInt64() const        { return m_bIsEmpty ? (__int64)0: InRangeInt<__int64>((__int64)m_Value, _I64_MIN, _I64_MAX); }
  360.     virtual float    ToFloat() const        { return m_bIsEmpty ? (float)0    : InRangeDbl<float>((float)m_Value, 3.4E-38, 3.4E+38); }
  361.     virtual double    ToDouble() const    { return m_bIsEmpty ? (double)0    : InRangeDbl<double>((double)m_Value, 1.7E-308, 1.7E+308); }
  362.  
  363.     typedef TValue basetype;
  364.     typedef TCalcValue    calctype;
  365. protected:
  366.     TValue m_Value;
  367.  
  368.     void    InternalParse(const TCHAR* szValue)
  369.     {
  370.         m_Value = _ttoi(szValue);
  371.     }
  372. };
  373.  
  374.  
  375. ////////////////////////////////////////////////////////////////////////
  376. //
  377. //  CSchemaByte
  378. //    CSchemaUnsignedByte
  379. //    CSchemaShort
  380. //    CSchemaUnsignedShort
  381. //    CSchemaInt
  382. //    CSchemaUnsignedInt
  383. //    CSchemaLong
  384. //    CSchemaUnsignedLong
  385. //    CSchemaFloat
  386. //    CSchemaDouble
  387. //    CSchemaDecimal
  388. //
  389. //    CSchemaInteger
  390. //    CSchemaNegativeInteger
  391. //    CSchemaPositiveInteger
  392. //    CSchemaNonPositiveInteger
  393. //
  394. ////////////////////////////////////////////////////////////////////////
  395.  
  396.  
  397. typedef CSchemaNumber<char,                long,    CSchemaType::k_byte                [if $DBLibraryCount > 0], short[endif]>    CSchemaByte;
  398. typedef CSchemaNumber<unsigned char,    long,    CSchemaType::k_unsigned_byte    [if $DBLibraryCount > 0], BYTE[endif]>    CSchemaUnsignedByte;
  399. typedef CSchemaNumber<short,            long,    CSchemaType::k_short            [if $DBLibraryCount > 0], short[endif]>    CSchemaShort;
  400. typedef CSchemaNumber<unsigned short,    long,    CSchemaType::k_unsigned_short    [if $DBLibraryCount > 0], long[endif]>    CSchemaUnsignedShort;
  401. typedef CSchemaNumber<long,                long,    CSchemaType::k_int                [if $DBLibraryCount > 0], long[endif]>    CSchemaInt;    
  402. typedef CSchemaNumber<unsigned long,    __int64,CSchemaType::k_unsigned_int        [if $DBLibraryCount > 0], long[endif]>    CSchemaUnsignedInt;
  403. typedef CSchemaNumber<__int64,            __int64,CSchemaType::k_long                [if $DBLibraryCount > 0], long[endif]>    CSchemaLong;
  404. typedef CSchemaNumber<unsigned __int64,    __int64,CSchemaType::k_unsigned_long    [if $DBLibraryCount > 0], long[endif]>    CSchemaUnsignedLong;
  405. typedef CSchemaNumber<float,            float,    CSchemaType::k_float            [if $DBLibraryCount > 0], float[endif]>    CSchemaFloat;
  406. typedef CSchemaNumber<double,            double,    CSchemaType::k_double            [if $DBLibraryCount > 0], double[endif]>    CSchemaDouble;
  407. typedef CSchemaNumber<double,            double,    CSchemaType::k_decimal            [if $DBLibraryCount > 0], double[endif]>    CSchemaDecimal;
  408.  
  409. typedef CSchemaLong        CSchemaInteger;
  410. typedef CSchemaInteger    CSchemaNegativeInteger;
  411. typedef CSchemaInteger    CSchemaNonNegativeInteger;
  412. typedef CSchemaInteger    CSchemaPositiveInteger;
  413. typedef CSchemaInteger    CSchemaNonPositiveInteger;
  414.  
  415.  
  416. template<> 
  417. float CSchemaUnsignedLong::ToFloat() const
  418. {
  419.     return m_bIsEmpty ? (float)0.0    : InRangeDbl<float>((float)InRangeInt<__int64>(m_Value, _I64_MIN, _I64_MAX), 3.4E-38, 3.4E+38); 
  420. }
  421.  
  422. template<>
  423. double CSchemaUnsignedLong::ToDouble() const
  424. {
  425.     return m_bIsEmpty ? (double)0.0    : InRangeDbl<double>((double)InRangeInt<__int64>(m_Value, _I64_MIN, _I64_MAX), 1.7E-308, 1.7E+308);     
  426. }
  427.  
  428.  
  429. template<>
  430. void CSchemaInt::InternalParse(const TCHAR* szValue)
  431. {
  432.     m_Value = _ttol(szValue);
  433. }
  434.  
  435. template<>
  436. void CSchemaUnsignedInt::InternalParse(const TCHAR* szValue)
  437. {
  438.     m_Value = _ttol(szValue);
  439. }
  440.  
  441. template<>
  442. void CSchemaLong::InternalParse(const TCHAR* szValue)
  443. {
  444.     m_Value = _ttoi64(szValue);
  445. }
  446.  
  447. template<>
  448. void CSchemaUnsignedLong::InternalParse(const TCHAR* szValue)
  449. {
  450.     m_Value = _ttoi64(szValue);
  451. }
  452.  
  453. template<>
  454. void CSchemaFloat::InternalParse(const TCHAR* szValue)
  455. {
  456.     TCHAR* endptr;
  457.     m_Value = (float)_tcstod(szValue, &endptr);
  458. }
  459.  
  460. template<>
  461. void CSchemaDouble::InternalParse(const TCHAR* szValue)
  462. {
  463.     TCHAR* endptr;
  464.     m_Value = _tcstod(szValue, &endptr);
  465. }
  466.  
  467. template<>
  468. void CSchemaDecimal::InternalParse(const TCHAR* szValue)
  469. {
  470.     TCHAR* endptr;
  471.     m_Value = _tcstod(szValue, &endptr);
  472. }
  473.  
  474. ////////////////////////////////////////////////////////////////////////
  475. //
  476. //  CSchemaBoolean
  477. //
  478. ////////////////////////////////////////////////////////////////////////
  479.  
  480.  
  481. class ALTOVA_DECLSPECIFIER CSchemaBoolean : public CSchemaTypeNumber, public CSchemaType
  482. {
  483. public:
  484.     CSchemaBoolean() : m_Value(false) {};
  485.     CSchemaBoolean(const bool value) : CSchemaType( false ), m_Value(value) {};
  486.     CSchemaBoolean(const long value) : CSchemaType( false ), m_Value(value!=0) {};
  487.     CSchemaBoolean(const TCHAR* szValue) { Parse(szValue); }
  488.     CSchemaBoolean(const CSchemaType& rOther) { *this = rOther; }
  489. [if $DBLibraryCount > 0]
  490.     CSchemaBoolean(const _variant_t& vValue) : CSchemaType(false), m_Value(false) 
  491.     {
  492.         if( vValue.vt == VT_NULL  ||  vValue.vt == VT_EMPTY )
  493.             return;
  494.         m_Value = vValue;
  495.     }
  496.     virtual operator _variant_t() const 
  497.     { 
  498.         if( m_bIsEmpty )
  499.             return _variant_t();
  500.         return m_Value; 
  501.     }
  502. [endif]
  503.     enum { TYPE = CSchemaType::k_bool };
  504.  
  505.     virtual operator bool() const            { return m_bIsEmpty ? false    : m_Value; }
  506.     long    ToCalcValue() const                { return ToLong(); }
  507.     virtual CSchemaBoolean& operator=(const bool bValue)    { m_bIsEmpty = false; m_Value = bValue; return *this; }    
  508.     virtual CSchemaBoolean& operator=(const CSchemaType& rOther)    { return (CSchemaBoolean&)Assign(rOther); }
  509.  
  510.     // from CSchemaType
  511.     virtual operator tstring() const;
  512.     virtual bool ToBool() const                { return m_bIsEmpty ? false    : m_Value; }
  513.  
  514.     void    Empty()        { m_Value = false; m_bIsEmpty = true; }
  515.     virtual void Parse(const TCHAR* szValue);
  516.     virtual CSchemaType& Assign(const CSchemaType& rOther )                
  517.     { 
  518.         m_bIsEmpty = ((CSchemaType&)rOther).IsEmpty(); 
  519.         m_Value = rOther.ToBool();    
  520.         return *this;
  521.     }
  522.  
  523.     // from CSchemaTypeNumber
  524.     virtual ETypes    NumericType() const    { return (CSchemaType::ETypes)TYPE; }
  525.     virtual long    ToLong() const        { return m_bIsEmpty ? (long)0        : m_Value; }
  526.     virtual __int64 ToInt64() const        { return m_bIsEmpty ? (__int64)0    : m_Value; }
  527.     virtual float    ToFloat() const        { return m_bIsEmpty ? (float)0.0    : m_Value; }
  528.     virtual double    ToDouble() const    { return m_bIsEmpty ? (double)0.0    : m_Value; }
  529.  
  530.     typedef bool basetype;
  531.     typedef long calctype;
  532. protected:
  533.     bool m_Value;
  534. };
  535.  
  536.  
  537. ////////////////////////////////////////////////////////////////////////
  538. //
  539. //  CSchemaTypeCalendar
  540. //
  541. ////////////////////////////////////////////////////////////////////////
  542.  
  543. class CSchemaDuration;
  544. class CSchemaTime;
  545. class CSchemaDay;
  546. class CSchemaMonth;
  547. class CSchemaMonthDay;
  548. class CSchemaYear;
  549. class CSchemaYearMonth;
  550. class CSchemaDate;
  551. class CSchemaDateTime;
  552.  
  553.  
  554. class ALTOVA_DECLSPECIFIER CSchemaTypeCalendar
  555. {
  556. public:
  557.     virtual operator CSchemaDuration() const = 0;
  558.     virtual operator CSchemaTime() const = 0;
  559.     virtual operator CSchemaDay() const = 0;
  560.     virtual operator CSchemaMonth() const = 0;
  561.     virtual operator CSchemaMonthDay() const = 0;
  562.     virtual operator CSchemaYear() const = 0;
  563.     virtual operator CSchemaYearMonth() const = 0;
  564.     virtual operator CSchemaDate() const = 0;
  565.     virtual operator CSchemaDateTime() const = 0;
  566.  
  567.     virtual CSchemaType::ETypes CalendarType() const = 0;
  568. };
  569.  
  570.  
  571. ////////////////////////////////////////////////////////////////////////
  572. //
  573. //  CSchemaDuration
  574. //
  575. ////////////////////////////////////////////////////////////////////////
  576.  
  577.  
  578. class ALTOVA_DECLSPECIFIER CSchemaDuration : public CSchemaTypeCalendar, public CSchemaType
  579. {
  580. public:
  581.     CSchemaDuration();
  582.     CSchemaDuration(bool bPositive, int nYear, int nMonth, int nDay, int nHour, int nMinute, double dSecond);
  583.     CSchemaDuration(const TCHAR* szValue);
  584.     CSchemaDuration(const CSchemaType& rOther);
  585.  
  586.     enum { TYPE = CSchemaType::k_Duration };
  587.  
  588.     bool IsPositive() const;
  589.     int GetYear() const;
  590.     int GetMonth() const;
  591.     int GetDay() const;
  592.     int GetHour() const;
  593.     int GetMinute() const;
  594.     double GetSecond() const;
  595.  
  596.     void SetPositive(bool bPositive);
  597.     void SetYear(int nYear);
  598.     void SetMonth(int nMonth);
  599.     void SetDay(int nDay);
  600.     void SetHour(int nHour);
  601.     void SetMinute(int nMinute);
  602.     void SetSecond(double dSecond);
  603.  
  604.     virtual CSchemaDuration& operator=(const CSchemaDuration& rOther )    { return (CSchemaDuration&)Assign(rOther); }
  605.     friend CSchemaType;
  606.     friend CSchemaDuration ALTOVA_DECLSPECIFIER operator+(const CSchemaDuration& dur1, const CSchemaDuration& dur2);
  607.     // from CSchemaType
  608.     virtual operator tstring() const;
  609.     virtual bool ToBool() const;
  610.  
  611.     virtual void Parse(const TCHAR* szValue);
  612.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  613.     virtual void Empty();
  614.  
  615.     // from CSchemaTypeCalendar
  616.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  617.     virtual operator CSchemaDuration() const;
  618.     virtual operator CSchemaTime() const;
  619.     virtual operator CSchemaDay() const;
  620.     virtual operator CSchemaMonth() const;
  621.     virtual operator CSchemaMonthDay() const;
  622.     virtual operator CSchemaYear() const;
  623.     virtual operator CSchemaYearMonth() const;
  624.     virtual operator CSchemaDate() const;
  625.     virtual operator CSchemaDateTime() const;
  626.  
  627.     typedef const TCHAR* basetype;
  628. protected:
  629.     double    ApproximatedNormalizedSeconds() const;    // approximated because assumed that 1 month=31 days; used only for comparison
  630.  
  631.     bool    m_bPositive;
  632.     int        m_nYear;
  633.     int        m_nMonth;
  634.     int        m_nDay;
  635.     int        m_nHour;
  636.     int        m_nMinute;
  637.     double    m_dSecond;
  638. };
  639.  
  640.  
  641. ////////////////////////////////////////////////////////////////////////
  642. //
  643. //  CSchemaDateTimeBase
  644. //
  645. ////////////////////////////////////////////////////////////////////////
  646.  
  647.  
  648. class ALTOVA_DECLSPECIFIER CSchemaDateTimeBase : public CSchemaType, public CSchemaTypeCalendar
  649. {
  650. public:
  651.     CSchemaDateTimeBase();
  652.     CSchemaDateTimeBase(bool bUTC);
  653.     CSchemaDateTimeBase(int nOffset);
  654.  
  655.     bool HasTimezone() const;
  656.     int GetTimezoneMode() const;
  657.     int GetOffset() const;
  658.  
  659.     void SetTimezoneMode(int nTZMode);
  660.     void SetOffset(int nOffset);
  661.  
  662.     enum
  663.     {
  664.         TZ_UTC,
  665.         TZ_Offset,
  666.         TZ_Missing
  667.     };
  668.  
  669. protected:
  670.     static int WriteTime(TCHAR* szTarget, int nHour, int nMinute, double dSecond);
  671.  
  672.     void ParseTZ(const TCHAR* szValue);
  673.     void WriteTZ(TCHAR* szTarget) const;
  674.  
  675.     int                m_nTZMode;
  676.     int                m_nOffset;
  677. };
  678.  
  679.  
  680. ////////////////////////////////////////////////////////////////////////
  681. //
  682. //  CSchemaDate
  683. //
  684. ////////////////////////////////////////////////////////////////////////
  685.  
  686.  
  687. class ALTOVA_DECLSPECIFIER CSchemaDate : public CSchemaDateTimeBase
  688. {
  689. public:
  690.     CSchemaDate();
  691.     CSchemaDate(int nYear, int nMonth, int nDay, bool bUTC = false);
  692.     CSchemaDate(int nYear, int nMonth, int nDay, int nOffset);
  693.     CSchemaDate(const TCHAR* szValue);
  694.     CSchemaDate(const CSchemaType& rOther);
  695.  
  696.     enum { TYPE = CSchemaType::k_Date };
  697.  
  698.     int GetYear() const;
  699.     int GetMonth() const;
  700.     int GetDay() const;
  701.  
  702.     void SetYear(int nYear);
  703.     void SetMonth(int nMonth);
  704.     void SetDay(int nDay);
  705.  
  706.     friend bool operator==(const CSchemaDate& t1, const CSchemaDate& t2);
  707.     friend bool operator< (const CSchemaDate& t1, const CSchemaDate& t2);
  708.     friend bool operator!=(const CSchemaDate& t1, const CSchemaDate& t2);
  709.     friend bool operator<=(const CSchemaDate& t1, const CSchemaDate& t2);
  710.     friend bool operator> (const CSchemaDate& t1, const CSchemaDate& t2);
  711.     friend bool operator>=(const CSchemaDate& t1, const CSchemaDate& t2);
  712.  
  713.     friend CSchemaType;
  714.     friend CSchemaDate ALTOVA_DECLSPECIFIER operator+(const CSchemaDate& t, const CSchemaDuration& dur);
  715.     friend CSchemaDuration ALTOVA_DECLSPECIFIER operator-(const CSchemaDate& t1, const CSchemaDate& t2);
  716.     virtual CSchemaDate& operator=(const CSchemaType& rOther)    { return (CSchemaDate&)Assign(rOther);    }
  717.  
  718.     // from CSchemaType
  719.     virtual operator tstring() const;
  720.     virtual bool ToBool() const;
  721.  
  722.     virtual void Parse(const TCHAR* szValue);
  723.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  724.     virtual void Empty();
  725.  
  726.     // from CSchemaTypeCalendar
  727.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  728.     virtual operator CSchemaDuration() const;
  729.     virtual operator CSchemaTime() const;
  730.     virtual operator CSchemaDay() const;
  731.     virtual operator CSchemaMonth() const;
  732.     virtual operator CSchemaMonthDay() const;
  733.     virtual operator CSchemaYear() const;
  734.     virtual operator CSchemaYearMonth() const;
  735.     virtual operator CSchemaDate() const;
  736.     virtual operator CSchemaDateTime() const;
  737.  
  738.     typedef const TCHAR* basetype;
  739. protected:
  740.     long    ApproximatedNormalizedDays() const;    // approx. because assumes 1 month = 31 days
  741.  
  742.     int        m_nYear;
  743.     int        m_nMonth;
  744.     int        m_nDay;
  745. };
  746.  
  747.  
  748. ////////////////////////////////////////////////////////////////////////
  749. //
  750. //  CSchemaTime
  751. //
  752. ////////////////////////////////////////////////////////////////////////
  753.  
  754.  
  755. class ALTOVA_DECLSPECIFIER CSchemaTime : public CSchemaDateTimeBase
  756. {
  757. public:
  758.     CSchemaTime();
  759.     CSchemaTime(int nHour, int nMinute, double dSecond, bool bUTC = false);
  760.     CSchemaTime(int nHour, int nMinute, double dSecond, int nOffset);
  761.     CSchemaTime(const TCHAR* szValue);
  762.     CSchemaTime(const CSchemaType& rOther);
  763.  
  764.     enum { TYPE = CSchemaType::k_Time };
  765.  
  766.     int GetHour() const;
  767.     int GetMinute() const;
  768.     double GetSecond() const;
  769.  
  770.     void SetHour(int nHour);
  771.     void SetMinute(int nMinute);
  772.     void SetSecond(double dSecond);
  773.  
  774.     friend bool operator==(const CSchemaTime& t1, const CSchemaTime& t2);
  775.     friend bool operator< (const CSchemaTime& t1, const CSchemaTime& t2);
  776.     friend bool operator!=(const CSchemaTime& t1, const CSchemaTime& t2);
  777.     friend bool operator<=(const CSchemaTime& t1, const CSchemaTime& t2);
  778.     friend bool operator> (const CSchemaTime& t1, const CSchemaTime& t2);
  779.     friend bool operator>=(const CSchemaTime& t1, const CSchemaTime& t2);
  780.  
  781.     friend CSchemaType;
  782.     friend CSchemaTime ALTOVA_DECLSPECIFIER operator+(const CSchemaTime& t, const CSchemaDuration& dur);
  783.     friend CSchemaDuration ALTOVA_DECLSPECIFIER operator-(const CSchemaTime& t1, const CSchemaTime& t2);
  784.     virtual CSchemaTime& operator=(const CSchemaType& rOther )    { return (CSchemaTime&)Assign(rOther); }
  785.  
  786.     // from CSchemaType
  787.     virtual operator tstring() const;
  788.     virtual bool ToBool() const;
  789.  
  790.     virtual void Parse(const TCHAR* szValue);
  791.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  792.     virtual void Empty();
  793.  
  794.     // from CSchemaTypeCalendar
  795.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  796.     virtual operator CSchemaDuration() const;
  797.     virtual operator CSchemaTime() const;
  798.     virtual operator CSchemaDay() const;
  799.     virtual operator CSchemaMonth() const;
  800.     virtual operator CSchemaMonthDay() const;
  801.     virtual operator CSchemaYear() const;
  802.     virtual operator CSchemaYearMonth() const;
  803.     virtual operator CSchemaDate() const;
  804.     virtual operator CSchemaDateTime() const;
  805.  
  806.     typedef const TCHAR* basetype;
  807. protected:
  808.     double NormalizedSeconds() const;
  809.  
  810.     int        m_nHour;
  811.     int        m_nMinute;
  812.     double    m_dSecond;
  813. };
  814.  
  815.  
  816. ////////////////////////////////////////////////////////////////////////
  817. //
  818. //  CSchemaDateTime
  819. //
  820. ////////////////////////////////////////////////////////////////////////
  821.  
  822.  
  823. class ALTOVA_DECLSPECIFIER CSchemaDateTime : public CSchemaDateTimeBase
  824. {
  825. public:
  826.     CSchemaDateTime();
  827.     CSchemaDateTime(int nYear, int nMonth, int nDay, int nHour, int nMinute, double dSecond, bool bUTC = false);
  828.     CSchemaDateTime(int nYear, int nMonth, int nDay, int nHour, int nMinute, double dSecond, int nOffset);
  829.     CSchemaDateTime(const TCHAR* szValue);
  830.     CSchemaDateTime(const CSchemaType& rOther);
  831. [if $DBLibraryCount > 0]
  832.     CSchemaDateTime(const _variant_t& vValue);
  833.     virtual operator _variant_t() const;
  834. [endif]
  835.  
  836.     enum { TYPE = CSchemaType::k_DateTime };
  837.  
  838.     int GetYear() const;
  839.     int GetMonth() const;
  840.     int GetDay() const;
  841.     int GetHour() const;
  842.     int GetMinute() const;
  843.     double GetSecond() const;
  844.  
  845.     void SetYear(int nYear);
  846.     void SetMonth(int nMonth);
  847.     void SetDay(int nDay);
  848.     void SetHour(int nHour);
  849.     void SetMinute(int nMinute);
  850.     void SetSecond(double dSecond);
  851.  
  852.     friend bool operator==(const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  853.     friend bool operator< (const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  854.     friend bool operator!=(const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  855.     friend bool operator<=(const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  856.     friend bool operator> (const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  857.     friend bool operator>=(const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  858.  
  859.     friend CSchemaType;
  860.     friend CSchemaDateTime ALTOVA_DECLSPECIFIER operator+(const CSchemaDateTime& t, const CSchemaDuration& dur);
  861.     friend CSchemaDuration ALTOVA_DECLSPECIFIER operator-(const CSchemaDateTime& t1, const CSchemaDateTime& t2);
  862.     virtual CSchemaDateTime& operator=(const CSchemaType& rOther)    { return (CSchemaDateTime&)Assign(rOther);    }
  863.  
  864.     // from CSchemaType
  865.     virtual operator tstring() const;
  866.     virtual bool ToBool() const;
  867.  
  868.     virtual void Parse(const TCHAR* szValue);
  869.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  870.     virtual void Empty();
  871.  
  872.     // from CSchemaTypeCalendar
  873.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  874.     virtual operator CSchemaDuration() const;
  875.     virtual operator CSchemaTime() const;
  876.     virtual operator CSchemaDay() const;
  877.     virtual operator CSchemaMonth() const;
  878.     virtual operator CSchemaMonthDay() const;
  879.     virtual operator CSchemaYear() const;
  880.     virtual operator CSchemaYearMonth() const;
  881.     virtual operator CSchemaDate() const;
  882.     virtual operator CSchemaDateTime() const;
  883.  
  884.  
  885.     typedef const TCHAR* basetype;
  886. protected:
  887.     double    ApproximatedNormalizedSeconds() const;    // approximated because assumes 1 month = 31 days;
  888.  
  889.     int        m_nYear;
  890.     int        m_nMonth;
  891.     int        m_nDay;
  892.  
  893.     int        m_nHour;
  894.     int        m_nMinute;
  895.     double    m_dSecond;
  896. };
  897.  
  898.  
  899. ////////////////////////////////////////////////////////////////////////
  900. //
  901. //  CSchemaYear
  902. //
  903. ////////////////////////////////////////////////////////////////////////
  904.  
  905.  
  906. class ALTOVA_DECLSPECIFIER CSchemaYear : public CSchemaDateTimeBase
  907. {
  908. public:
  909.     CSchemaYear();
  910.     CSchemaYear(int nYear, bool bUTC = false);
  911.     CSchemaYear(int nYear, int nOffset);
  912.     CSchemaYear(const TCHAR* szValue);
  913.     CSchemaYear(const CSchemaType& rOther);
  914.  
  915.     enum { TYPE = CSchemaType::k_Year };
  916.  
  917.     int GetYear() const;
  918.     void SetYear(int nYear);
  919.  
  920.     friend CSchemaType;
  921.     virtual CSchemaYear& operator=(const CSchemaType& rOther)    { return (CSchemaYear&)Assign(rOther); }
  922.  
  923.     // from CSchemaType
  924.     virtual operator tstring() const;
  925.     virtual bool ToBool() const;
  926.  
  927.     virtual void Parse(const TCHAR* szValue);
  928.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  929.     virtual void Empty();
  930.  
  931.     // from CSchemaTypeCalendar
  932.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  933.     virtual operator CSchemaDuration() const;
  934.     virtual operator CSchemaTime() const;
  935.     virtual operator CSchemaDay() const;
  936.     virtual operator CSchemaMonth() const;
  937.     virtual operator CSchemaMonthDay() const;
  938.     virtual operator CSchemaYear() const;
  939.     virtual operator CSchemaYearMonth() const;
  940.     virtual operator CSchemaDate() const;
  941.     virtual operator CSchemaDateTime() const;
  942.  
  943.     typedef const TCHAR* basetype;
  944. protected:
  945.     int        m_nYear;
  946. };
  947.  
  948.  
  949. ////////////////////////////////////////////////////////////////////////
  950. //
  951. //  CSchemaYearMonth
  952. //
  953. ////////////////////////////////////////////////////////////////////////
  954.  
  955.  
  956. class ALTOVA_DECLSPECIFIER CSchemaYearMonth : public CSchemaDateTimeBase
  957. {
  958. public:
  959.     CSchemaYearMonth();
  960.     CSchemaYearMonth(int nYear, int nMonth, bool bUTC = false);
  961.     CSchemaYearMonth(int nYear, int nMonth, int nOffset);
  962.     CSchemaYearMonth(const TCHAR* szValue);
  963.     CSchemaYearMonth(const CSchemaType& rOther);
  964.  
  965.     enum { TYPE = CSchemaType::k_YearMonth };
  966.  
  967.     int GetYear() const;
  968.     int GetMonth() const;
  969.  
  970.     void SetYear(int nYear);
  971.     void SetMonth(int nMonth);
  972.  
  973.     friend CSchemaType;
  974.     virtual CSchemaYearMonth& operator=(const CSchemaType& rOther)    { return (CSchemaYearMonth&)Assign(rOther); }
  975.  
  976.     // from CSchemaType
  977.     virtual operator tstring() const;
  978.     virtual bool ToBool() const;
  979.  
  980.     virtual void Parse(const TCHAR* szValue);
  981.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  982.     virtual void Empty();
  983.  
  984.     // from CSchemaTypeCalendar
  985.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  986.     virtual operator CSchemaDuration() const;
  987.     virtual operator CSchemaTime() const;
  988.     virtual operator CSchemaDay() const;
  989.     virtual operator CSchemaMonth() const;
  990.     virtual operator CSchemaMonthDay() const;
  991.     virtual operator CSchemaYear() const;
  992.     virtual operator CSchemaYearMonth() const;
  993.     virtual operator CSchemaDate() const;
  994.     virtual operator CSchemaDateTime() const;
  995.  
  996.  
  997.     typedef const TCHAR* basetype;
  998. protected:
  999.     long    NormalizedMonths() const;
  1000.  
  1001.     int        m_nYear;
  1002.     int        m_nMonth;
  1003. };
  1004.  
  1005.  
  1006. ////////////////////////////////////////////////////////////////////////
  1007. //
  1008. //  CSchemaMonth
  1009. //
  1010. ////////////////////////////////////////////////////////////////////////
  1011.  
  1012.  
  1013. class ALTOVA_DECLSPECIFIER CSchemaMonth : public CSchemaDateTimeBase
  1014. {
  1015. public:
  1016.     CSchemaMonth();
  1017.     CSchemaMonth(int nMonth, bool bUTC = false);
  1018.     CSchemaMonth(int nMonth, int nOffset);
  1019.     CSchemaMonth(const TCHAR* szValue);
  1020.     CSchemaMonth(const CSchemaType& rOther);
  1021.  
  1022.     enum { TYPE = CSchemaType::k_Month };
  1023.  
  1024.     int GetMonth() const;
  1025.     void SetMonth(int nMonth);
  1026.  
  1027.     friend CSchemaType;
  1028.     virtual CSchemaMonth& operator=(const CSchemaType& rOther )    { return (CSchemaMonth&)Assign(rOther); }
  1029.  
  1030.     // from CSchemaType
  1031.     virtual operator tstring() const;
  1032.     virtual bool ToBool() const;
  1033.  
  1034.     virtual void Parse(const TCHAR* szValue);
  1035.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  1036.     virtual void Empty();
  1037.  
  1038.     // from CSchemaTypeCalendar
  1039.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  1040.     virtual operator CSchemaDuration() const;
  1041.     virtual operator CSchemaTime() const;
  1042.     virtual operator CSchemaDay() const;
  1043.     virtual operator CSchemaMonth() const;
  1044.     virtual operator CSchemaMonthDay() const;
  1045.     virtual operator CSchemaYear() const;
  1046.     virtual operator CSchemaYearMonth() const;
  1047.     virtual operator CSchemaDate() const;
  1048.     virtual operator CSchemaDateTime() const;
  1049.  
  1050.  
  1051.     typedef const TCHAR* basetype;
  1052. protected:
  1053.     int        m_nMonth;
  1054. };
  1055.  
  1056.  
  1057. ////////////////////////////////////////////////////////////////////////
  1058. //
  1059. //  CSchemaMonthDay
  1060. //
  1061. ////////////////////////////////////////////////////////////////////////
  1062.  
  1063.  
  1064. class ALTOVA_DECLSPECIFIER CSchemaMonthDay : public CSchemaDateTimeBase
  1065. {
  1066. public:
  1067.     CSchemaMonthDay();
  1068.     CSchemaMonthDay(int nMonth, int nDay, bool bUTC = false);
  1069.     CSchemaMonthDay(int nMonth, int nDay, int nOffset);
  1070.     CSchemaMonthDay(const TCHAR* szValue);
  1071.     CSchemaMonthDay(const CSchemaType& rOther);
  1072.  
  1073.     enum { TYPE = CSchemaType::k_MonthDay };
  1074.  
  1075.     int GetMonth() const;
  1076.     int GetDay() const;
  1077.  
  1078.     void SetMonth(int nMonth);
  1079.     void SetDay(int nYear);
  1080.  
  1081.     friend CSchemaType;
  1082.     virtual CSchemaMonthDay& operator=(const CSchemaType& rOther)    { return (CSchemaMonthDay&)Assign(rOther);    }
  1083.  
  1084.     // from CSchemaType
  1085.     virtual operator tstring() const;
  1086.     virtual bool ToBool() const;
  1087.  
  1088.     virtual void Parse(const TCHAR* szValue);
  1089.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  1090.     virtual void Empty();
  1091.  
  1092.     // from CSchemaTypeCalendar
  1093.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  1094.     virtual operator CSchemaDuration() const;
  1095.     virtual operator CSchemaTime() const;
  1096.     virtual operator CSchemaDay() const;
  1097.     virtual operator CSchemaMonth() const;
  1098.     virtual operator CSchemaMonthDay() const;
  1099.     virtual operator CSchemaYear() const;
  1100.     virtual operator CSchemaYearMonth() const;
  1101.     virtual operator CSchemaDate() const;
  1102.     virtual operator CSchemaDateTime() const;
  1103.  
  1104.  
  1105.     typedef const TCHAR* basetype;
  1106. protected:
  1107.     long    ApproximatedNormalizedDays() const;        // approx. 'cause assumes 1 month = 31 days; for comparison only
  1108.  
  1109.     int        m_nMonth;
  1110.     int        m_nDay;
  1111. };
  1112.  
  1113.  
  1114. ////////////////////////////////////////////////////////////////////////
  1115. //
  1116. //  CSchemaDay
  1117. //
  1118. ////////////////////////////////////////////////////////////////////////
  1119.  
  1120.  
  1121. class ALTOVA_DECLSPECIFIER CSchemaDay : public CSchemaDateTimeBase
  1122. {
  1123. public:
  1124.     CSchemaDay();
  1125.     CSchemaDay(int nDay, bool bUTC = false);
  1126.     CSchemaDay(int nDay, int nOffset);
  1127.     CSchemaDay(const TCHAR* szValue);
  1128.     CSchemaDay(const CSchemaType& rOther);
  1129.  
  1130.     enum { TYPE = CSchemaType::k_Day };
  1131.  
  1132.     int GetDay() const;
  1133.  
  1134.     void SetDay(int nYear);
  1135.  
  1136.     friend CSchemaType;
  1137.     virtual CSchemaDay& operator=(const CSchemaType& rOther)    { return (CSchemaDay&)Assign(rOther);    }
  1138.  
  1139.     // from CSchemaType
  1140.     virtual operator tstring() const;
  1141.     virtual bool ToBool() const;
  1142.  
  1143.     virtual void Parse(const TCHAR* szValue);
  1144.     virtual CSchemaType& Assign(const CSchemaType& rOther );
  1145.     virtual void Empty();
  1146.  
  1147.     // from CSchemaTypeCalendar
  1148.     virtual ETypes CalendarType() const    { return (CSchemaType::ETypes)TYPE; }
  1149.     virtual operator CSchemaDuration() const;
  1150.     virtual operator CSchemaTime() const;
  1151.     virtual operator CSchemaDay() const;
  1152.     virtual operator CSchemaMonth() const;
  1153.     virtual operator CSchemaMonthDay() const;
  1154.     virtual operator CSchemaYear() const;
  1155.     virtual operator CSchemaYearMonth() const;
  1156.     virtual operator CSchemaDate() const;
  1157.     virtual operator CSchemaDateTime() const;
  1158.  
  1159.  
  1160.     typedef const TCHAR* basetype;
  1161. protected:
  1162.     int        m_nDay;
  1163. };
  1164.  
  1165.  
  1166.  
  1167. ////////////////////////////////////////////////////////////////////////
  1168. //
  1169. //  CSchemaString family
  1170. //
  1171. ////////////////////////////////////////////////////////////////////////
  1172.  
  1173.  
  1174. class ALTOVA_DECLSPECIFIER CSchemaString : public CSchemaType, public CSchemaTypeNumber, public CSchemaTypeCalendar
  1175. {
  1176. public:
  1177.     CSchemaString();
  1178.     CSchemaString(const tstring sValue);
  1179.     CSchemaString(const TCHAR* szValue);
  1180.     CSchemaString(const double    nValue);    // numeric value will be transformed into a string-representation
  1181.     CSchemaString(const CSchemaType& rOther);
  1182. [if $DBLibraryCount > 0]
  1183.     CSchemaString(const _variant_t& vValue);
  1184.     virtual operator _variant_t(); 
  1185. [endif]
  1186.     enum { TYPE = CSchemaType::k_String };
  1187.  
  1188.     friend CSchemaType;
  1189.     virtual CSchemaString& operator=(const CSchemaType& rOther)    { return (CSchemaString&)Assign(rOther); }
  1190.  
  1191.     double ToCalcValue() const    { return ToDouble(); }
  1192.     static CSchemaType* CreateInstanceByString(const TCHAR* szValue);
  1193. [if $DBLibraryCount > 0]
  1194.     static _variant_t    CreateVariantByString(const TCHAR* szValue);
  1195. [endif]
  1196.  
  1197.     // from CSchemaType
  1198.     virtual operator tstring() const;
  1199.     virtual bool ToBool() const;
  1200.     virtual void Parse(const TCHAR* szValue);
  1201.     virtual CSchemaType& Assign(const CSchemaType& rOther);
  1202.     virtual void Empty();
  1203.  
  1204.     // from CSchemaTypeNumber
  1205.     virtual ETypes        NumericType() const;
  1206.     virtual long        ToLong() const;
  1207.     virtual __int64        ToInt64() const;
  1208.     virtual float        ToFloat() const;
  1209.     virtual double        ToDouble() const;
  1210.  
  1211.     // from CSchemaTypeCalendar 
  1212.     virtual ETypes        CalendarType() const;
  1213.     virtual operator CSchemaDuration() const;
  1214.     virtual operator CSchemaTime() const;
  1215.     virtual operator CSchemaDay() const;
  1216.     virtual operator CSchemaMonth() const;
  1217.     virtual operator CSchemaMonthDay() const;
  1218.     virtual operator CSchemaYear() const;
  1219.     virtual operator CSchemaYearMonth() const;
  1220.     virtual operator CSchemaDate() const;
  1221.     virtual operator CSchemaDateTime() const;
  1222.  
  1223.  
  1224.     typedef const TCHAR* basetype;
  1225.     typedef double    calctype;    // string values are represented as double-values if possible.
  1226.  
  1227. protected:
  1228.     tstring m_Value;
  1229. };
  1230.  
  1231.  
  1232. typedef CSchemaString CSchemaNormalizedString;
  1233. typedef CSchemaString CSchemaToken;
  1234. typedef CSchemaString CSchemaLanguage;
  1235. typedef CSchemaString CSchemaName;
  1236. typedef CSchemaString CSchemaNMToken;
  1237. typedef CSchemaString CSchemaNMTokens;
  1238. typedef CSchemaString CSchemaNCName;
  1239. typedef CSchemaString CSchemaID;
  1240. typedef CSchemaString CSchemaIDRef;
  1241. typedef CSchemaString CSchemaIDRefs;
  1242. typedef CSchemaString CSchemaEntity;
  1243. typedef CSchemaString CSchemaEntities;
  1244. typedef CSchemaString CSchemaAnyURI;
  1245. typedef CSchemaString CSchemaQName;
  1246. typedef CSchemaString CSchemaNotation;
  1247.  
  1248.  
  1249.  
  1250.  
  1251. ////////////////////////////////////////////////////////////////////////
  1252. //
  1253. //  CSchemaBinaryBase
  1254. //
  1255. ////////////////////////////////////////////////////////////////////////
  1256.  
  1257.  
  1258. class ALTOVA_DECLSPECIFIER CSchemaBinaryBase : public CSchemaType
  1259. {
  1260. public:
  1261.     CSchemaBinaryBase() : m_nSize(0), m_pData(NULL) {};
  1262.     CSchemaBinaryBase(const CSchemaBinaryBase& rOther);
  1263.     CSchemaBinaryBase(const unsigned char* pData, int nSize);
  1264.     virtual ~CSchemaBinaryBase();
  1265. [if $DBLibraryCount > 0]
  1266.     CSchemaBinaryBase(const _variant_t& vValue);
  1267.     virtual operator _variant_t() const;
  1268. [endif]
  1269.     int GetSize() const                        { return m_nSize; }
  1270.     const unsigned char* GetData() const    { return m_pData; }
  1271.     unsigned char* GetData()                { return m_pData; }
  1272.  
  1273.     void SetData(const unsigned char* pData, int nSize);
  1274.  
  1275.     friend CSchemaType;
  1276.  
  1277.     // from CSchemaType
  1278.     virtual operator tstring() const = 0;
  1279.     virtual bool ToBool() const    {    return !( m_bIsEmpty || m_pData == NULL );    }
  1280.  
  1281.     virtual void Parse(const TCHAR* szValue) = 0;
  1282.     virtual CSchemaType& Assign(const CSchemaType& rOther);
  1283.     virtual void Empty();
  1284.  
  1285.     typedef const TCHAR* basetype;
  1286. protected:
  1287.     void Clone(const CSchemaBinaryBase& rOther);
  1288.     void Clone(const unsigned char* pData, int nSize);
  1289.  
  1290.     int                m_nSize;
  1291.     unsigned char*    m_pData;
  1292. };
  1293.  
  1294.  
  1295. ////////////////////////////////////////////////////////////////////////
  1296. //
  1297. //  CSchemaHexBinary
  1298. //
  1299. ////////////////////////////////////////////////////////////////////////
  1300.  
  1301.  
  1302. class ALTOVA_DECLSPECIFIER CSchemaHexBinary : public CSchemaBinaryBase
  1303. {
  1304. public:
  1305.     CSchemaHexBinary() {};
  1306.     CSchemaHexBinary(const CSchemaBinaryBase& rOther) : CSchemaBinaryBase(rOther) {};
  1307.     CSchemaHexBinary(const unsigned char* pData, int nSize) : CSchemaBinaryBase(pData, nSize) {};
  1308.     CSchemaHexBinary(const TCHAR* szValue);
  1309.     CSchemaHexBinary(const CSchemaType& rOther);
  1310.  
  1311.     enum { TYPE = CSchemaType::k_HexBinary };
  1312.  
  1313.     friend CSchemaType;
  1314.     virtual CSchemaHexBinary& operator=(const CSchemaType& rOther) { return (CSchemaHexBinary&)Assign(rOther); }
  1315.     virtual CSchemaHexBinary& operator=(const CSchemaHexBinary& rOther)    { return (CSchemaHexBinary&)Assign(rOther); }
  1316.  
  1317.     // from CSchemaType
  1318.     virtual operator tstring() const;
  1319.  
  1320.     virtual void Parse(const TCHAR* szValue);
  1321.  
  1322.     typedef const TCHAR* basetype;
  1323. protected:
  1324.     static const TCHAR sm_EncodeArray\[\];
  1325.     static const TCHAR sm_DecodeArray\[\];
  1326. };
  1327.  
  1328.  
  1329. ////////////////////////////////////////////////////////////////////////
  1330. //
  1331. //  CSchemaBase64Binary
  1332. //
  1333. ////////////////////////////////////////////////////////////////////////
  1334.  
  1335.  
  1336. class ALTOVA_DECLSPECIFIER CSchemaBase64Binary : public CSchemaBinaryBase
  1337. {
  1338. public:
  1339.     CSchemaBase64Binary()  {};
  1340.     CSchemaBase64Binary(const CSchemaBinaryBase& rOther) : CSchemaBinaryBase(rOther ) {};
  1341.     CSchemaBase64Binary(const unsigned char* pData, int nSize) : CSchemaBinaryBase(pData, nSize) {};
  1342.     CSchemaBase64Binary(const TCHAR* szValue);
  1343.     CSchemaBase64Binary(const CSchemaType& rOther);
  1344.  
  1345.     enum { TYPE = CSchemaType::k_Base64Binary };
  1346.     
  1347.     friend CSchemaType;
  1348.     virtual CSchemaBase64Binary& operator=(const CSchemaType& rOther)    { return (CSchemaBase64Binary&)Assign(rOther); }
  1349.     virtual CSchemaBase64Binary& operator=(const CSchemaBase64Binary& rOther)    { return (CSchemaBase64Binary&)Assign(rOther); }
  1350.  
  1351.     // from CSchemaType
  1352.     virtual operator tstring() const;
  1353.  
  1354.     virtual void Parse(const TCHAR* szValue);
  1355.  
  1356.     typedef const TCHAR* basetype;
  1357. protected:
  1358.     void Encode(unsigned char* pSrc, int nSrcSize, TCHAR*& rszDst, int& rnDstSize, int nMaxLineLength = 76) const;
  1359.     void Decode(const TCHAR* szSrc, unsigned char*& rpDst, int& rnDstSize);
  1360.  
  1361.     static const TCHAR sm_EncodeArray\[\];
  1362.     static const TCHAR sm_DecodeArray\[\];
  1363. };
  1364.  
  1365.  
  1366. } // namespace altova
  1367.  
  1368. #endif // ALTOVA_SCHEMATYPES_H_INCLUDED
  1369.