/usr/include/dballe/db/sql/attrv6.h is in libdballe-dev 7.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | /*
* db/sql/attrv6 - v6 implementation of attr table
*
* Copyright (C) 2005--2015 ARPA-SIM <urpsim@smr.arpa.emr.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author: Enrico Zini <enrico@enricozini.com>
*/
#ifndef DBALLE_DB_SQL_ATTRV6_H
#define DBALLE_DB_SQL_ATTRV6_H
#include <dballe/db/sql/datav6.h>
#include <wreport/var.h>
#include <functional>
#include <vector>
#include <memory>
#include <cstdio>
namespace dballe {
struct Record;
namespace db {
namespace sql {
struct AttributeList;
namespace bulk {
struct InsertAttrsV6;
}
/**
* Precompiled queries to manipulate the attr table
*/
struct AttrV6
{
public:
enum UpdateMode {
UPDATE,
IGNORE,
ERROR,
};
virtual ~AttrV6();
/// Insert all attributes of the given variable
void insert_attributes(Transaction& t, int id_data, const wreport::Var& var, UpdateMode update_mode=UPDATE);
/// Bulk attribute insert
virtual void insert(Transaction& t, sql::bulk::InsertAttrsV6& vars, UpdateMode update_mode=UPDATE) = 0;
/**
* Load from the database all the attributes for var
*
* @param var
* wreport::Var to which the resulting attributes will be added
* @return
* The error indicator for the function (See @ref error.h)
*/
virtual void read(int id_data, std::function<void(std::unique_ptr<wreport::Var>)> dest) = 0;
/**
* Dump the entire contents of the table to an output stream
*/
virtual void dump(FILE* out) = 0;
};
namespace bulk {
/**
* Workflow information about an attribute variable listed for bulk
* insert/update
*/
struct AttrV6 : public Item
{
int id_data;
const wreport::Var* attr;
AttrV6(const wreport::Var* attr, int id_data=-1)
: id_data(id_data), attr(attr)
{
}
bool operator<(const AttrV6& v) const
{
if (int d = id_data - v.id_data) return d < 0;
return attr->code() < v.attr->code();
}
void dump(FILE* out) const;
};
struct InsertAttrsV6 : public std::vector<AttrV6>
{
void add(const wreport::Var* attr, int id_data)
{
emplace_back(attr, id_data);
}
// Add all attributes of the given variable
void add_all(const wreport::Var& var, int id_data);
void dump(FILE* out) const;
};
/**
* Helper class for annotating InsertV6 variables with the current status of
* the database.
*/
struct AnnotateAttrsV6
{
InsertAttrsV6& attrs;
InsertAttrsV6::iterator iter;
bool do_insert = false;
bool do_update = false;
AnnotateAttrsV6(InsertAttrsV6& attrs);
bool annotate(int id_data, wreport::Varcode code, const char* value);
void annotate_end();
void dump(FILE* out) const;
};
}
}
}
}
#endif
|