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.Bin32 Struct Reference

Public Member Functions

 Bin32 (uint val)
 
override string ToString ()
 

Static Public Member Functions

static implicit operator uint (Bin32 val)
 
static implicit operator Bin32 (uint val)
 
static Bin32 FromString (string s)
 

Public Attributes

buint _data
 

Properties

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

Constructor & Destructor Documentation

◆ Bin32()

BrawlLib.Internal.Bin32.Bin32 ( uint  val)
inline
12 {
13 _data = val;
14 }
buint _data
Definition: BinaryHandlers.cs:9

Member Function Documentation

◆ FromString()

static Bin32 BrawlLib.Internal.Bin32.FromString ( string  s)
inlinestatic
91 {
92 char[] delims = new char[] {',', '(', ')', ' '};
93
94 uint b = 0;
95 string[] arr = s.Split(delims, StringSplitOptions.RemoveEmptyEntries);
96
97 for (int len = 0; len < arr.Length; len++)
98 {
99 byte bit = 0;
100 for (int i = 0; i < arr[len].Length; i++)
101 {
102 b <<= 1;
103 byte.TryParse(arr[len][i].ToString(), out bit);
104 bit = bit.Clamp(0, 1);
105 b += bit;
106 }
107 }
108
109 return new Bin32(b);
110 }
Bin32(uint val)
Definition: BinaryHandlers.cs:11
override string ToString()
Definition: BinaryHandlers.cs:28

◆ operator Bin32()

static implicit BrawlLib.Internal.Bin32.operator Bin32 ( uint  val)
inlinestatic
22 {
23 return new Bin32(val);
24 }

◆ operator uint()

static implicit BrawlLib.Internal.Bin32.operator uint ( Bin32  val)
inlinestatic
17 {
18 return val._data;
19 }

◆ ToString()

override string BrawlLib.Internal.Bin32.ToString ( )
inline
29 {
30 int i = 0;
31 string val = "";
32 while (i++ < 32)
33 {
34 val += (_data >> (32 - i)) & 1;
35 if (i % 4 == 0 && i != 32)
36 {
37 val += " ";
38 }
39 }
40
41 return val;
42 }

Member Data Documentation

◆ _data

buint BrawlLib.Internal.Bin32._data

Property Documentation

◆ this[int index]

bool BrawlLib.Internal.Bin32.this[int index]
getset
45 {
46 get => ((_data >> index) & 1) != 0;
47 set
48 {
49 if (value)
50 {
51 _data |= (uint) (1 << index);
52 }
53 else
54 {
55 _data &= ~(uint) (1 << index);
56 }
57 }
58 }

◆ this[int shift, int bitCount]

uint BrawlLib.Internal.Bin32.this[int shift, int bitCount]
getset
67 {
68 get
69 {
70 int mask = 0;
71 for (int i = 0; i < bitCount; i++)
72 {
73 mask |= 1 << i;
74 }
75
76 return (uint) ((_data >> shift) & mask);
77 }
78 set
79 {
80 int mask = 0;
81 for (int i = 0; i < bitCount; i++)
82 {
83 mask |= 1 << i;
84 }
85
86 _data = (uint) ((_data & ~(mask << shift)) | ((value & mask) << shift));
87 }
88 }

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