00001
00002
00003
00004
00005
00016 #ifndef XSD_CXX_TREE_DATE_TIME_HXX
00017 #define XSD_CXX_TREE_DATE_TIME_HXX
00018
00019 #include <string>
00020 #include <cstddef>
00021
00022 #include <xercesc/dom/DOMAttr.hpp>
00023 #include <xercesc/dom/DOMElement.hpp>
00024
00025 #include <xsd/cxx/tree/elements.hxx>
00026 #include <xsd/cxx/tree/istream-fwd.hxx>
00027
00028 namespace xsd
00029 {
00030 namespace cxx
00031 {
00040 namespace tree
00041 {
00053 class time_zone
00054 {
00055 public:
00060
00067 time_zone ();
00068
00076 time_zone (short hours, short minutes);
00077
00079
00085 bool
00086 zone_present () const;
00087
00092 void
00093 zone_reset ();
00094
00100 short
00101 zone_hours () const;
00102
00108 void
00109 zone_hours (short h);
00110
00111
00117 short
00118 zone_minutes () const;
00119
00125 void
00126 zone_minutes (short m);
00127
00128 protected:
00129
00130
00131 template <typename C>
00132 void
00133 zone_parse (const C*, std::size_t);
00134
00135 template <typename S>
00136 void
00137 zone_extract (istream<S>&);
00138
00139
00140
00141 private:
00142 bool present_;
00143 short hours_;
00144 short minutes_;
00145 };
00146
00153 bool
00154 operator== (const time_zone&, const time_zone&);
00155
00162 bool
00163 operator!= (const time_zone&, const time_zone&);
00164
00165
00174 template <typename C, typename B>
00175 class gday: public B, public time_zone
00176 {
00177 public:
00182
00191 explicit
00192 gday (unsigned short day);
00193
00202 gday (unsigned short day, short zone_hours, short zone_minutes);
00203
00213 gday (const gday& x, flags f = 0, container* c = 0);
00214
00226 virtual gday*
00227 _clone (flags f = 0, container* c = 0) const;
00228
00238 template <typename S>
00239 gday (istream<S>& s, flags f = 0, container* c = 0);
00240
00249 gday (const xercesc::DOMElement& e, flags f = 0, container* c = 0);
00250
00259 gday (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
00260
00270 gday (const std::basic_string<C>& s,
00271 const xercesc::DOMElement* e,
00272 flags f = 0,
00273 container* c = 0);
00275
00276 public:
00282 unsigned short
00283 day () const;
00284
00290 void
00291 day (unsigned short d);
00292
00293 protected:
00294
00295
00296 gday ();
00297
00298 void
00299 parse (const std::basic_string<C>&);
00300
00301
00302
00303 private:
00304 unsigned short day_;
00305 };
00306
00313 template <typename C, typename B>
00314 bool
00315 operator== (const gday<C, B>&, const gday<C, B>&);
00316
00323 template <typename C, typename B>
00324 bool
00325 operator!= (const gday<C, B>&, const gday<C, B>&);
00326
00335 template <typename C, typename B>
00336 class gmonth: public B, public time_zone
00337 {
00338 public:
00343
00352 explicit
00353 gmonth (unsigned short month);
00354
00363 gmonth (unsigned short month, short zone_hours, short zone_minutes);
00364
00374 gmonth (const gmonth& x, flags f = 0, container* c = 0);
00375
00387 virtual gmonth*
00388 _clone (flags f = 0, container* c = 0) const;
00389
00399 template <typename S>
00400 gmonth (istream<S>& s, flags f = 0, container* c = 0);
00401
00410 gmonth (const xercesc::DOMElement& e, flags f = 0, container* c = 0);
00411
00420 gmonth (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
00421
00431 gmonth (const std::basic_string<C>& s,
00432 const xercesc::DOMElement* e,
00433 flags f = 0,
00434 container* c = 0);
00436
00437 public:
00443 unsigned short
00444 month () const;
00445
00451 void
00452 month (unsigned short m);
00453
00454 protected:
00455
00456
00457 gmonth ();
00458
00459 void
00460 parse (const std::basic_string<C>&);
00461
00462
00463
00464 private:
00465 unsigned short month_;
00466 };
00467
00474 template <typename C, typename B>
00475 bool
00476 operator== (const gmonth<C, B>&, const gmonth<C, B>&);
00477
00484 template <typename C, typename B>
00485 bool
00486 operator!= (const gmonth<C, B>&, const gmonth<C, B>&);
00487
00488
00496 template <typename C, typename B>
00497 class gyear: public B, public time_zone
00498 {
00499 public:
00504
00513 explicit
00514 gyear (int year);
00515
00524 gyear (int year, short zone_hours, short zone_minutes);
00525
00535 gyear (const gyear& x, flags f = 0, container* c = 0);
00536
00548 virtual gyear*
00549 _clone (flags f = 0, container* c = 0) const;
00550
00560 template <typename S>
00561 gyear (istream<S>& s, flags f = 0, container* c = 0);
00562
00571 gyear (const xercesc::DOMElement& e, flags f = 0, container* c = 0);
00572
00581 gyear (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
00582
00592 gyear (const std::basic_string<C>& s,
00593 const xercesc::DOMElement* e,
00594 flags f = 0,
00595 container* c = 0);
00597
00598 public:
00604 int
00605 year () const;
00606
00612 void
00613 year (int y);
00614
00615 protected:
00616
00617
00618 gyear ();
00619
00620 void
00621 parse (const std::basic_string<C>&);
00622
00623
00624
00625 private:
00626 int year_;
00627 };
00628
00635 template <typename C, typename B>
00636 bool
00637 operator== (const gyear<C, B>&, const gyear<C, B>&);
00638
00645 template <typename C, typename B>
00646 bool
00647 operator!= (const gyear<C, B>&, const gyear<C, B>&);
00648
00649
00658 template <typename C, typename B>
00659 class gmonth_day: public B, public time_zone
00660 {
00661 public:
00666
00676 gmonth_day (unsigned short month, unsigned short day);
00677
00687 gmonth_day (unsigned short month, unsigned short day,
00688 short zone_hours, short zone_minutes);
00689
00699 gmonth_day (const gmonth_day& x, flags f = 0, container* c = 0);
00700
00712 virtual gmonth_day*
00713 _clone (flags f = 0, container* c = 0) const;
00714
00724 template <typename S>
00725 gmonth_day (istream<S>& s, flags f = 0, container* c = 0);
00726
00735 gmonth_day (const xercesc::DOMElement& e,
00736 flags f = 0,
00737 container* c = 0);
00738
00747 gmonth_day (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
00748
00758 gmonth_day (const std::basic_string<C>& s,
00759 const xercesc::DOMElement* e,
00760 flags f = 0,
00761 container* c = 0);
00763
00764 public:
00770 unsigned short
00771 month () const;
00772
00778 void
00779 month (unsigned short m);
00780
00786 unsigned short
00787 day () const;
00788
00794 void
00795 day (unsigned short d);
00796
00797 protected:
00798
00799
00800 gmonth_day ();
00801
00802 void
00803 parse (const std::basic_string<C>&);
00804
00805
00806
00807 private:
00808 unsigned short month_;
00809 unsigned short day_;
00810 };
00811
00818 template <typename C, typename B>
00819 bool
00820 operator== (const gmonth_day<C, B>&, const gmonth_day<C, B>&);
00821
00828 template <typename C, typename B>
00829 bool
00830 operator!= (const gmonth_day<C, B>&, const gmonth_day<C, B>&);
00831
00832
00842 template <typename C, typename B>
00843 class gyear_month: public B, public time_zone
00844 {
00845 public:
00850
00860 gyear_month (int year, unsigned short month);
00861
00871 gyear_month (int year, unsigned short month,
00872 short zone_hours, short zone_minutes);
00873
00883 gyear_month (const gyear_month& x, flags f = 0, container* c = 0);
00884
00896 virtual gyear_month*
00897 _clone (flags f = 0, container* c = 0) const;
00898
00908 template <typename S>
00909 gyear_month (istream<S>& s, flags f = 0, container* c = 0);
00910
00919 gyear_month (const xercesc::DOMElement& e,
00920 flags f = 0,
00921 container* c = 0);
00922
00931 gyear_month (const xercesc::DOMAttr& a,
00932 flags f = 0,
00933 container* c = 0);
00934
00944 gyear_month (const std::basic_string<C>& s,
00945 const xercesc::DOMElement* e,
00946 flags f = 0,
00947 container* c = 0);
00949
00950 public:
00956 int
00957 year () const;
00958
00964 void
00965 year (int y);
00966
00972 unsigned short
00973 month () const;
00974
00980 void
00981 month (unsigned short m);
00982
00983 protected:
00984
00985
00986 gyear_month ();
00987
00988 void
00989 parse (const std::basic_string<C>&);
00990
00991
00992
00993 private:
00994 int year_;
00995 unsigned short month_;
00996 };
00997
01004 template <typename C, typename B>
01005 bool
01006 operator== (const gyear_month<C, B>&, const gyear_month<C, B>&);
01007
01014 template <typename C, typename B>
01015 bool
01016 operator!= (const gyear_month<C, B>&, const gyear_month<C, B>&);
01017
01018
01027 template <typename C, typename B>
01028 class date: public B, public time_zone
01029 {
01030 public:
01035
01047 date (int year, unsigned short month, unsigned short day);
01048
01059 date (int year, unsigned short month, unsigned short day,
01060 short zone_hours, short zone_minutes);
01061
01071 date (const date& x, flags f = 0, container* c = 0);
01072
01084 virtual date*
01085 _clone (flags f = 0, container* c = 0) const;
01086
01096 template <typename S>
01097 date (istream<S>& s, flags f = 0, container* c = 0);
01098
01107 date (const xercesc::DOMElement& e, flags f = 0, container* c = 0);
01108
01117 date (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
01118
01128 date (const std::basic_string<C>& s,
01129 const xercesc::DOMElement* e,
01130 flags f = 0,
01131 container* c = 0);
01133
01134 public:
01140 int
01141 year () const;
01142
01148 void
01149 year (int y);
01150
01156 unsigned short
01157 month () const;
01158
01164 void
01165 month (unsigned short m);
01166
01172 unsigned short
01173 day () const;
01174
01180 void
01181 day (unsigned short d);
01182
01183 protected:
01184
01185
01186 date ();
01187
01188 void
01189 parse (const std::basic_string<C>&);
01190
01191
01192
01193 private:
01194 int year_;
01195 unsigned short month_;
01196 unsigned short day_;
01197 };
01198
01205 template <typename C, typename B>
01206 bool
01207 operator== (const date<C, B>&, const date<C, B>&);
01208
01215 template <typename C, typename B>
01216 bool
01217 operator!= (const date<C, B>&, const date<C, B>&);
01218
01219
01228 template <typename C, typename B>
01229 class time: public B, public time_zone
01230 {
01231 public:
01236
01248 time (unsigned short hours, unsigned short minutes, double seconds);
01249
01260 time (unsigned short hours, unsigned short minutes, double seconds,
01261 short zone_hours, short zone_minutes);
01262
01272 time (const time& x, flags f = 0, container* c = 0);
01273
01285 virtual time*
01286 _clone (flags f = 0, container* c = 0) const;
01287
01297 template <typename S>
01298 time (istream<S>& s, flags f = 0, container* c = 0);
01299
01308 time (const xercesc::DOMElement& e, flags f = 0, container* c = 0);
01309
01318 time (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
01319
01329 time (const std::basic_string<C>& s,
01330 const xercesc::DOMElement* e,
01331 flags f = 0,
01332 container* c = 0);
01334
01335 public:
01341 unsigned short
01342 hours () const;
01343
01349 void
01350 hours (unsigned short h);
01351
01357 unsigned short
01358 minutes () const;
01359
01365 void
01366 minutes (unsigned short m);
01367
01373 double
01374 seconds () const;
01375
01381 void
01382 seconds (double s);
01383
01384 protected:
01385
01386
01387 time ();
01388
01389 void
01390 parse (const std::basic_string<C>&);
01391
01392
01393
01394 private:
01395 unsigned short hours_;
01396 unsigned short minutes_;
01397 double seconds_;
01398 };
01399
01406 template <typename C, typename B>
01407 bool
01408 operator== (const time<C, B>&, const time<C, B>&);
01409
01416 template <typename C, typename B>
01417 bool
01418 operator!= (const time<C, B>&, const time<C, B>&);
01419
01420
01429 template <typename C, typename B>
01430 class date_time: public B, public time_zone
01431 {
01432 public:
01437
01452 date_time (int year, unsigned short month, unsigned short day,
01453 unsigned short hours, unsigned short minutes,
01454 double seconds);
01455
01469 date_time (int year, unsigned short month, unsigned short day,
01470 unsigned short hours, unsigned short minutes,
01471 double seconds, short zone_hours, short zone_minutes);
01472
01482 date_time (const date_time& x, flags f = 0, container* c = 0);
01483
01495 virtual date_time*
01496 _clone (flags f = 0, container* c = 0) const;
01497
01507 template <typename S>
01508 date_time (istream<S>& s, flags f = 0, container* c = 0);
01509
01518 date_time (const xercesc::DOMElement& e,
01519 flags f = 0,
01520 container* c = 0);
01521
01530 date_time (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
01531
01541 date_time (const std::basic_string<C>& s,
01542 const xercesc::DOMElement* e,
01543 flags f = 0,
01544 container* c = 0);
01546
01547 public:
01553 int
01554 year () const;
01555
01561 void
01562 year (int y);
01563
01569 unsigned short
01570 month () const;
01571
01577 void
01578 month (unsigned short m);
01579
01585 unsigned short
01586 day () const;
01587
01593 void
01594 day (unsigned short d);
01595
01601 unsigned short
01602 hours () const;
01603
01609 void
01610 hours (unsigned short h);
01611
01617 unsigned short
01618 minutes () const;
01619
01625 void
01626 minutes (unsigned short m);
01627
01633 double
01634 seconds () const;
01635
01641 void
01642 seconds (double s);
01643
01644 protected:
01645
01646
01647 date_time ();
01648
01649 void
01650 parse (const std::basic_string<C>&);
01651
01652
01653
01654 private:
01655 int year_;
01656 unsigned short month_;
01657 unsigned short day_;
01658 unsigned short hours_;
01659 unsigned short minutes_;
01660 double seconds_;
01661 };
01662
01669 template <typename C, typename B>
01670 bool
01671 operator== (const date_time<C, B>&, const date_time<C, B>&);
01672
01679 template <typename C, typename B>
01680 bool
01681 operator!= (const date_time<C, B>&, const date_time<C, B>&);
01682
01683
01692 template <typename C, typename B>
01693 class duration: public B
01694 {
01695 public:
01713 duration (bool negative,
01714 unsigned int years, unsigned int months, unsigned int days,
01715 unsigned int hours, unsigned int minutes, double seconds);
01716
01726 duration (const duration& x, flags f = 0, container* c = 0);
01727
01739 virtual duration*
01740 _clone (flags f = 0, container* c = 0) const;
01741
01751 template <typename S>
01752 duration (istream<S>& s, flags f = 0, container* c = 0);
01753
01762 duration (const xercesc::DOMElement& e,
01763 flags f = 0,
01764 container* c = 0);
01765
01774 duration (const xercesc::DOMAttr& a, flags f = 0, container* c = 0);
01775
01785 duration (const std::basic_string<C>& s,
01786 const xercesc::DOMElement* e,
01787 flags f = 0,
01788 container* c = 0);
01790
01791 public:
01797 bool
01798 negative () const;
01799
01806 void
01807 negative (bool n);
01808
01814 unsigned int
01815 years () const;
01816
01822 void
01823 years (unsigned int y);
01824
01830 unsigned int
01831 months () const;
01832
01838 void
01839 months (unsigned int m);
01840
01846 unsigned int
01847 days () const;
01848
01854 void
01855 days (unsigned int d);
01856
01862 unsigned int
01863 hours () const;
01864
01870 void
01871 hours (unsigned int h);
01872
01878 unsigned int
01879 minutes () const;
01880
01886 void
01887 minutes (unsigned int m);
01888
01894 double
01895 seconds () const;
01896
01902 void
01903 seconds (double s);
01904
01905 protected:
01906
01907
01908 duration ();
01909
01910 void
01911 parse (const std::basic_string<C>&);
01912
01913
01914
01915 private:
01916 bool negative_;
01917 unsigned int years_;
01918 unsigned int months_;
01919 unsigned int days_;
01920 unsigned int hours_;
01921 unsigned int minutes_;
01922 double seconds_;
01923 };
01924
01931 template <typename C, typename B>
01932 bool
01933 operator== (const duration<C, B>&, const duration<C, B>&);
01934
01941 template <typename C, typename B>
01942 bool
01943 operator!= (const duration<C, B>&, const duration<C, B>&);
01944 }
01945 }
01946 }
01947
01948 #include <xsd/cxx/tree/date-time.ixx>
01949 #include <xsd/cxx/tree/date-time.txx>
01950
01951 #endif // XSD_CXX_TREE_DATE_TIME_HXX