1 // +------------------------------------------------------------------+
2 // |             ____ _               _        __  __ _  __           |
3 // |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
4 // |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
5 // |           | |___| | | |  __/ (__|   <    | |  | | . \            |
6 // |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
7 // |                                                                  |
8 // | Copyright Mathias Kettner 2014             mk@mathias-kettner.de |
9 // +------------------------------------------------------------------+
10 //
11 // This file is part of Check_MK.
12 // The official homepage is at http://mathias-kettner.de/check_mk.
13 //
14 // check_mk is free software;  you can redistribute it and/or modify it
15 // under the  terms of the  GNU General Public License  as published by
16 // the Free Software Foundation in version 2.  check_mk is  distributed
17 // in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
18 // out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
19 // PARTICULAR PURPOSE. See the  GNU General Public License for more de-
20 // ails.  You should have  received  a copy of the  GNU  General Public
21 // License along with GNU Make; see the file  COPYING.  If  not,  write
22 // to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
23 // Boston, MA 02110-1301 USA.
24 
25 #ifndef Column_h
26 #define Column_h
27 
28 #include "config.h"  // IWYU pragma: keep
29 #include <string>
30 class Filter;
31 class Query;
32 
33 #define COLTYPE_INT 0
34 #define COLTYPE_DOUBLE 1
35 #define COLTYPE_STRING 2
36 #define COLTYPE_LIST 3
37 #define COLTYPE_TIME 4
38 #define COLTYPE_DICT 5
39 #define COLTYPE_BLOB 6
40 #define COLTYPE_NULL 7
41 
42 class Column {
43     std::string _name;
44     std::string _description;
45     int _indirect_offset;
46     int _extra_offset;
47     int _extra_extra_offset;
48 
49 public:
50     Column(std::string name, std::string description, int indirect_offset,
51            int extra_offset, int extra_extra_offset = -1);
~Column()52     virtual ~Column() {}
53 
name()54     const char *name() const { return _name.c_str(); }
description()55     const char *description() const { return _description.c_str(); }
56     void *shiftPointer(void *data);
57 
valueAsString(void *,Query *)58     virtual std::string valueAsString(void *, Query *) { return "invalid"; }
59     virtual int type() = 0;
60     virtual void output(void *data, Query *) = 0;
mustDelete()61     virtual bool mustDelete() {
62         return false;
63     }  // true for dynamic Columns to be deleted after Query
createFilter(int,char *)64     virtual Filter *createFilter(int, char *) { return 0; }
65 };
66 
67 #endif  // Column_h
68