Tesseract
3.02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
cached_file.h
Go to the documentation of this file.
1
/**********************************************************************
2
* File: cached_file.h
3
* Description: Declaration of a Cached File class
4
* Author: Ahmad Abdulkader
5
* Created: 2007
6
*
7
* (C) Copyright 2008, Google Inc.
8
** Licensed under the Apache License, Version 2.0 (the "License");
9
** you may not use this file except in compliance with the License.
10
** You may obtain a copy of the License at
11
** http://www.apache.org/licenses/LICENSE-2.0
12
** Unless required by applicable law or agreed to in writing, software
13
** distributed under the License is distributed on an "AS IS" BASIS,
14
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
** See the License for the specific language governing permissions and
16
** limitations under the License.
17
*
18
**********************************************************************/
19
20
#ifndef CACHED_FILE_H
21
#define CACHED_FILE_H
22
23
// The CachedFile class provides a large-cache read access to a file
24
// It is mainly designed for loading large word dump files
25
26
#include <stdio.h>
27
#include <string>
28
#ifdef USE_STD_NAMESPACE
29
using
std::string;
30
#endif
31
32
namespace
tesseract
{
33
class
CachedFile
{
34
public
:
35
explicit
CachedFile
(
string
file_name);
36
~CachedFile
();
37
38
// reads a specified number of bytes to the specified buffer and
39
// returns the actual number of bytes read
40
int
Read
(
void
*read_buff,
int
bytes);
41
// Returns the file size
42
long
Size
();
43
// returns the current position in the file
44
long
Tell
();
45
// End of file flag
46
bool
eof
();
47
48
private
:
49
static
const
unsigned
int
kCacheSize = 0x8000000;
50
// file name
51
string
file_name_;
52
// internal file buffer
53
unsigned
char
*buff_;
54
// file position
55
long
file_pos_;
56
// file size
57
long
file_size_;
58
// position of file within buffer
59
int
buff_pos_;
60
// buffer size
61
int
buff_size_;
62
// file handle
63
FILE *fp_;
64
// Opens the file
65
bool
Open();
66
};
67
}
68
69
#endif // CACHED_FILE_H
mnt
data
src
tesseract-ocr
cube
cached_file.h
Generated on Thu Nov 1 2012 20:19:47 for Tesseract by
1.8.1