This file is indexed.

/usr/include/dballe/db/v7/qbuilder.h is in libdballe-dev 7.21-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
#ifndef DBA_DB_V7_QBUILDER_H
#define DBA_DB_V7_QBUILDER_H

#include <dballe/sql/querybuf.h>
#include <dballe/db/v7/db.h>
#include <dballe/core/query.h>
#include <regex.h>

namespace dballe {
struct Varmatch;

namespace db {
namespace v7 {

/// Build SQL queries for V7 databases
struct QueryBuilder
{
    dballe::sql::Connection& conn;

    /** Database to operate on */
    DB& db;

    /**
     * If defined, it need to point to the identifier to be used as the only
     * bound input parameter.
     *
     * If not defined, there are no bound input parameters in this query
     */
    const char* bind_in_ident = nullptr;

    bool select_station = false; // ana_id, lat, lon, ident

    bool select_varinfo = false; // rep_cod, id_ltr, varcode

    // IdQuery
    bool select_data_id = false; // id_data

    // DataQuery
    bool select_data = false; // datetime, value

    // SummaryQuery
    bool select_summary_details = false; // id_data, datetime, datetimemax

    /// Query object
    const core::Query& query;

    /** Dynamically generated SQL query */
    dballe::sql::Querybuf sql_query;

    /// FROM part of the SQL query
    dballe::sql::Querybuf sql_from;

    /// WHERE part of the SQL query
    dballe::sql::Querybuf sql_where;

    /// Modifier flags to enable special query behaviours
    const unsigned int modifiers;

    /// True if we are querying station information, rather than measured data
    bool query_station_vars;

    QueryBuilder(DB& db, const core::Query& query, unsigned int modifiers, bool query_station_vars);
    virtual ~QueryBuilder() {}

    void build();

protected:
    // Add WHERE conditions
    bool add_pa_where(const char* tbl);
    bool add_dt_where(const char* tbl);
    bool add_ltr_where(const char* tbl);
    bool add_varcode_where(const char* tbl);
    bool add_repinfo_where(const char* tbl);
    bool add_datafilter_where(const char* tbl);

    virtual void build_select() = 0;
    virtual bool build_where() = 0;
    virtual void build_order_by() = 0;
};

struct StationQueryBuilder : public QueryBuilder
{
    StationQueryBuilder(DB& db, const core::Query& query, unsigned int modifiers)
        : QueryBuilder(db, query, modifiers, false) {}

    virtual void build_select();
    virtual bool build_where();
    virtual void build_order_by();
};

struct DataQueryBuilder : public QueryBuilder
{
    /// Attribute filter, if requested
    Varmatch* attr_filter = nullptr;

    /// True if we also query attributes of data
    bool query_attrs;

    /// True if the select includes the attrs field
    bool select_attrs = false;

    DataQueryBuilder(DB& db, const core::Query& query, unsigned int modifiers, bool query_station_vars, bool query_attrs);
    ~DataQueryBuilder();

    // bool add_attrfilter_where(const char* tbl);

    /// Match the attributes of var against attr_filter
    bool match_attrs(const wreport::Var& var) const;

    virtual void build_select();
    virtual bool build_where();
    virtual void build_order_by();
};

struct IdQueryBuilder : public DataQueryBuilder
{
    IdQueryBuilder(DB& db, const core::Query& query, unsigned int modifiers, bool query_station_vars)
        : DataQueryBuilder(db, query, modifiers, query_station_vars, false) {}

    virtual void build_select();
    virtual void build_order_by();
};

struct SummaryQueryBuilder : public DataQueryBuilder
{
    SummaryQueryBuilder(DB& db, const core::Query& query, unsigned int modifiers, bool query_station_vars)
        : DataQueryBuilder(db, query, modifiers, query_station_vars, false) {}

    virtual void build_select();
    virtual void build_order_by();
};

}
}
}

#endif