forked from yvt/xtbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXTBDicDBReader.h
55 lines (41 loc) · 1.16 KB
/
XTBDicDBReader.h
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
//
// XTBDicDBReader.h
// XTBook
//
// Created by Kawada Tomoaki on 7/6/11.
// Copyright 2011 Nexhawks. All rights reserved.
//
#pragma once
#include "XTBStream.h"
#include "platform.h"
#include <tcw/twSemaphore.h>
typedef uint64_t XTBDicDBPointer;
static const XTBDicDBPointer XTBDicDBInvalidPointer=0xffffffffffffffffULL;
struct XTBDicDBReaderKey{
std::string key;
XTBDicDBPointer pointer;
bool isInvalid() const{
return pointer==XTBDicDBInvalidPointer;
}
};
class XTBDicDBReader{
XTBSysString m_path;
XTBStream *m_contentsStream;
XTBStream *m_keysStream;
XTBStream *m_keyIndexStream;
twSemaphore *m_contentsMutex;
twSemaphore *m_keysMutex;
twSemaphore *m_keyIndexMutex;
unsigned int m_keyCount;
XTBSysString pathForContents() const;
XTBSysString pathForKeys() const;
XTBSysString pathForKeyIndex() const;
public:
XTBDicDBReader(const XTBSysString& path);
virtual ~XTBDicDBReader();
std::string contentsAtPointer(XTBDicDBPointer,
uint32_t maxLength=(uint32_t)-1) const;
XTBDicDBReaderKey keyAtIndex(unsigned int) const;
XTBDicDBPointer pointerForKey(const std::string&) const;
unsigned int count() const{return m_keyCount;}
};