-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscriptparser.cpp
83 lines (67 loc) · 1.58 KB
/
scriptparser.cpp
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "scriptparser.h"
#include <iostream>
#include <cstring>
#include <cstdio>
#include "vstring.h"
using namespace std;
void ScriptParser::getDtTask(map<string,const char *> ¶s,const char *fn)
{
FILE *fp=fopen(fn,"r");
if(!fp)
{
printf("Script %s can not be open.\n",fn);
return ;
}
int nargs = 0;
char result[100] = "";
string fst_str = "", sec_str = "";
while(!feof(fp))
{
nargs = fscanf(fp, "%s", result);
if(nargs != 1)
continue;
if(!strcmp(result, "") || strlen(result) < 3)
continue;
VString::parsePair(result,fst_str,sec_str,'=');
char *pairf = new char[fst_str.length()+1];
strcpy(pairf, fst_str.c_str());
char *pairs = new char[sec_str.length()+1];
strcpy(pairs, sec_str.c_str());
paras.insert(paraType(pairf, pairs));
fst_str.erase(fst_str.begin(), fst_str.end());
sec_str.erase(sec_str.begin(), sec_str.end());
strcpy(result,"");
}
fclose(fp);
return ;
}
void ScriptParser::getKeyFrames(vector<const char*> &kflst,const char fname[])
{
printf("Read KeyFrames set...\n");
FILE *fp=fopen(fname,"r");
if(!fp)
{
printf("%s File can not be open.\n",fname);
return ;
}
char result[60];
char *crntKeyFrm;
int i = 0, nargs = 0;
while(!feof(fp))
{
nargs = fscanf(fp, "%s", result);
if(nargs != 1)
continue;
crntKeyFrm = new char[60];
strcpy(crntKeyFrm, result);
//out<<result<<endl;
kflst.push_back(crntKeyFrm);
i++;
}
//cout<<"Count: "<<i<<endl;
fclose(fp);
return ;
}
void ScriptParser::test()
{
}