libdballe 9.6
types.h
Go to the documentation of this file.
1#ifndef DBALLE_TYPES_H
2#define DBALLE_TYPES_H
3
8#include <dballe/fwd.h>
9#include <wreport/varinfo.h>
10#include <memory>
11#include <iosfwd>
12#include <functional>
13
14namespace wreport {
15class Var;
16}
17
18namespace dballe {
19struct CSVWriter;
20
27struct Date
28{
29 unsigned short year;
30 unsigned char month;
31 unsigned char day;
32
35
42 Date(int ye, int mo=1, int da=1);
43
45 Date(const Date& d) = default;
46
48 static Date from_julian(int jday);
49
51 bool is_missing() const;
52
54 int to_julian() const;
55
59 void to_stream_iso8601(std::ostream& out) const;
60
64 void to_csv_iso8601(CSVWriter& out) const;
65
73 int compare(const Date& other) const;
74
75 bool operator<(const Date& dt) const;
76 bool operator>(const Date& dt) const;
77 bool operator==(const Date& dt) const;
78 bool operator!=(const Date& dt) const;
79
81 static void validate(int ye, int mo, int da);
83 static int days_in_month(int year, int month);
85 static int calendar_to_julian(int year, int month, int day);
87 static void julian_to_calendar(int jday, unsigned short& year, unsigned char& month, unsigned char& day);
88};
89
90std::ostream& operator<<(std::ostream& out, const Date& dt);
91
92
99struct Time
100{
101 unsigned char hour;
102 unsigned char minute;
103 unsigned char second;
104
107
114 Time(int ho, int mi=0, int se=0);
115
116 Time(const Time& t) = default;
117
119 bool is_missing() const;
120
125 void to_stream_iso8601(std::ostream& out) const;
126
130 void to_csv_iso8601(CSVWriter& out) const;
131
139 int compare(const Time& other) const;
140
141 bool operator<(const Time& dt) const;
142 bool operator>(const Time& dt) const;
143 bool operator==(const Time& dt) const;
144 bool operator!=(const Time& dt) const;
145
152 static void validate(int ho, int mi, int se);
153};
154
155std::ostream& operator<<(std::ostream& out, const Time& t);
156
157
165{
166 unsigned short year;
167 unsigned char month;
168 unsigned char day;
169 unsigned char hour;
170 unsigned char minute;
171 unsigned char second;
172
175 Datetime(const Date& date, const Time& time);
176
183 Datetime(int ye, int mo=1, int da=1, int ho=0, int mi=0, int se=0);
184
186 static Datetime from_julian(int jday, int ho=0, int mi=0, int se=0);
187
192 static Datetime lower_bound(int ye, int mo, int da, int ho, int mi, int se);
193
198 static Datetime upper_bound(int ye, int mo, int da, int ho, int mi, int se);
199
202
205
207 Date date() const;
208
210 Time time() const;
211
213 bool is_missing() const;
214
216 int to_julian() const;
217
225 int compare(const Datetime& other) const;
226
227 bool operator==(const Datetime& o) const;
228 bool operator!=(const Datetime& o) const;
229 bool operator<(const Datetime& o) const;
230 bool operator>(const Datetime& o) const;
231 bool operator<=(const Datetime& o) const;
232 bool operator>=(const Datetime& o) const;
233
237 int print_iso8601(FILE* out, char sep='T', const char* end="\n") const;
238
242 int print(FILE* out, const char* end="\n") const;
243
251 void to_stream_iso8601(std::ostream& out, char sep='T', const char* tz="") const;
252
256 void to_csv_iso8601(CSVWriter& out, char sep='T', const char* tz="") const;
257
259 std::string to_string(char sep='T', const char* tz="") const;
260
266 static Datetime from_iso8601(const char* str);
267
276 static void validate(int ye, int mo, int da, int ho, int mi, int se);
277
282 static void normalise_h24(int& ye, int& mo, int& da, int& ho, int& mi, int& se);
283};
284
285std::ostream& operator<<(std::ostream& out, const Datetime& dt);
286
287
295{
300
301 DatetimeRange() = default;
302 DatetimeRange(const Datetime& min, const Datetime& max) : min(min), max(max) {}
304 int yemin, int momin, int damin, int homin, int mimin, int semin,
305 int yemax, int momax, int damax, int homax, int mimax, int semax);
306
308 bool is_missing() const;
309
310 bool operator==(const DatetimeRange& o) const;
311 bool operator!=(const DatetimeRange& o) const;
312 bool operator<(const DatetimeRange& o) const;
313 bool operator<=(const DatetimeRange& o) const;
314 bool operator>(const DatetimeRange& o) const;
315 bool operator>=(const DatetimeRange& o) const;
316
318 void set(const Datetime& min, const Datetime& max);
319
332 void set(int yemin, int momin, int damin, int homin, int mimin, int semin,
333 int yemax, int momax, int damax, int homax, int mimax, int semax);
334
339 void merge(const DatetimeRange& range);
340
342 bool contains(const Datetime& dt) const;
343
345 bool contains(const DatetimeRange& dtr) const;
346
348 bool is_disjoint(const DatetimeRange& dtr) const;
349
351 int print(FILE* out, const char* end="\n") const;
352};
353
354std::ostream& operator<<(std::ostream& out, const DatetimeRange& dtr);
355
356
368struct Coords
369{
371 int lat = MISSING_INT;
372
377 int lon = MISSING_INT;
378
380 Coords() = default;
382 Coords(int lat, int lon);
384 Coords(double lat, double lon);
385
387 bool is_missing() const;
388
390 void set_lat(double lat);
391
393 void set_lon(double lon);
394
396 void set_lat(int lat);
397
399 void set_lon(int lon);
400
402 void set(int lat, int lon);
403
405 void set(double lat, double lon);
406
408 double dlat() const;
409
411 double dlon() const;
412
423 int compare(const Coords& o) const;
424
425 bool operator==(const Coords& o) const;
426 bool operator!=(const Coords& o) const;
427 bool operator<(const Coords& o) const;
428 bool operator>(const Coords& o) const;
429 bool operator<=(const Coords& o) const;
430 bool operator>=(const Coords& o) const;
431
433 int print(FILE* out, const char* end="\n") const;
434
436 std::string to_string(const char* undef="-") const;
437
439 static int lat_to_int(double lat);
440
442 static int lon_to_int(double lat);
443
445 static double lat_from_int(int lat);
446
448 static double lon_from_int(int lon);
449};
450
451std::ostream& operator<<(std::ostream&, const Coords&);
452
453
468{
470 static constexpr int IMIN = -9000000;
472 static constexpr int IMAX = 9000000;
474 static constexpr double DMIN = -90.0;
476 static constexpr double DMAX = 90.0;
477
479 int imin = IMIN;
481 int imax = IMAX;
482
484 LatRange() = default;
486 LatRange(int min, int max);
488 LatRange(double min, double max);
489
490 bool operator==(const LatRange& lr) const;
491 bool operator!=(const LatRange& lr) const;
492
494 bool is_missing() const;
495
497 double dmin() const;
498
500 double dmax() const;
501
503 void get(double& min, double& max) const;
504
506 void set(int min, int max);
507
509 void set(double min, double max);
510
512 bool contains(int lat) const;
513
515 bool contains(double lat) const;
516
518 bool contains(const LatRange& lr) const;
519
526 int print(FILE* out, const char* end="\n") const;
527};
528
529std::ostream& operator<<(std::ostream& out, const LatRange& lr);
530
531
552{
554 int imin = MISSING_INT;
556 int imax = MISSING_INT;
557
559 LonRange() = default;
561 LonRange(int min, int max);
563 LonRange(double min, double max);
564
565 bool operator==(const LonRange& lr) const;
566 bool operator!=(const LonRange& lr) const;
567
569 bool is_missing() const;
570
572 double dmin() const;
573
575 double dmax() const;
576
582 void get(double& min, double& max) const;
583
588 void set(int min, int max);
589
594 void set(double min, double max);
595
600 void set(const LonRange& lr);
601
603 bool contains(int lon) const;
604
606 bool contains(double lon) const;
607
609 bool contains(const LonRange& lr) const;
610
617 int print(FILE* out, const char* end="\n") const;
618};
619
620std::ostream& operator<<(std::ostream& out, const LonRange& lr);
621
622
624struct Level
625{
629 int l1;
633 int l2;
634
635 Level(int ltype1=MISSING_INT, int l1=MISSING_INT, int ltype2=MISSING_INT, int l2=MISSING_INT)
636 : ltype1(ltype1), l1(l1), ltype2(ltype2), l2(l2) {}
637
639 bool is_missing() const;
640
641 bool operator==(const Level& o) const;
642 bool operator!=(const Level& o) const;
643 bool operator<(const Level& o) const;
644 bool operator>(const Level& o) const;
645 bool operator<=(const Level& o) const;
646 bool operator>=(const Level& o) const;
647
655 int compare(const Level& l) const;
656
660 std::string describe() const;
661
663 void to_stream(std::ostream& out, const char* undef="-") const;
664
666 std::string to_string(const char* undef="-") const;
667
671 void to_csv(CSVWriter& out) const;
672
674 static Level cloud(int ltype2=MISSING_INT, int l2=MISSING_INT);
675
677 int print(FILE* out, const char* undef="-", const char* end="\n") const;
678};
679
680std::ostream& operator<<(std::ostream& out, const Level& l);
681
682
686struct Trange
687{
689 int pind;
691 int p1;
693 int p2;
694
695 Trange(int pind=MISSING_INT, int p1=MISSING_INT, int p2=MISSING_INT)
696 : pind(pind), p1(p1), p2(p2) {}
697
699 bool is_missing() const;
700
708 int compare(const Trange& t) const;
709
710 bool operator==(const Trange& o) const;
711 bool operator!=(const Trange& o) const;
712 bool operator<(const Trange& o) const;
713 bool operator>(const Trange& o) const;
714 bool operator<=(const Trange& o) const;
715 bool operator>=(const Trange& o) const;
716
720 std::string describe() const;
721
723 void to_stream(std::ostream& out, const char* undef="-") const;
724
726 std::string to_string(const char* undef="-") const;
727
731 void to_csv(CSVWriter& out) const;
732
734 static Trange instant();
735
737 int print(FILE* out, const char* undef="-", const char* end="\n") const;
738};
739
740std::ostream& operator<<(std::ostream& out, const Trange& l);
741
742
747class Ident
748{
749protected:
750 char* value = nullptr;
751
752public:
753 Ident() = default;
754 Ident(const char* value);
755 Ident(const std::string& value);
756 Ident(const Ident& o);
757 Ident(Ident&& o);
758 ~Ident();
759 Ident& operator=(const Ident& o);
760 Ident& operator=(Ident&& o);
761 Ident& operator=(const char* o);
762 Ident& operator=(const std::string& o);
763
765 const char* get() const { return value; }
766
768 void clear();
769
770 int compare(const Ident& o) const;
771 int compare(const char* o) const;
772 int compare(const std::string& o) const;
773 template<typename T> bool operator==(const T& o) const { return compare(o) == 0; }
774 template<typename T> bool operator!=(const T& o) const { return compare(o) != 0; }
775 template<typename T> bool operator<(const T& o) const { return compare(o) < 0; }
776 template<typename T> bool operator<=(const T& o) const { return compare(o) <= 0; }
777 template<typename T> bool operator>(const T& o) const { return compare(o) > 0; }
778 template<typename T> bool operator>=(const T& o) const { return compare(o) >= 0; }
779
781 bool is_missing() const;
782
783 operator const char*() const { return value; }
784 operator std::string() const;
785};
786
787std::ostream& operator<<(std::ostream&, const Ident&);
788
789
794{
796 std::string report;
797
800
803
804
805 Station() = default;
806
808 bool is_missing() const;
809
810 bool operator==(const Station& o) const
811 {
812 return std::tie(report, coords, ident) == std::tie(o.report, o.coords, o.ident);
813 }
814 bool operator!=(const Station& o) const
815 {
816 return std::tie(report, coords, ident) != std::tie(o.report, o.coords, o.ident);
817 }
818 bool operator<(const Station& o) const
819 {
820 return std::tie(report, coords, ident) < std::tie(o.report, o.coords, o.ident);
821 }
822 bool operator<=(const Station& o) const
823 {
824 return std::tie(report, coords, ident) <= std::tie(o.report, o.coords, o.ident);
825 }
826 bool operator>(const Station& o) const
827 {
828 return std::tie(report, coords, ident) > std::tie(o.report, o.coords, o.ident);
829 }
830 bool operator>=(const Station& o) const
831 {
832 return std::tie(report, coords, ident) >= std::tie(o.report, o.coords, o.ident);
833 }
834
841 int print(FILE* out, const char* end="\n") const;
842
844 std::string to_string(const char* undef="-") const;
845};
846
847std::ostream& operator<<(std::ostream&, const Station&);
848
849
850struct DBStation : public Station
851{
857 int id = MISSING_INT;
858
859
860 DBStation() = default;
861
863 bool is_missing() const;
864
865 bool operator==(const DBStation& o) const
866 {
867 return std::tie(id, report, coords, ident) == std::tie(o.id, o.report, o.coords, o.ident);
868 }
869 bool operator!=(const DBStation& o) const
870 {
871 return std::tie(id, report, coords, ident) != std::tie(o.id, o.report, o.coords, o.ident);
872 }
873 bool operator<(const DBStation& o) const
874 {
875 return std::tie(id, report, coords, ident) < std::tie(o.id, o.report, o.coords, o.ident);
876 }
877 bool operator<=(const DBStation& o) const
878 {
879 return std::tie(id, report, coords, ident) <= std::tie(o.id, o.report, o.coords, o.ident);
880 }
881 bool operator>(const DBStation& o) const
882 {
883 return std::tie(id, report, coords, ident) > std::tie(o.id, o.report, o.coords, o.ident);
884 }
885 bool operator>=(const DBStation& o) const
886 {
887 return std::tie(id, report, coords, ident) >= std::tie(o.id, o.report, o.coords, o.ident);
888 }
889
896 int print(FILE* out, const char* end="\n") const;
897
899 std::string to_string(const char* undef="-") const;
900};
901
902std::ostream& operator<<(std::ostream&, const DBStation&);
903
904}
905
906namespace std {
907
908template<> struct hash<dballe::Level>
909{
911 typedef size_t result_type;
912 result_type operator()(argument_type const& o) const noexcept;
913};
914
915template<> struct hash<dballe::Trange>
916{
918 typedef size_t result_type;
919 result_type operator()(argument_type const& o) const noexcept;
920};
921
922template<> struct hash<dballe::Coords>
923{
925 typedef size_t result_type;
926 result_type operator()(argument_type const& o) const noexcept;
927};
928
929template<> struct hash<dballe::Ident>
930{
932 typedef size_t result_type;
933 result_type operator()(argument_type const& o) const noexcept;
934};
935
936template<> struct hash<dballe::Station>
937{
939 typedef size_t result_type;
940 result_type operator()(argument_type const& o) const noexcept;
941};
942
943template<> struct hash<dballe::DBStation>
944{
946 typedef size_t result_type;
947 result_type operator()(argument_type const& o) const noexcept;
948};
949
950}
951
952#endif
Definition: csv.h:141
A station identifier, that can be any string (including the empty string) or a missing value.
Definition: types.h:748
bool is_missing() const
Check if the Ident is set to the missing value.
const char * get() const
Get the string value (might be nullptr in case of missing value)
Definition: types.h:765
void clear()
Set to missing value.
Coordinates.
Definition: types.h:369
void set_lat(double lat)
Set the latitude only.
int compare(const Coords &o) const
Compare two Coords strutures, for use in sorting.
static int lon_to_int(double lat)
Convert a longitude to the internal integer representation.
Coords(int lat, int lon)
Construct a coords from integers in 1/100000 of a degree.
std::string to_string(const char *undef="-") const
Format to a string.
static double lon_from_int(int lon)
Convert a longitude from the internal integer representation.
double dlat() const
Get the latitude in degrees.
void set(int lat, int lon)
Set from integers in 1/100000 of a degree.
double dlon() const
Get the longitude in degrees.
void set_lon(double lon)
Set the longitude only.
static double lat_from_int(int lat)
Convert a latitude from the internal integer representation.
Coords()=default
Construct a missing Coords.
void set_lon(int lon)
Set the longitude only, in 1/100000 of a degree.
static int lat_to_int(double lat)
Convert a latitude to the internal integer representation.
int lon
Longitude in 1/100000 of a degree (5 significant digits preserved) and normalised between -180....
Definition: types.h:377
bool is_missing() const
Check if these coordinates are undefined.
int lat
Latitude in 1/100000 of a degree (5 significant digits preserved)
Definition: types.h:371
void set(double lat, double lon)
Set from values in degrees.
void set_lat(int lat)
Set the latitude only, in 1/100000 of a degree.
Coords(double lat, double lon)
Construct a coords from values in degrees.
int print(FILE *out, const char *end="\n") const
Print to an output stream.
Definition: types.h:851
bool is_missing() const
Return true if all the station fields are empty.
int id
Database ID of the station.
Definition: types.h:857
std::string to_string(const char *undef="-") const
Format to a string.
int print(FILE *out, const char *end="\n") const
Print the Station to a FILE*.
Calendar date.
Definition: types.h:28
int to_julian() const
Convert the date to Julian day.
static Date from_julian(int jday)
Create a date from a Julian day.
Date(const Date &d)=default
Copy constructor.
Date(int ye, int mo=1, int da=1)
Construct from broken down values.
bool is_missing() const
Check if this date is the missing value.
static void validate(int ye, int mo, int da)
Raise an exception if the three values do not represent a valid date.
void to_csv_iso8601(CSVWriter &out) const
Write the date as a CSV field in ISO8601 date format.
void to_stream_iso8601(std::ostream &out) const
Write the date to an output stream in ISO8601 date format.
static int days_in_month(int year, int month)
Return the number of days in the given month.
static void julian_to_calendar(int jday, unsigned short &year, unsigned char &month, unsigned char &day)
Convert a Julian day into a calendar date.
Date()
Construct a missing date.
int compare(const Date &other) const
Generic comparison.
static int calendar_to_julian(int year, int month, int day)
Convert a calendar date into a Julian day.
Range of datetimes.
Definition: types.h:295
Datetime min
Lower bound of the range.
Definition: types.h:297
bool contains(const Datetime &dt) const
Check if a Datetime is inside this range.
void merge(const DatetimeRange &range)
Merge range into this one, resulting in the smallest range that contains both.
bool contains(const DatetimeRange &dtr) const
Check if a range is inside this range (extremes included)
Datetime max
Upper bound of the range.
Definition: types.h:299
void set(const Datetime &min, const Datetime &max)
Set the extremes.
bool is_missing() const
Check if this range is open on both sides.
bool is_disjoint(const DatetimeRange &dtr) const
Check if the two ranges are completely disjoint.
void set(int yemin, int momin, int damin, int homin, int mimin, int semin, int yemax, int momax, int damax, int homax, int mimax, int semax)
Set the extremes from broken down components.
int print(FILE *out, const char *end="\n") const
Print to an output stream in ISO8601 combined format.
Date and time.
Definition: types.h:165
void set_upper_bound()
Fill possibly missing fields with their highest valid value.
static Datetime from_julian(int jday, int ho=0, int mi=0, int se=0)
Set the date from a Julian day.
int print(FILE *out, const char *end="\n") const
Print to an output stream in ISO8601 combined format.
void to_stream_iso8601(std::ostream &out, char sep='T', const char *tz="") const
Write the datetime to an output stream in ISO8601 combined format.
void to_csv_iso8601(CSVWriter &out, char sep='T', const char *tz="") const
Write the datetime as a CSV field in ISO8601 date format.
static void validate(int ye, int mo, int da, int ho, int mi, int se)
Raise an exception if the three values do not represent a valid date/time.
Datetime(int ye, int mo=1, int da=1, int ho=0, int mi=0, int se=0)
Construct from broken down values.
static Datetime lower_bound(int ye, int mo, int da, int ho, int mi, int se)
Return a Datetime filling the parts set to MISSING_INT with their lowest possible values.
static Datetime from_iso8601(const char *str)
Parse an ISO8601 datetime string.
int compare(const Datetime &other) const
Generic comparison.
Time time() const
Return a Time with this time.
Datetime()
Construct a missing datetime.
Date date() const
Return a Date with this date.
static Datetime upper_bound(int ye, int mo, int da, int ho, int mi, int se)
Return a Datetime filling the parts set to MISSING_INT with their highest possible values.
int print_iso8601(FILE *out, char sep='T', const char *end="\n") const
Print to an output stream in ISO8601 combined format.
int to_julian() const
Convert the date to Julian day.
std::string to_string(char sep='T', const char *tz="") const
Write to a string in ISO8601 combined format.
bool is_missing() const
Check if this datetime is the missing value.
void set_lower_bound()
Fill possibly missing fields with their lowest valid value.
static void normalise_h24(int &ye, int &mo, int &da, int &ho, int &mi, int &se)
Convert a datetime with an hour of 24:00:00 to hour 00:00:00 of the following day.
Range of latitudes.
Definition: types.h:468
bool contains(int lat) const
Check if a point is inside this range (extremes included)
static constexpr double DMAX
Maximum possible double value.
Definition: types.h:476
static constexpr double DMIN
Minimum possible double value.
Definition: types.h:474
LatRange(double min, double max)
Construct a LatRange given extremes in degrees.
bool contains(double lat) const
Check if a point is inside this range (extremes included)
int print(FILE *out, const char *end="\n") const
Print the LatRange to a FILE*.
double dmax() const
Get the upper extreme as double.
void set(int min, int max)
Set the extremes as integers.
int imax
Maximum latitude.
Definition: types.h:481
bool contains(const LatRange &lr) const
Check if a range is inside this range (extremes included)
static constexpr int IMAX
Maximum possible integer value.
Definition: types.h:472
double dmin() const
Get the lower extreme as double.
int imin
Minimum latitude.
Definition: types.h:479
static constexpr int IMIN
Minimum possible integer value.
Definition: types.h:470
LatRange()=default
Construct a LatRange matching any latitude.
LatRange(int min, int max)
Construct a LatRange given integer extremes.
void set(double min, double max)
Set the extremes in degrees.
void get(double &min, double &max) const
Get the extremes as double.
bool is_missing() const
Return true if the LatRange matches any latitude.
Vertical level or layer.
Definition: types.h:625
int l1
L1 value of the level or the first layer.
Definition: types.h:629
int l2
L2 value of the second layer.
Definition: types.h:633
int ltype1
Type of the level or the first layer.
Definition: types.h:627
int print(FILE *out, const char *undef="-", const char *end="\n") const
Print to an output stream.
int ltype2
Type of the the second layer.
Definition: types.h:631
void to_csv(CSVWriter &out) const
Write the datetime to a CSV writer as 4 fields.
int compare(const Level &l) const
Generic comparison.
bool is_missing() const
Check if this level is fully set to the missing value.
std::string to_string(const char *undef="-") const
Format to a string.
void to_stream(std::ostream &out, const char *undef="-") const
Format to an output stream.
static Level cloud(int ltype2=MISSING_INT, int l2=MISSING_INT)
Create a cloud special level.
std::string describe() const
Return a string description of this level.
Range of longitudes.
Definition: types.h:552
double dmin() const
Get the lower extreme as double, or -180.0 if missing.
int print(FILE *out, const char *end="\n") const
Print the LonRange to a FILE*.
int imin
Initial point of the longitude range.
Definition: types.h:554
int imax
Final point of the longitude range.
Definition: types.h:556
bool contains(const LonRange &lr) const
Check if a range is inside this range (extremes included)
bool is_missing() const
Return true if the LonRange matches any longitude.
void set(const LonRange &lr)
Set from another LonRange, throwing an error in case of open ended ranges.
void set(int min, int max)
Set the extremes as integers, throwing an error in case of open ended ranges.
LonRange()=default
Construct a range that matches any longitude.
bool contains(double lon) const
Check if a point is inside this range (extremes included)
double dmax() const
Get the upper extreme as double, or 180.0 if missing.
bool contains(int lon) const
Check if a point is inside this range (extremes included)
LonRange(double min, double max)
Construct a range given extremes in degrees.
void get(double &min, double &max) const
Get the extremes in degrees.
LonRange(int min, int max)
Construct a range given integer extremes.
void set(double min, double max)
Set the extremes in degrees, throwing an error in case of open ended ranges.
Station information.
Definition: types.h:794
int print(FILE *out, const char *end="\n") const
Print the Station to a FILE*.
Ident ident
Mobile station identifier.
Definition: types.h:802
bool is_missing() const
Return true if all the station fields are empty.
std::string to_string(const char *undef="-") const
Format to a string.
Coords coords
Station coordinates.
Definition: types.h:799
std::string report
Report name for this station.
Definition: types.h:796
Time of the day.
Definition: types.h:100
Time(int ho, int mi=0, int se=0)
Construct from broken down values.
Time()
Construct a missing time.
void to_csv_iso8601(CSVWriter &out) const
Write the time as a CSV field in ISO8601 date format.
void to_stream_iso8601(std::ostream &out) const
Write the time to an output stream in ISO8601 extended format (hh:mm:ss).
int compare(const Time &other) const
Generic comparison.
bool is_missing() const
Check if this time is the missing value.
static void validate(int ho, int mi, int se)
Raise an exception if the three values do not represent a valid time.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:687
int p1
Time range P1 indicator.
Definition: types.h:691
void to_csv(CSVWriter &out) const
Write the datetime to a CSV writer as 3 fields.
int print(FILE *out, const char *undef="-", const char *end="\n") const
Print to an output stream.
void to_stream(std::ostream &out, const char *undef="-") const
Format to an output stream.
int pind
Time range type indicator.
Definition: types.h:689
static Trange instant()
Time range for instant values.
std::string describe() const
Return a string description of this time range.
int p2
Time range P2 indicator.
Definition: types.h:693
std::string to_string(const char *undef="-") const
Format to a string.
int compare(const Trange &t) const
Generic comparison.
bool is_missing() const
Check if this level is fully set to the missing value.