-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjList.h
69 lines (64 loc) · 1.19 KB
/
ObjList.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
64
65
66
67
68
69
#ifndef _TXT_PRASE_
#define _TXT_PRASE_
#include <stdio.h>
#include <string>
#include <vector>
#include <fstream>
#include <sstream>
using namespace std;
class Object
{
public:
//label
int lOrg;
//video id
string id;
};
class CObjList
{
public:
vector<Object> _vec;
bool Init(const char* fileName)
{
_vec.clear();
bool bReturn = false;
ifstream gtfile(fileName);
if (!gtfile.is_open())
{
printf("[ERROR]could not open text file %s\n",fileName);
exit(-1);
}
while (!gtfile.eof())
{
string line;
getline(gtfile,line);
if (0 == line.length())
{
break;
}
istringstream iss(line);
if (!iss.fail())
{
Object obj;
iss >> obj.id >> obj.lOrg;
if (obj.id.length()>0)
{
_vec.push_back(obj);
bReturn = true;
}
else
break;
} else
{
if (!gtfile.eof())
{
printf("[ERROR] Error parsing text file.\n");
exit(-1);
}
}
}
gtfile.close();
return bReturn;
}
};
#endif