-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlily.h
103 lines (89 loc) · 1.86 KB
/
lily.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#pragma once
#include <iostream>
using namespace std;
class Field
{
public:
string name;
void* ref;
char type;
Field(string name, void* ref, char type = 'f')// just create a field with a ref
{
this->name = name;
this->ref = ref;
this->type = type;
this->IsBuiltIn = true;
}
Field(string name, string value, char t = 'f');// create a field from a string applay new memory
~Field()
{
if (!IsBuiltIn)
{
delete ref;
}
}
string toString();// using os to print value, value only!
void assign(string s);
friend ostream& operator<<(ostream& os, Field&);
friend istream& operator>>(istream& os, Field&);
//ostream& operator<<(ostream& os)
//{
// os << name << "=" << toString() << endl;
// return os;
//}
bool operator == (const string& b) const
{
return (name == b);
}
private:
bool IsBuiltIn;
};
typedef int (*Cmd_fun)(int n, string s[]);
class Cmd {
public:
string name;
string doc;
Cmd_fun ref;
Cmd(string s, Cmd_fun f, string d="none")
{
name = s;
ref = f;
doc = d;
}
bool operator == (const string& b) const
{
return (name == b);
}
};
class Fun
{
public:
string name;
void* ref;
char type;
char argn;
Fun(string name, void* ref , char argn = 0 ,char type='f')// just create a field with a ref
{
this->name = name;
this->ref = ref;
this->type = type;
this->argn = argn;
}
bool operator == (const string& b) const
{
return (name == b);
}
};
extern void(*lily_out)(string sth);
int lily_in(string *s1);
template<typename T>
void li_out(T);
int public_a_cmd(string name, Cmd_fun fun);
int public_a_field(string name, void* ref, char type = 'f');
int public_a_fun(string name, void* ref, char argn = 0, char type = 'f');
int shell_do_cmd(string& s);
int shell_do_field(string& s);
int shell_do_fun(string& s);
int shell_do_notFound(string& s);
int cmd_whos(int n, string arg[]);
int cmd_help(int n, string arg[]);