tesseract  5.0.0-alpha-619-ge9db
scanutils.cpp File Reference
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <limits>
#include "scanutils.h"

Go to the source code of this file.

Enumerations

enum  Flags { FL_SPLAT = 0x01, FL_INV = 0x02, FL_WIDTH = 0x04, FL_MINUS = 0x08 }
 
enum  Ranks {
  RANK_CHAR = -2, RANK_SHORT = -1, RANK_INT = 0, RANK_LONG = 1,
  RANK_LONGLONG = 2, RANK_PTR = std::numeric_limits<int>::max()
}
 
enum  Bail { BAIL_NONE = 0, BAIL_EOF, BAIL_ERR }
 

Functions

size_t LongBit ()
 
int tfscanf (FILE *stream, const char *format,...)
 

Variables

enum Ranks kMinRank = RANK_CHAR
 
enum Ranks kMaxRank = RANK_LONGLONG
 
enum Ranks kIntMaxRank = RANK_LONGLONG
 
enum Ranks kSizeTRank = RANK_LONG
 
enum Ranks kPtrDiffRank = RANK_LONG
 

Enumeration Type Documentation

◆ Bail

enum Bail
Enumerator
BAIL_NONE 
BAIL_EOF 
BAIL_ERR 

Definition at line 54 of file scanutils.cpp.

54  {
55  BAIL_NONE = 0, // No error condition
56  BAIL_EOF, // Hit EOF
57  BAIL_ERR // Conversion mismatch
58 };

◆ Flags

enum Flags
Enumerator
FL_SPLAT 
FL_INV 
FL_WIDTH 
FL_MINUS 

Definition at line 31 of file scanutils.cpp.

31  {
32  FL_SPLAT = 0x01, // Drop the value, do not assign
33  FL_INV = 0x02, // Character-set with inverse
34  FL_WIDTH = 0x04, // Field width specified
35  FL_MINUS = 0x08, // Negative number
36 };

◆ Ranks

enum Ranks
Enumerator
RANK_CHAR 
RANK_SHORT 
RANK_INT 
RANK_LONG 
RANK_LONGLONG 
RANK_PTR 

Definition at line 38 of file scanutils.cpp.

38  {
39  RANK_CHAR = -2,
40  RANK_SHORT = -1,
41  RANK_INT = 0,
42  RANK_LONG = 1,
43  RANK_LONGLONG = 2,
44  RANK_PTR = std::numeric_limits<int>::max() // Special value used for pointers
45 };

Function Documentation

◆ LongBit()

size_t LongBit ( )
inline

Definition at line 61 of file scanutils.cpp.

61  {
62  return CHAR_BIT * sizeof(long);
63 }

◆ tfscanf()

int tfscanf ( FILE *  stream,
const char *  format,
  ... 
)

fscanf variant to ensure correct reading regardless of locale.

tfscanf parse a file stream according to the given format. See the fscanf manpage for more information, as this function attempts to mimic its behavior.

Note
Note that scientific floating-point notation is not supported.

Definition at line 181 of file scanutils.cpp.

181  {
182  va_list ap;
183  int rv;
184 
185  va_start(ap, format);
186  rv = tvfscanf(stream, format, ap);
187  va_end(ap);
188 
189  return rv;
190 }

Variable Documentation

◆ kIntMaxRank

enum Ranks kIntMaxRank = RANK_LONGLONG

Definition at line 50 of file scanutils.cpp.

◆ kMaxRank

enum Ranks kMaxRank = RANK_LONGLONG

Definition at line 48 of file scanutils.cpp.

◆ kMinRank

enum Ranks kMinRank = RANK_CHAR

Definition at line 47 of file scanutils.cpp.

◆ kPtrDiffRank

enum Ranks kPtrDiffRank = RANK_LONG

Definition at line 52 of file scanutils.cpp.

◆ kSizeTRank

enum Ranks kSizeTRank = RANK_LONG

Definition at line 51 of file scanutils.cpp.

BAIL_EOF
Definition: scanutils.cpp:56
FL_MINUS
Definition: scanutils.cpp:35
RANK_PTR
Definition: scanutils.cpp:44
BAIL_ERR
Definition: scanutils.cpp:57
RANK_INT
Definition: scanutils.cpp:41
FL_WIDTH
Definition: scanutils.cpp:34
RANK_CHAR
Definition: scanutils.cpp:39
FL_INV
Definition: scanutils.cpp:33
FL_SPLAT
Definition: scanutils.cpp:32
BAIL_NONE
Definition: scanutils.cpp:55
RANK_LONG
Definition: scanutils.cpp:42
RANK_SHORT
Definition: scanutils.cpp:40
RANK_LONGLONG
Definition: scanutils.cpp:43