DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
metadatatable.h
Go to the documentation of this file.
1 #ifndef METADATATABLE_H
2 #define METADATATABLE_H
3 
4 #include "commons_global.h"
5 #include "idtypes.h"
6 
7 #include "sqlitefielddef.h"
8 #include "sqlitetable.h"
9 using namespace sqlite;
10 
11 #include <vector>
12 #include <string>
13 #include <map>
14 
15 #include <boost/lexical_cast.hpp>
16 
17 
18 class COMMONSSHARED_EXPORT MetadataTable : public SQLiteTable
19 {
20  struct Impl;
21  std::unique_ptr<Impl> p;
22 
23  FieldDef<FieldType::Text> fldKey = makeFieldDef("Key",FieldType::Text()).primaryKey();
24  FieldDef<FieldType::Text> fldValue = makeFieldDef("Value",FieldType::Text());
25 
26  void lazyInit();
27 public:
28  MetadataTable(std::shared_ptr<SQLiteStorage> db, std::string name);
29  ~MetadataTable() noexcept;
30 
31  void dropAndCreate();
32 
33  void setMetadata (std::string key, std::string value);
34  std::string getMetadata (std::string key);
35 
36  template <typename T>
37  T getMetadataAs(std::string key) {
38  return boost::lexical_cast<T>(getMetadata(key));
39  }
40 };
41 
42 #endif // METADATATABLE_H
Definition: sqliteoutputstorage.h:33
std::pair< box, unsigned > value
Definition: diffusion.cpp:30
Definition: metadatatable.cpp:8
T getMetadataAs(std::string key)
Definition: metadatatable.h:37
Definition: metadatatable.h:18
#define COMMONSSHARED_EXPORT
Definition: commons_global.h:23