BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Properties | List of all members
BrawlLib.Internal.PString Struct Reference

Public Member Functions

 PString (byte *address)
 
override bool Equals (object obj)
 
bool Equals (PString s, bool ignoreCase)
 
bool Equals (string s, bool ignoreCase)
 
override int GetHashCode ()
 
override string ToString ()
 
void Write (string s)
 
void Write (string s, int offset)
 
void Write (string s, int offset, int len)
 
void Write (char *p, int offset, int len)
 
void Write (byte *p, int offset, int len)
 

Static Public Member Functions

static implicit operator int (PString p)
 
static implicit operator uint (PString p)
 
static implicit operator sbyte * (PString p)
 
static implicit operator PString (sbyte *p)
 
static implicit operator byte * (PString p)
 
static implicit operator PString (byte *p)
 
static implicit operator VoidPtr (PString p)
 
static implicit operator PString (VoidPtr p)
 
static operator string (PString p)
 
static PString operator+ (PString p, int amount)
 
static bool operator== (PString p, string s)
 
static bool operator!= (PString p, string s)
 
static bool operator== (PString p, PString s)
 
static bool operator!= (PString p, PString s)
 
static bool Equals (PString s1, PString s2, bool ignoreCase)
 
static bool Equals (PString s1, string s2, bool ignoreCase)
 

Properties

byte this[int index] [get, set]
 
int Length [get]
 

Constructor & Destructor Documentation

◆ PString()

BrawlLib.Internal.PString.PString ( byte *  address)
inline
11 {
12 _address = address;
13 }

Member Function Documentation

◆ Equals() [1/5]

override bool BrawlLib.Internal.PString.Equals ( object  obj)
inline
89 {
90 if (obj is PString)
91 {
92 return Equals((PString) obj, false);
93 }
94
95 if (obj is string)
96 {
97 return Equals((string) obj, false);
98 }
99
100 return false;
101 }
override bool Equals(object obj)
Definition: PString.cs:88

◆ Equals() [2/5]

bool BrawlLib.Internal.PString.Equals ( PString  s,
bool  ignoreCase 
)
inline
114 {
115 byte* pStr1 = _address;
116 byte* pStr2 = s._address;
117 byte b1, b2;
118
119 do
120 {
121 b1 = *pStr1++;
122 b2 = *pStr2++;
123 if (b1 != b2)
124 {
125 if (ignoreCase)
126 {
127 if (b1 >= 0x41 && b1 <= 0x5A)
128 {
129 if (b1 + 0x20 == b2)
130 {
131 continue;
132 }
133 }
134 else if (b1 >= 0x61 && b1 <= 0x7A)
135 {
136 if (b1 - 0x20 == b2)
137 {
138 continue;
139 }
140 }
141 }
142
143 return false;
144 }
145 } while (b1 != 0);
146
147 return true;
148 }

◆ Equals() [3/5]

static bool BrawlLib.Internal.PString.Equals ( PString  s1,
PString  s2,
bool  ignoreCase 
)
inlinestatic
104 {
105 return s1.Equals(s2, ignoreCase);
106 }

◆ Equals() [4/5]

static bool BrawlLib.Internal.PString.Equals ( PString  s1,
string  s2,
bool  ignoreCase 
)
inlinestatic
109 {
110 return s1.Equals(s2, ignoreCase);
111 }

◆ Equals() [5/5]

bool BrawlLib.Internal.PString.Equals ( string  s,
bool  ignoreCase 
)
inline
151 {
152 byte* pStr1 = _address;
153 char* pStr2;
154 byte b1, b2;
155
156 fixed (char* pChar = s)
157 {
158 pStr2 = pChar;
159 do
160 {
161 b1 = *pStr1++;
162 b2 = (byte) *pStr2++;
163 if (b1 != b2)
164 {
165 if (ignoreCase)
166 {
167 if (b1 >= 0x41 && b1 <= 0x5A)
168 {
169 if (b1 + 0x20 == b2)
170 {
171 continue;
172 }
173 }
174 else if (b1 >= 0x61 && b1 <= 0x7A)
175 {
176 if (b1 - 0x20 == b2)
177 {
178 continue;
179 }
180 }
181 }
182
183 return false;
184 }
185 } while (b1 != 0);
186 }
187
188 return true;
189 }

◆ GetHashCode()

override int BrawlLib.Internal.PString.GetHashCode ( )
inline
192 {
193 return base.GetHashCode();
194 }

◆ operator byte *()

static implicit BrawlLib.Internal.PString.operator byte * ( PString  p)
inlinestatic
38 {
39 return p._address;
40 }

◆ operator int()

static implicit BrawlLib.Internal.PString.operator int ( PString  p)
inlinestatic
16 {
17 return (int) p._address;
18 }

◆ operator PString() [1/3]

static implicit BrawlLib.Internal.PString.operator PString ( byte *  p)
inlinestatic
43 {
44 return *(PString*) &p;
45 }
PString(byte *address)
Definition: PString.cs:10

◆ operator PString() [2/3]

static implicit BrawlLib.Internal.PString.operator PString ( sbyte *  p)
inlinestatic
33 {
34 return *(PString*) &p;
35 }

◆ operator PString() [3/3]

static implicit BrawlLib.Internal.PString.operator PString ( VoidPtr  p)
inlinestatic
53 {
54 return *(PString*) &p;
55 }

◆ operator sbyte *()

static implicit BrawlLib.Internal.PString.operator sbyte * ( PString  p)
inlinestatic
28 {
29 return (sbyte*) p._address;
30 }

◆ operator string()

static BrawlLib.Internal.PString.operator string ( PString  p)
inlineexplicitstatic
58 {
59 return new string((sbyte*) p._address);
60 }

◆ operator uint()

static implicit BrawlLib.Internal.PString.operator uint ( PString  p)
inlinestatic
22 {
23 return (uint) p._address;
24 }

◆ operator VoidPtr()

static implicit BrawlLib.Internal.PString.operator VoidPtr ( PString  p)
inlinestatic
48 {
49 return *(VoidPtr*) &p;
50 }

◆ operator!=() [1/2]

static bool BrawlLib.Internal.PString.operator!= ( PString  p,
PString  s 
)
inlinestatic
84 {
85 return !p.Equals(s, false);
86 }

◆ operator!=() [2/2]

static bool BrawlLib.Internal.PString.operator!= ( PString  p,
string  s 
)
inlinestatic
74 {
75 return !p.Equals(s, false);
76 }

◆ operator+()

static PString BrawlLib.Internal.PString.operator+ ( PString  p,
int  amount 
)
inlinestatic
63 {
64 p._address += amount;
65 return p;
66 }

◆ operator==() [1/2]

static bool BrawlLib.Internal.PString.operator== ( PString  p,
PString  s 
)
inlinestatic
79 {
80 return p.Equals(s, false);
81 }

◆ operator==() [2/2]

static bool BrawlLib.Internal.PString.operator== ( PString  p,
string  s 
)
inlinestatic
69 {
70 return p.Equals(s, false);
71 }

◆ ToString()

override string BrawlLib.Internal.PString.ToString ( )
inline
197 {
198 return new string(this);
199 }

◆ Write() [1/5]

void BrawlLib.Internal.PString.Write ( byte *  p,
int  offset,
int  len 
)
inline
251 {
252 byte* s = _address;
253 p += offset;
254 for (int i = 0; i < len; i++)
255 {
256 *s++ = *p++;
257 }
258 }

◆ Write() [2/5]

void BrawlLib.Internal.PString.Write ( char *  p,
int  offset,
int  len 
)
inline
241 {
242 byte* s = _address;
243 p += offset;
244 for (int i = 0; i < len; i++)
245 {
246 *s++ = (byte) *p++;
247 }
248 }

◆ Write() [3/5]

void BrawlLib.Internal.PString.Write ( string  s)
inline
223 {
224 Write(s, 0);
225 }
void Write(string s)
Definition: PString.cs:222

◆ Write() [4/5]

void BrawlLib.Internal.PString.Write ( string  s,
int  offset 
)
inline
228 {
229 Write(s, offset, s.Length);
230 }

◆ Write() [5/5]

void BrawlLib.Internal.PString.Write ( string  s,
int  offset,
int  len 
)
inline
233 {
234 fixed (char* p = s)
235 {
236 Write(p, offset, len);
237 }
238 }

Property Documentation

◆ Length

int BrawlLib.Internal.PString.Length
get
208 {
209 get
210 {
211 int len = 0;
212 byte* p = _address;
213 while (*p++ != 0)
214 {
215 len++;
216 }
217
218 return len;
219 }
220 }

◆ this[int index]

byte BrawlLib.Internal.PString.this[int index]
getsetadd
202 {
203 get => _address[index];
204 set => _address[index] = value;
205 }

The documentation for this struct was generated from the following file: