libdballe 9.13
types.h
Go to the documentation of this file.
1#ifndef DBALLE_TYPES_H
2#define DBALLE_TYPES_H
3
7
8#include <dballe/fwd.h>
9#include <functional>
10#include <iosfwd>
11#include <memory>
12#include <wreport/varinfo.h>
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,
88 unsigned char& month, unsigned char& day);
89};
90
91std::ostream& operator<<(std::ostream& out, const Date& dt);
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
164{
165 unsigned short year;
166 unsigned char month;
167 unsigned char day;
168 unsigned char hour;
169 unsigned char minute;
170 unsigned char second;
171
174 Datetime(const Date& date, const Time& time);
175
182 Datetime(int ye, int mo = 1, int da = 1, int ho = 0, int mi = 0,
183 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',
252 const char* tz = "") const;
253
257 void to_csv_iso8601(CSVWriter& out, char sep = 'T',
258 const char* tz = "") const;
259
261 std::string to_string(char sep = 'T', const char* tz = "") const;
262
268 static Datetime from_iso8601(const char* str);
269
278 static void validate(int ye, int mo, int da, int ho, int mi, int se);
279
284 static void normalise_h24(int& ye, int& mo, int& da, int& ho, int& mi,
285 int& se);
286};
287
288std::ostream& operator<<(std::ostream& out, const Datetime& dt);
289
296struct DatetimeRange
297{
302
303 DatetimeRange() = default;
304 DatetimeRange(const Datetime& min, const Datetime& max) : min(min), max(max)
305 {
306 }
307 DatetimeRange(int yemin, int momin, int damin, int homin, int mimin,
308 int semin, int yemax, int momax, int damax, int homax,
309 int mimax, int semax);
310
312 bool is_missing() const;
313
314 bool operator==(const DatetimeRange& o) const;
315 bool operator!=(const DatetimeRange& o) const;
316 bool operator<(const DatetimeRange& o) const;
317 bool operator<=(const DatetimeRange& o) const;
318 bool operator>(const DatetimeRange& o) const;
319 bool operator>=(const DatetimeRange& o) const;
320
322 void set(const Datetime& min, const Datetime& max);
323
336 void set(int yemin, int momin, int damin, int homin, int mimin, int semin,
337 int yemax, int momax, int damax, int homax, int mimax, int semax);
338
343 void merge(const DatetimeRange& range);
344
346 bool contains(const Datetime& dt) const;
347
349 bool contains(const DatetimeRange& dtr) const;
350
352 bool is_disjoint(const DatetimeRange& dtr) const;
353
355 int print(FILE* out, const char* end = "\n") const;
356};
357
358std::ostream& operator<<(std::ostream& out, const DatetimeRange& dtr);
359
371struct Coords
372{
374 int lat = MISSING_INT;
375
380 int lon = MISSING_INT;
381
383 Coords() = default;
385 Coords(int lat, int lon);
387 Coords(double lat, double lon);
388
390 bool is_missing() const;
391
393 void set_lat(double lat);
394
396 void set_lon(double lon);
397
399 void set_lat(int lat);
400
402 void set_lon(int lon);
403
405 void set(int lat, int lon);
406
408 void set(double lat, double lon);
409
411 double dlat() const;
412
414 double dlon() const;
415
426 int compare(const Coords& o) const;
427
428 bool operator==(const Coords& o) const;
429 bool operator!=(const Coords& o) const;
430 bool operator<(const Coords& o) const;
431 bool operator>(const Coords& o) const;
432 bool operator<=(const Coords& o) const;
433 bool operator>=(const Coords& o) const;
434
436 int print(FILE* out, const char* end = "\n") const;
437
439 std::string to_string(const char* undef = "-") const;
440
442 static int lat_to_int(double lat);
443
445 static int lon_to_int(double lat);
446
448 static double lat_from_int(int lat);
449
451 static double lon_from_int(int lon);
452};
453
454std::ostream& operator<<(std::ostream&, const Coords&);
455
470{
472 static constexpr int IMIN = -9000000;
474 static constexpr int IMAX = 9000000;
476 static constexpr double DMIN = -90.0;
478 static constexpr double DMAX = 90.0;
479
481 int imin = IMIN;
483 int imax = IMAX;
484
486 LatRange() = default;
488 LatRange(int min, int max);
490 LatRange(double min, double max);
491
492 bool operator==(const LatRange& lr) const;
493 bool operator!=(const LatRange& lr) const;
494
496 bool is_missing() const;
497
499 double dmin() const;
500
502 double dmax() const;
503
505 void get(double& min, double& max) const;
506
508 void set(int min, int max);
509
511 void set(double min, double max);
512
514 bool contains(int lat) const;
515
517 bool contains(double lat) const;
518
520 bool contains(const LatRange& lr) const;
521
528 int print(FILE* out, const char* end = "\n") const;
529};
530
531std::ostream& operator<<(std::ostream& out, const LatRange& lr);
532
553{
555 int imin = MISSING_INT;
557 int imax = MISSING_INT;
558
560 LonRange() = default;
562 LonRange(int min, int max);
564 LonRange(double min, double max);
565
566 bool operator==(const LonRange& lr) const;
567 bool operator!=(const LonRange& lr) const;
568
570 bool is_missing() const;
571
573 double dmin() const;
574
576 double dmax() const;
577
583 void get(double& min, double& max) const;
584
589 void set(int min, int max);
590
595 void set(double min, double max);
596
601 void set(const LonRange& lr);
602
604 bool contains(int lon) const;
605
607 bool contains(double lon) const;
608
610 bool contains(const LonRange& lr) const;
611
618 int print(FILE* out, const char* end = "\n") const;
619};
620
621std::ostream& operator<<(std::ostream& out, const LonRange& lr);
622
624struct Level
625{
629 int l1;
633 int l2;
634
635 Level(int ltype1 = MISSING_INT, int l1 = MISSING_INT,
636 int ltype2 = MISSING_INT, int l2 = MISSING_INT)
638 {
639 }
640
642 bool is_missing() const;
643
644 bool operator==(const Level& o) const;
645 bool operator!=(const Level& o) const;
646 bool operator<(const Level& o) const;
647 bool operator>(const Level& o) const;
648 bool operator<=(const Level& o) const;
649 bool operator>=(const Level& o) const;
650
658 int compare(const Level& l) const;
659
663 std::string describe() const;
664
666 void to_stream(std::ostream& out, const char* undef = "-") const;
667
669 std::string to_string(const char* undef = "-") const;
670
674 void to_csv(CSVWriter& out) const;
675
677 static Level cloud(int ltype2 = MISSING_INT, int l2 = MISSING_INT);
678
680 int print(FILE* out, const char* undef = "-", const char* end = "\n") const;
681};
682
683std::ostream& operator<<(std::ostream& out, const Level& l);
684
688struct Trange
689{
691 int pind;
693 int p1;
695 int p2;
696
697 Trange(int pind = MISSING_INT, int p1 = MISSING_INT, int p2 = MISSING_INT)
698 : pind(pind), p1(p1), p2(p2)
699 {
700 }
701
703 bool is_missing() const;
704
712 int compare(const Trange& t) const;
713
714 bool operator==(const Trange& o) const;
715 bool operator!=(const Trange& o) const;
716 bool operator<(const Trange& o) const;
717 bool operator>(const Trange& o) const;
718 bool operator<=(const Trange& o) const;
719 bool operator>=(const Trange& o) const;
720
724 std::string describe() const;
725
727 void to_stream(std::ostream& out, const char* undef = "-") const;
728
730 std::string to_string(const char* undef = "-") const;
731
735 void to_csv(CSVWriter& out) const;
736
738 static Trange instant();
739
741 int print(FILE* out, const char* undef = "-", const char* end = "\n") const;
742};
743
744std::ostream& operator<<(std::ostream& out, const Trange& l);
745
750class Ident
751{
752protected:
753 char* value = nullptr;
754
755public:
756 Ident() = default;
757 Ident(const char* value);
758 Ident(const std::string& value);
759 Ident(const Ident& o);
760 Ident(Ident&& o);
761 ~Ident();
762 Ident& operator=(const Ident& o);
763 Ident& operator=(Ident&& o);
764 Ident& operator=(const char* o);
765 Ident& operator=(const std::string& o);
766
768 const char* get() const { return value; }
769
771 void clear();
772
773 int compare(const Ident& o) const;
774 int compare(const char* o) const;
775 int compare(const std::string& o) const;
776 template <typename T> bool operator==(const T& o) const
777 {
778 return compare(o) == 0;
779 }
780 template <typename T> bool operator!=(const T& o) const
781 {
782 return compare(o) != 0;
783 }
784 template <typename T> bool operator<(const T& o) const
785 {
786 return compare(o) < 0;
787 }
788 template <typename T> bool operator<=(const T& o) const
789 {
790 return compare(o) <= 0;
791 }
792 template <typename T> bool operator>(const T& o) const
793 {
794 return compare(o) > 0;
795 }
796 template <typename T> bool operator>=(const T& o) const
797 {
798 return compare(o) >= 0;
799 }
800
802 bool is_missing() const;
803
804 operator const char*() const { return value; }
805 operator std::string() const;
806};
807
808std::ostream& operator<<(std::ostream&, const Ident&);
809
815class Report
816{
817protected:
818 std::string value;
819
820public:
821 Report() = default;
822 // cppcheck-suppress noExplicitConstructor
823 Report(const char* value);
824 // cppcheck-suppress noExplicitConstructor
825 Report(const std::string& value);
826 Report(const Report& value);
827 Report(Report&& value);
828
829 Report& operator=(const char* value);
830 Report& operator=(const std::string& value);
831 Report& operator=(const Report& value);
832 Report& operator=(Report&& value);
833
834 ~Report();
835
836 operator const char*() const { return value.c_str(); }
837 operator std::string() const { return value; }
838
839 bool operator<(const Report& o) const { return value < o.value; }
840 template <typename T> bool operator<(const T& o) const
841 {
842 return *this < Report(o);
843 }
844 bool operator<=(const Report& o) const { return value <= o.value; }
845 template <typename T> bool operator<=(const T& o) const
846 {
847 return *this <= Report(o);
848 }
849 bool operator>(const Report& o) const { return value > o.value; }
850 template <typename T> bool operator>(const T& o) const
851 {
852 return *this > Report(o);
853 }
854 bool operator>=(const Report& o) const { return value >= o.value; }
855 template <typename T> bool operator>=(const T& o) const
856 {
857 return *this >= Report(o);
858 }
859 bool operator==(const Report& o) const { return value == o.value; }
860 template <typename T> bool operator==(const T& o) const
861 {
862 return *this == Report(o);
863 }
864 bool operator!=(const Report& o) const { return value != o.value; }
865 template <typename T> bool operator!=(const T& o) const
866 {
867 return *this != Report(o);
868 }
869
870 bool empty() const { return value.empty(); }
871 void clear() { return value.clear(); }
872 const char* c_str() const { return value.c_str(); }
873};
874
878struct Station
879{
882
885
888
889 Station() = default;
890
892 bool is_missing() const;
893
894 bool operator==(const Station& o) const
895 {
896 return std::tie(report, coords, ident) ==
897 std::tie(o.report, o.coords, o.ident);
898 }
899 bool operator!=(const Station& o) const
900 {
901 return std::tie(report, coords, ident) !=
902 std::tie(o.report, o.coords, o.ident);
903 }
904 bool operator<(const Station& o) const
905 {
906 return std::tie(report, coords, ident) <
907 std::tie(o.report, o.coords, o.ident);
908 }
909 bool operator<=(const Station& o) const
910 {
911 return std::tie(report, coords, ident) <=
912 std::tie(o.report, o.coords, o.ident);
913 }
914 bool operator>(const Station& o) const
915 {
916 return std::tie(report, coords, ident) >
917 std::tie(o.report, o.coords, o.ident);
918 }
919 bool operator>=(const Station& o) const
920 {
921 return std::tie(report, coords, ident) >=
922 std::tie(o.report, o.coords, o.ident);
923 }
924
931 int print(FILE* out, const char* end = "\n") const;
932
934 std::string to_string(const char* undef = "-") const;
935};
936
937std::ostream& operator<<(std::ostream&, const Station&);
938
939struct DBStation : public Station
940{
946 int id = MISSING_INT;
947
948 DBStation() = default;
949
951 bool is_missing() const;
952
953 bool operator==(const DBStation& o) const
954 {
955 return std::tie(id, report, coords, ident) ==
956 std::tie(o.id, o.report, o.coords, o.ident);
957 }
958 bool operator!=(const DBStation& o) const
959 {
960 return std::tie(id, report, coords, ident) !=
961 std::tie(o.id, o.report, o.coords, o.ident);
962 }
963 bool operator<(const DBStation& o) const
964 {
965 return std::tie(id, report, coords, ident) <
966 std::tie(o.id, o.report, o.coords, o.ident);
967 }
968 bool operator<=(const DBStation& o) const
969 {
970 return std::tie(id, report, coords, ident) <=
971 std::tie(o.id, o.report, o.coords, o.ident);
972 }
973 bool operator>(const DBStation& o) const
974 {
975 return std::tie(id, report, coords, ident) >
976 std::tie(o.id, o.report, o.coords, o.ident);
977 }
978 bool operator>=(const DBStation& o) const
979 {
980 return std::tie(id, report, coords, ident) >=
981 std::tie(o.id, o.report, o.coords, o.ident);
982 }
983
990 int print(FILE* out, const char* end = "\n") const;
991
993 std::string to_string(const char* undef = "-") const;
994};
995
996std::ostream& operator<<(std::ostream&, const DBStation&);
997
998} // namespace dballe
999
1000namespace std {
1001
1002template <> struct hash<dballe::Level>
1003{
1004 typedef dballe::Level argument_type;
1005 typedef size_t result_type;
1006 result_type operator()(argument_type const& o) const noexcept;
1007};
1008
1009template <> struct hash<dballe::Trange>
1010{
1011 typedef dballe::Trange argument_type;
1012 typedef size_t result_type;
1013 result_type operator()(argument_type const& o) const noexcept;
1014};
1015
1016template <> struct hash<dballe::Coords>
1017{
1018 typedef dballe::Coords argument_type;
1019 typedef size_t result_type;
1020 result_type operator()(argument_type const& o) const noexcept;
1021};
1022
1023template <> struct hash<dballe::Ident>
1024{
1025 typedef dballe::Ident argument_type;
1026 typedef size_t result_type;
1027 result_type operator()(argument_type const& o) const noexcept;
1028};
1029
1030template <> struct hash<dballe::Station>
1031{
1032 typedef dballe::Station argument_type;
1033 typedef size_t result_type;
1034 result_type operator()(argument_type const& o) const noexcept;
1035};
1036
1037template <> struct hash<dballe::DBStation>
1038{
1039 typedef dballe::DBStation argument_type;
1040 typedef size_t result_type;
1041 result_type operator()(argument_type const& o) const noexcept;
1042};
1043
1044} // namespace std
1045
1046#endif
Definition csv.h:140
A station identifier, that can be any string (including the empty string) or a missing value.
Definition types.h:751
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:768
void clear()
Set to missing value.
A report name.
Definition types.h:816
Coordinates.
Definition types.h:372
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:380
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:374
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:940
bool is_missing() const
Return true if all the station fields are empty.
int id
Database ID of the station.
Definition types.h:946
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:297
Datetime min
Lower bound of the range.
Definition types.h:299
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:301
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:164
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:470
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:478
static constexpr double DMIN
Minimum possible double value.
Definition types.h:476
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:483
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:474
double dmin() const
Get the lower extreme as double.
int imin
Minimum latitude.
Definition types.h:481
static constexpr int IMIN
Minimum possible integer value.
Definition types.h:472
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:553
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:555
int imax
Final point of the longitude range.
Definition types.h:557
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:879
int print(FILE *out, const char *end="\n") const
Print the Station to a FILE*.
Ident ident
Mobile station identifier.
Definition types.h:887
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:884
Report report
Report name for this station.
Definition types.h:881
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:689
int p1
Time range P1 indicator.
Definition types.h:693
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:691
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:695
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.