tesseract  4.0.0-1-g2a2b
scanutils.cpp File Reference
#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstddef>
#include <cstring>
#include <climits>
#include <cstdio>
#include <limits>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "scanutils.h"
#include "tprintf.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 64 of file scanutils.cpp.

64  {
65  BAIL_NONE = 0, // No error condition
66  BAIL_EOF, // Hit EOF
67  BAIL_ERR // Conversion mismatch
68 };

◆ Flags

enum Flags
Enumerator
FL_SPLAT 
FL_INV 
FL_WIDTH 
FL_MINUS 

Definition at line 41 of file scanutils.cpp.

41  {
42  FL_SPLAT = 0x01, // Drop the value, do not assign
43  FL_INV = 0x02, // Character-set with inverse
44  FL_WIDTH = 0x04, // Field width specified
45  FL_MINUS = 0x08, // Negative number
46 };

◆ Ranks

enum Ranks
Enumerator
RANK_CHAR 
RANK_SHORT 
RANK_INT 
RANK_LONG 
RANK_LONGLONG 
RANK_PTR 

Definition at line 48 of file scanutils.cpp.

48  {
49  RANK_CHAR = -2,
50  RANK_SHORT = -1,
51  RANK_INT = 0,
52  RANK_LONG = 1,
53  RANK_LONGLONG = 2,
54  RANK_PTR = std::numeric_limits<int>::max() // Special value used for pointers
55 };

Function Documentation

◆ LongBit()

size_t LongBit ( )
inline

Definition at line 71 of file scanutils.cpp.

71  {
72  return CHAR_BIT * sizeof(long);
73 }

◆ 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 192 of file scanutils.cpp.

192  {
193  va_list ap;
194  int rv;
195 
196  va_start(ap, format);
197  rv = tvfscanf(stream, format, ap);
198  va_end(ap);
199 
200  return rv;
201 }

Variable Documentation

◆ kIntMaxRank

enum Ranks kIntMaxRank = RANK_LONGLONG

Definition at line 60 of file scanutils.cpp.

◆ kMaxRank

enum Ranks kMaxRank = RANK_LONGLONG

Definition at line 58 of file scanutils.cpp.

◆ kMinRank

enum Ranks kMinRank = RANK_CHAR

Definition at line 57 of file scanutils.cpp.

◆ kPtrDiffRank

enum Ranks kPtrDiffRank = RANK_LONG

Definition at line 62 of file scanutils.cpp.

◆ kSizeTRank

enum Ranks kSizeTRank = RANK_LONG

Definition at line 61 of file scanutils.cpp.