forked from osm2pgsql-dev/osm2pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyvals.hpp
64 lines (53 loc) · 1.6 KB
/
keyvals.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* Common key-value list processing
*
* Used as a small general purpose store for
* tags, segment lists etc
*
*/
#ifndef KEYVAL_H
#define KEYVAL_H
#include <boost/shared_ptr.hpp>
struct keyval {
std::string key;
std::string value;
/* if a hstore column is requested we need a flag to store if a key
has its own column because it should not be added to the hstore
in this case
*/
int has_column;
private:
keyval *next;
keyval *prev;
public:
keyval() : has_column(0), next(this), prev(this) {}
keyval(const std::string &name_, const std::string &value_)
: key(name_), value(value_), has_column(0), next(NULL), prev(NULL)
{}
keyval(const keyval &other);
~keyval() {}
unsigned int countList() const;
bool listHasData() const { return next != this; }
const std::string *getItem(const std::string &name) const;
keyval *getTag(const std::string &name);
void removeTag();
keyval *firstItem() const { return listHasData() ? next : NULL; }
keyval *nextItem(const keyval *item) const {
return item->next == this ? NULL : item->next;
}
keyval *popItem();
void pushItem(keyval *item);
int addItem(const std::string &name, const std::string &value, bool noDupe);
void resetList();
void cloneList(keyval *target);
void moveList(keyval *target);
private:
keyval(const std::string &key_, const std::string &value_, keyval *after)
: key(key_), value(value_), has_column(0)
{
next = after->next;
prev = after;
after->next->prev = this;
after->next = this;
}
};
#endif