mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert taxonomy.c to C++
Since the taxonomy is now a real C++ struct with constructor and destructor, dive_site has to be converted to C++ as well. A bit hairy for now, but will ultimately be distinctly simpler. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3c1401785b
commit
3f8b4604be
39 changed files with 259 additions and 336 deletions
|
|
@ -3,8 +3,9 @@
|
|||
#define TAXONOMY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum taxonomy_category {
|
||||
TC_NONE,
|
||||
|
|
@ -24,29 +25,22 @@ enum taxonomy_origin {
|
|||
GEOCOPIED
|
||||
};
|
||||
|
||||
extern char *taxonomy_category_names[TC_NR_CATEGORIES];
|
||||
extern char *taxonomy_api_names[TC_NR_CATEGORIES];
|
||||
extern const char *taxonomy_category_names[TC_NR_CATEGORIES];
|
||||
extern const char *taxonomy_api_names[TC_NR_CATEGORIES];
|
||||
|
||||
struct taxonomy {
|
||||
int category; /* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
|
||||
const char *value; /* the value returned, parsed, or manually entered for that category */
|
||||
enum taxonomy_origin origin;
|
||||
taxonomy_category category; /* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
|
||||
std::string value; /* the value returned, parsed, or manually entered for that category */
|
||||
taxonomy_origin origin;
|
||||
};
|
||||
|
||||
/* the data block contains 3 taxonomy structures - unused ones have a tag value of NONE */
|
||||
struct taxonomy_data {
|
||||
int nr;
|
||||
struct taxonomy *category;
|
||||
};
|
||||
/* the data block contains taxonomy structures - unused ones have a tag value of NONE */
|
||||
using taxonomy_data = std::vector<taxonomy>;
|
||||
|
||||
void free_taxonomy(struct taxonomy_data *t);
|
||||
void copy_taxonomy(const struct taxonomy_data *orig, struct taxonomy_data *copy);
|
||||
const char *taxonomy_get_value(const struct taxonomy_data *t, enum taxonomy_category cat);
|
||||
const char *taxonomy_get_country(const struct taxonomy_data *t);
|
||||
void taxonomy_set_category(struct taxonomy_data *t, enum taxonomy_category category, const char *value, enum taxonomy_origin origin);
|
||||
void taxonomy_set_country(struct taxonomy_data *t, const char *country, enum taxonomy_origin origin);
|
||||
std::string taxonomy_get_value(const taxonomy_data &t, enum taxonomy_category cat);
|
||||
std::string taxonomy_get_country(const taxonomy_data &t);
|
||||
void taxonomy_set_category(taxonomy_data &t, enum taxonomy_category category, const std::string &value, enum taxonomy_origin origin);
|
||||
void taxonomy_set_country(taxonomy_data &t, const std::string &country, enum taxonomy_origin origin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // TAXONOMY_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue