libdballe 9.13
internals.h
1#ifndef DBALLE_DB_V7_INTERNALS_H
2#define DBALLE_DB_V7_INTERNALS_H
3
4#include <vector>
5#include <wreport/var.h>
6
7namespace dballe {
8namespace db {
9namespace v7 {
10
13 : public std::vector<std::pair<wreport::Varcode, const char*>>
14{
15 void add(wreport::Varcode code, const char* value)
16 {
17 push_back(std::make_pair(code, value));
18 }
19
21 const char* get(wreport::Varcode code) const
22 {
23 for (const_iterator i = begin(); i != end(); ++i)
24 if (i->first == code)
25 return i->second;
26 return nullptr;
27 }
28
33 const char* pop(wreport::Varcode code)
34 {
35 const char* res = nullptr;
36 for (iterator i = begin(); i != end(); ++i)
37 {
38 if (i->first == code)
39 {
40 res = i->second;
41 i->second = nullptr;
42 break;
43 }
44 }
45 while (!empty() && back().second == nullptr)
46 pop_back();
47 return res;
48 }
49};
50
51} // namespace v7
52} // namespace db
53} // namespace dballe
54
55#endif
Store a list of attributes to be inserted/updated in the database.
Definition internals.h:14
const char * pop(wreport::Varcode code)
Get a value by code, returns nullptr if not found, removes it from the AttributeList.
Definition internals.h:33
const char * get(wreport::Varcode code) const
Get a value by code, returns nullptr if not found.
Definition internals.h:21