mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create/retrieve dive_site by name.
When we are working on the location management, we want to get a new dive_site if the dive_site name changed unless there's no dive_site by that name, then we create it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3b2a02dffa
commit
ca5606d3e9
2 changed files with 17 additions and 1 deletions
16
divesite.c
16
divesite.c
|
@ -200,3 +200,19 @@ void clear_dive_site(struct dive_site *ds)
|
||||||
ds->taxonomy.nr = 0;
|
ds->taxonomy.nr = 0;
|
||||||
free_taxonomy(&ds->taxonomy);
|
free_taxonomy(&ds->taxonomy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t find_or_create_dive_site_with_name(const char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct dive_site *ds;
|
||||||
|
bool found = false;
|
||||||
|
for_each_dive_site(i,ds) {
|
||||||
|
if (same_string(name, ds->name)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ds)
|
||||||
|
return ds->uuid;
|
||||||
|
return create_dive_site(name);
|
||||||
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ uint32_t get_dive_site_uuid_by_gps_proximity(degrees_t latitude, degrees_t longi
|
||||||
bool dive_site_is_empty(struct dive_site *ds);
|
bool dive_site_is_empty(struct dive_site *ds);
|
||||||
void copy_dive_site(struct dive_site *orig, struct dive_site *copy);
|
void copy_dive_site(struct dive_site *orig, struct dive_site *copy);
|
||||||
void clear_dive_site(struct dive_site *ds);
|
void clear_dive_site(struct dive_site *ds);
|
||||||
|
uint32_t find_or_create_dive_site_with_name(const char *name);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue