source: trunk/flatfile_pool.h @ 26

Last change on this file since 26 was 7, checked in by willem, 11 years ago

willem

File size: 1.6 KB
Line 
1
2/*
3   Copyright 2013 Willem Vermin, SURFsara
4
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8
9       http://www.apache.org/licenses/LICENSE-2.0
10
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16 */
17#ifndef FLATFILE_POOL_H
18#define FLATFILE_POOL_H
19#include "stopos_pool.h"
20#include "stopos_key.h"
21#include "stopos.h"
22
23class flatstatusrecord: statusrecord
24{
25  longuint nextd;
26};
27
28class flatfile_pool: public stopos_pool
29{
30  private:
31    int ff;    // handle of file to be used
32
33    int get_record(std::string &r, const std::string &k, const std::string &l);
34    int put_record(const std::string &r, const std::string &k,const std::string &l);
35    int remove_record(const std::string &k, const std::string &l);
36    int write_string(const std::string &r,off_t p);
37    int read_string(std::string &r,off_t p);
38
39    const static char deleted = 'd';
40    const static char exists  = '_';
41
42    std::string key_to_slot(const std::string &k);
43    off_t strtoslot(const std::string &s);
44    std::string slottostr(off_t l);
45    int haskey(std::string &r, const std::string &k);
46    int open_db(int flags);
47
48  public:
49    flatfile_pool();
50    int create_db(const std::string &dbname);
51    int purge_db(void);
52    int open_db(void);
53    int close_db(void);
54};
55
56#endif
Note: See TracBrowser for help on using the repository browser.