Add helper function to detect empty dive sites

No point in keeping those.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-02-13 22:53:03 -08:00
parent cd77e2e700
commit 7ca3d859dc
2 changed files with 13 additions and 0 deletions

View file

@ -106,3 +106,13 @@ uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees
return ds->uuid;
}
/* a uuid is always present - but if all the other fields are empty, the dive site is pointless */
bool dive_site_is_empty(struct dive_site *ds)
{
return same_string(ds->name, "") &&
same_string(ds->description, "") &&
same_string(ds->notes, "") &&
ds->latitude.udeg == 0 &&
ds->longitude.udeg == 0;
}

View file

@ -6,6 +6,8 @@
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
struct dive_site
@ -51,6 +53,7 @@ uint32_t create_dive_site(const char *name);
uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude);
uint32_t get_dive_site_uuid_by_name(const char *name, struct dive_site **dsp);
uint32_t get_dive_site_uuid_by_gps(degrees_t latitude, degrees_t longitude, struct dive_site **dsp);
bool dive_site_is_empty(struct dive_site *ds);
#ifdef __cplusplus
}