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

Public Member Functions

 Bin8 (byte val)
 
override string ToString ()
 

Static Public Member Functions

static implicit operator byte (Bin8 val)
 
static implicit operator Bin8 (byte val)
 
static Bin8 FromString (string s)
 

Public Attributes

byte _data
 

Properties

bool this[int index] [get, set]
 
byte this[int shift, int bitCount] [get, set]
 

Constructor & Destructor Documentation

◆ Bin8()

BrawlLib.Internal.Bin8.Bin8 ( byte  val)
inline
347 {
348 _data = val;
349 }
byte _data
Definition: BinaryHandlers.cs:344

Member Function Documentation

◆ FromString()

static Bin8 BrawlLib.Internal.Bin8.FromString ( string  s)
inlinestatic
426 {
427 char[] delims = new char[] {',', '(', ')', ' '};
428
429 byte b = 0;
430 string[] arr = s.Split(delims, StringSplitOptions.RemoveEmptyEntries);
431
432 for (int len = 0; len < arr.Length; len++)
433 {
434 byte bit = 0;
435 for (int i = 0; i < arr[len].Length; i++)
436 {
437 b <<= 1;
438 byte.TryParse(arr[len][i].ToString(), out bit);
439 bit = bit.Clamp(0, 1);
440 b += bit;
441 }
442 }
443
444 return new Bin8(b);
445 }
Bin8(byte val)
Definition: BinaryHandlers.cs:346
override string ToString()
Definition: BinaryHandlers.cs:363

◆ operator Bin8()

static implicit BrawlLib.Internal.Bin8.operator Bin8 ( byte  val)
inlinestatic
357 {
358 return new Bin8(val);
359 }

◆ operator byte()

static implicit BrawlLib.Internal.Bin8.operator byte ( Bin8  val)
inlinestatic
352 {
353 return val._data;
354 }

◆ ToString()

override string BrawlLib.Internal.Bin8.ToString ( )
inline
364 {
365 int i = 0;
366 string val = "";
367 while (i++ < 8)
368 {
369 val += (_data >> (8 - i)) & 1;
370 if (i % 4 == 0 && i != 8)
371 {
372 val += " ";
373 }
374 }
375
376 return val;
377 }

Member Data Documentation

◆ _data

byte BrawlLib.Internal.Bin8._data

Property Documentation

◆ this[int index]

bool BrawlLib.Internal.Bin8.this[int index]
getset
380 {
381 get => ((_data >> index) & 1) != 0;
382 set
383 {
384 if (value)
385 {
386 _data |= (byte) (1 << index);
387 }
388 else
389 {
390 _data &= (byte) ~(1 << index);
391 }
392 }
393 }

◆ this[int shift, int bitCount]

byte BrawlLib.Internal.Bin8.this[int shift, int bitCount]
getset
402 {
403 get
404 {
405 int mask = 0;
406 for (int i = 0; i < bitCount; i++)
407 {
408 mask |= 1 << i;
409 }
410
411 return (byte) ((_data >> shift) & mask);
412 }
413 set
414 {
415 int mask = 0;
416 for (int i = 0; i < bitCount; i++)
417 {
418 mask |= 1 << i;
419 }
420
421 _data = (byte) ((_data & ~(mask << shift)) | ((value & mask) << shift));
422 }
423 }

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