forked from guanghaoyin/face_asm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreader.h
63 lines (53 loc) · 1.22 KB
/
reader.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
56
57
58
59
60
61
62
63
#pragma once
#pragma execution_character_set("utf-8")
#ifndef READER_H
#define READER_H
#include <cstdio>
namespace modelshare {
class reader
{
public:
reader(const char *filename);
~reader();
/// Skips whitespace and any commments preceeding the current file position.
void Sync() { Skip_useless(); Skip_comments(); }
bool FlValid() {
bool valid = (fl == NULL);
return valid;
}
FILE *FL() { return fl; }
bool MoreNonWhiteSpaceOnLine();
private:
FILE *fl;
const char CR; //0x0a
const char LF; //0x0d 输入回车的附加字符
const char Comment_char;//#
//私有数据成员不可赋初值
void Skip_useless() {
int ch;
do {
ch = fgetc(fl);
} while (ch == ' ' || ch == '\t' || ch == CR || ch == LF);
ungetc(ch, fl);//最后一次为不需要的字符,需退回到文件流
}
void Skip_restline() {
int ch;
do {
ch = fgetc(fl);
} while (ch != EOF && ch != CR && ch != LF);
ungetc(ch, fl);//最后一次为不需要的字符,需退回到文件流
Skip_useless();
}
void Skip_comments() {
int ch;
ch = getc(fl);
if (ch == Comment_char) {
Skip_restline();
Skip_comments();
}else{
ungetc(ch, fl);
}
}
};
}
#endif // !READER_H