Renderer, ...: use PixelRect::GetCenter()
[xcsoar.git] / src / Device / Driver / Volkslogger / dbbconv.h
blob57a12ec71a05d036755d906e36854ccd083a375a
1 /***********************************************************************
2 **
3 ** dbbconv.h
4 **
5 ** This file is part of libkfrgcs.
6 **
7 ************************************************************************
8 **
9 ** Copyright (c): 2002 by Garrecht Ingenieurgesellschaft
11 ** This file is distributed under the terms of the General Public
12 ** Licence. See the file COPYING for more information.
14 ** $Id$
16 ***********************************************************************/
18 #ifndef DBBCONV_H
19 #define DBBCONV_H
21 #include "Database.hpp"
23 #include <stdint.h>
24 #include <stddef.h>
26 class DBB {
27 public:
28 static constexpr size_t DBBBeg = 0x0000;
29 static constexpr size_t DBB_SIZE = 0x3000;
30 static constexpr size_t DBBEnd = DBBBeg + DBB_SIZE;
31 static constexpr size_t FrmBeg = 0x3000;
32 static constexpr size_t FRM_SIZE = 0x1000;
33 static constexpr size_t FrmEnd = FrmBeg + FRM_SIZE;
34 static constexpr size_t SIZE = DBB_SIZE + FRM_SIZE;
36 size_t dbcursor;
37 size_t fdfcursor;
38 struct HEADER {
39 unsigned dsanzahl;
40 unsigned dslaenge, keylaenge;
41 unsigned dsfirst, dslast;
43 HEADER header[8];
44 public:
45 uint8_t buffer[SIZE];
47 /**
48 * Konstruktor: leeren Datenbank-Block erzeugen.
50 DBB();
52 void *GetBlock(size_t offset=0) {
53 return buffer + DBBBeg + offset;
56 const void *GetBlock(size_t offset=0) const {
57 return buffer + DBBBeg + offset;
60 void *GetFDF(size_t offset=0) {
61 return buffer + FrmBeg + offset;
64 const void *GetFDF(size_t offset=0) const {
65 return buffer + FrmBeg + offset;
68 protected:
69 Volkslogger::TableHeader *GetHeader(unsigned i) {
70 Volkslogger::TableHeader *h = (Volkslogger::TableHeader *)GetBlock();
71 return &h[i];
74 const Volkslogger::TableHeader *GetHeader(unsigned i) const {
75 const Volkslogger::TableHeader *h =
76 (const Volkslogger::TableHeader *)GetBlock();
77 return &h[i];
80 public:
81 /**
82 * Generate Header-Structure from DBB-File.
84 void open_dbb();
86 /**
87 * Update header of specified table (kennung) of the database and
88 * close the table (it can't be extended anymore).
90 void close_db(int kennung);
92 void add_ds(int kennung, const void *quelle);
94 /**
95 * Add a FDF entry.
97 * @return a writeable pointer of the specified size or nullptr if
98 * the buffer is full
100 void *AddFDF(uint8_t id, size_t size);
102 void add_fdf(int feldkennung, size_t feldlaenge, const void *quelle);
105 * Add a FDF entry with the specified string value (convert to upper
106 * case).
108 void AddFDFStringUpper(uint8_t id, const char *value);
111 * Find an actual record of specified type(id) in the declaration
112 * memory and return it's position in the memory array.
114 int fdf_findfield(uint8_t id) const;
117 #endif