-
Notifications
You must be signed in to change notification settings - Fork 2
/
listdef.h
74 lines (74 loc) · 1.56 KB
/
listdef.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
70
71
72
73
74
#ifndef LISTDEF_H
#define LISTDEF_H
#include<iostream>
#include<vector>
#include<string>
#include"classheader.h"
class CmdList
{
vector<PipeLine*> vcmdl;
bool isnew;
vector<ReDir*> rcgc;
public:
CmdList():isnew(true)
{
vcmdl.reserve(VEC_RESER);
rcgc.reserve(VEC_RESER);
}
PipeLine* currentPL()//访问当前构建的管道线
{
if(isnew)
{
vcmdl.push_back(new PipeLine);
isnew=false;
}
return vcmdl.back();
}
void SetNew(bool ops=true)
{
isnew=ops;
}
void AddRubish(ReDir* ops)
{
if(ops)
rcgc.push_back(ops);
}
int Execute()
{
for(unsigned int i=0;i<vcmdl.size();i++)
{
if(!vcmdl[i]->IsError())
{
if(vcmdl[i]->Execute()==YIN_QUIT) return YIN_QUIT;
//cout<<endl;
//if((i+1)<vcmdl.size())
// cout<<"============================"<<endl;
}
else
{
cout<<"Syntax Error"<<endl;//<<"============================"<<endl;
}
}
return 0;
}
~CmdList()
{
for(unsigned int i=0;i<vcmdl.size();i++)
{
if(vcmdl[i]!=NULL)
{
delete vcmdl[i];
vcmdl[i]=NULL;
}
}
for(unsigned int i=0;i<rcgc.size();i++)
{
if(rcgc[i]!=NULL)
{
delete rcgc[i];
rcgc[i]=NULL;
}
}
}
};
#endif