TRF Language Model
wb-file.h File Reference

define the file class More...

#include "iostream"
#include "fstream"
#include <stdio.h>
#include <time.h>
#include <cstdarg>
#include "wb-win.h"
#include "wb-log.h"

Go to the source code of this file.

Classes

class  wb::File
 file class. More...
 
class  wb::IO_Obj
 base class used to derive. It providing the vritual function of write and read More...
 
class  wb::ObjFile
 used to read more than one objects More...
 

Namespaces

 wb
 define all the code written by Bin Wang.
 

Macros

#define SAFE_FOPEN(pfile, path, mode)
 file open More...
 
#define SAFE_FMOPEN(file, path, mode)
 file open More...
 
#define SAFE_FSOPEN(file, path)
 file open More...
 
#define SAFE_FCLOSE(fp)   { if(fp) {fclose(fp); fp=NULL;} }
 file close More...
 
#define MAX_SENTENCE_LEN   32*1024
 the maximum length of string read from file once More...
 
#define WRITE_VALUE(x, fp)   fwrite(&(x),sizeof(x),1,fp)
 Write a value to file. More...
 
#define READ_VALUE(x, fp)   fread(&(x),sizeof(x),1,fp)
 Read a value from file. More...
 
#define FPRINT_VALUE(x, fp)   fprintf(fp, #x"=%d\n", (x))
 fprintf a value to file More...
 
#define FSCANF_VALUE(x, fp)   fscanf(fp, #x"=%d\n", &(x))
 fscanf a value from file More...
 

Detailed Description

define the file class

Author
WangBin
Date
2016-05-05

Definition in file wb-file.h.

Macro Definition Documentation

§ FPRINT_VALUE

#define FPRINT_VALUE (   x,
  fp 
)    fprintf(fp, #x"=%d\n", (x))

fprintf a value to file

Definition at line 60 of file wb-file.h.

§ FSCANF_VALUE

#define FSCANF_VALUE (   x,
  fp 
)    fscanf(fp, #x"=%d\n", &(x))

fscanf a value from file

Definition at line 62 of file wb-file.h.

§ MAX_SENTENCE_LEN

#define MAX_SENTENCE_LEN   32*1024

the maximum length of string read from file once

Definition at line 53 of file wb-file.h.

§ READ_VALUE

#define READ_VALUE (   x,
  fp 
)    fread(&(x),sizeof(x),1,fp)

Read a value from file.

Definition at line 58 of file wb-file.h.

§ SAFE_FCLOSE

#define SAFE_FCLOSE (   fp)    { if(fp) {fclose(fp); fp=NULL;} }

file close

Definition at line 50 of file wb-file.h.

§ SAFE_FMOPEN

#define SAFE_FMOPEN (   file,
  path,
  mode 
)
Value:
{\
file.open(path, mode); if (!file.good()) {cout<<"File Open Failed: "<<path<<endl; exit(0);}}

file open

Definition at line 44 of file wb-file.h.

§ SAFE_FOPEN

#define SAFE_FOPEN (   pfile,
  path,
  mode 
)
Value:
{\
if ( !path || !(pfile = fopen(path, mode)) ) {cout<<"File Open Failed: "<<path<<endl; exit(0);}}

file open

Definition at line 41 of file wb-file.h.

§ SAFE_FSOPEN

#define SAFE_FSOPEN (   file,
  path 
)
Value:
{\
file.open(path); if (!file.good()) {cout<<"File Open Failed: "<<path<<endl; exit(0);}}

file open

Definition at line 47 of file wb-file.h.

§ WRITE_VALUE

#define WRITE_VALUE (   x,
  fp 
)    fwrite(&(x),sizeof(x),1,fp)

Write a value to file.

Definition at line 56 of file wb-file.h.