-
Notifications
You must be signed in to change notification settings - Fork 0
/
trans.h
96 lines (93 loc) · 1.73 KB
/
trans.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
class String:public CString
{
public:
//int equals(char *);
int equals(char *Str)
{
if(*this==Str)
return(1);
else
return(0);
//return(Compare(Str)==1?1:0);
}
void operator =(CString x)
{
char *Buffer;
//Buffer=x.GetBuffer(GetLength());
//*this=Buffer;
Buffer=(char *)x.GetBuffer(x.GetLength());
Empty();
if(Buffer[0]!=0)
Insert(0,x.GetBuffer(x.GetLength()));
}
String operator +(String x)
{
String s;
s.Insert(0,GetBuffer(x.GetLength()));
s.Insert(s.GetLength(),x.GetBuffer(x.GetLength()));
return(s);
}
int length()
{
return(GetLength());
}
int startsWith(char *x)
{
char *Buffer2;
int i=0;
Buffer2=GetBuffer(GetLength());
for(int i=0; i < strlen(x); i++)
if(x[i] != Buffer2[i])
break;
if(i == strlen(x))
return(1);
return(0);
}
String substring(int Start)
{
String x;
char *Buffer2;
Buffer2=GetBuffer(GetLength());
for(int i=Start;i<GetLength();i++)
{
x.Insert(i,Buffer2[i]);
}
return(x);
}
String substring(int Start,int End)
{
String x;
char *Buffer2;
Buffer2=GetBuffer(GetLength());
for(int i=Start;i<End;i++)
{
x.Insert(i,Buffer2[i]);
}
return(x);
}
int endsWith(char *x)
{
char *Buffer2;
int j=0;
Buffer2=GetBuffer(GetLength());
for(int i=strlen(Buffer2)-1,j=strlen(x)-1;j>=0;i--,j--)
{
if(x[j]!=Buffer2[i])
break;
}
if(j==-1)
return(1);
return(0);
}
int indexOf(char *Str)
{
return(Find(Str));
}
char charAt(int Pos)
{
//return(GetAt(Pos));
char *Buffer2;
Buffer2=GetBuffer(GetLength());
return(Buffer2[Pos]);
}
};