-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.hpp
72 lines (68 loc) · 1.51 KB
/
command.hpp
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
#include <string>
#include <vector>
#include "dem.hpp"
#include "bit.hpp"
using namespace std;
string HELP("");
//int str_to_int(string u);
vector<string> _cmd_parse(string u){
vector<string> res;
string tool;
int l=u.size();
for(int i=0;i<l;i++){
if(u[i]==' '){
res.push_back(tool);
tool="";
}else{
tool=tool+u[i];
}
}
if(tool.size()){
res.push_back(tool);
}
return res;
}
void usage(){
string u;
cin>>u;
if(u=="h"||u=="help"){
cout<<HELP<<endl;
}else{
//vector<string> res=_cmd_parse(u);
if(u=="d"){//DECIMAL
string value;
unsigned int fro,to2;
cin>>fro>>to2>>value;
NUM from=DECIMAL::NORMAL(value,fro);
NUM to=DECIMAL::turn(from,to2);
if(!to.fflag){
printf("-");
}
cout<<OUT;
cout<<(to.main)<<endl;
}else if(u=="p"){//pseudocode
string ftype,ttype;
cin>>ftype>>ttype;
try{
TYPESIZE::turn(ftype,ttype);
}catch(int err){
if(err==-1){
cout<<OUT<<"Wrong TypeName\n";
}
}
}else if(u=="exit"){//exit
cout<<"[ Exit ]";
throw 0;
}
}
}
/*
int str_to_int(string u){
int sum=0,j=1,l=u.size();
for(int i=l-1;i>=0;i--){
sum+=DE_CONFIG.find(u[i])*j;
j*=10;
}
return sum;
}
*/