TPIE

2362a60
stream_header.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2009, 2011, 2012, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
23 
24 #ifndef __TPIE_STREAM_HEADER_H__
25 #define __TPIE_STREAM_HEADER_H__
26 #include <tpie/util.h>
27 #include <tpie/types.h>
28 
29 namespace tpie {
30 
32  static const uint64_t magicConst = 0x521cbe927dd6056all;
33  static const uint64_t versionConst = 4;
34 
35  uint64_t magic;
36  uint64_t version;
37  uint64_t itemSize;
38  uint64_t blockSize;
39  uint64_t userDataSize;
40  uint64_t maxUserDataSize;
41  uint64_t size;
42  uint64_t flags;
43  uint64_t lastBlockReadOffset;
44 
45  static const uint64_t cleanCloseMask = 0x1;
46  static const uint64_t compressedMask = 0x2;
47 
48  bool get_clean_close() const { return flags & cleanCloseMask; }
49  void set_clean_close(bool b) { if (b) flags |= cleanCloseMask; else flags &= ~cleanCloseMask; }
50 
51  bool get_compressed() const { return flags & compressedMask; }
52  void set_compressed(bool b) { if (b) flags |= compressedMask; else flags &= ~compressedMask; }
53 };
54 
55 }
56 #endif //__TPIE_STREAM_HEADER_H__
Typesafe bitflags.
Miscellaneous utility functions.