wolfrpg_map_parser/command/set_variable_command/
options.rs

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
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Options {
    bind_result: bool,
    real_number_calculation: bool,
    left_not_variable: bool,
    right_not_variable: bool,
    use_variable_as_reference: bool,
    use_left_as_reference: bool,
    use_right_as_reference: bool,
}

impl Options {
    pub fn new(options: u8) -> Self {
        Self {
            bind_result:                options & 0b00000001 != 0,
            real_number_calculation:    options & 0b00000010 != 0,
            left_not_variable:          options & 0b00000100 != 0,
            right_not_variable:         options & 0b00001000 != 0,
            use_variable_as_reference:  options & 0b00010000 != 0,
            use_left_as_reference:      options & 0b00100000 != 0,
            use_right_as_reference:     options & 0b01000000 != 0,
        }
    }

    pub fn bind_result(&self) -> bool {
        self.bind_result
    }

    pub fn bind_result_mut(&mut self) -> &mut bool {
        &mut self.bind_result
    }

    pub fn real_number_calculation(&self) -> bool {
        self.real_number_calculation
    }

    pub fn real_number_calculation_mut(&mut self) -> &mut bool {
        &mut self.real_number_calculation
    }

    pub fn left_not_variable(&self) -> bool {
        self.left_not_variable
    }

    pub fn left_not_variable_mut(&mut self) -> &mut bool {
        &mut self.left_not_variable
    }

    pub fn right_not_variable(&self) -> bool {
        self.right_not_variable
    }

    pub fn right_not_variable_mut(&mut self) -> &mut bool {
        &mut self.right_not_variable
    }

    pub fn use_variable_as_reference(&self) -> bool {
        self.use_variable_as_reference
    }

    pub fn use_variable_as_reference_mut(&mut self) -> &mut bool {
        &mut self.use_variable_as_reference
    }

    pub fn use_left_as_reference(&self) -> bool {
        self.use_left_as_reference
    }

    pub fn use_left_as_reference_mut(&mut self) -> &mut bool {
        &mut self.use_left_as_reference
    }

    pub fn use_right_as_reference(&self) -> bool {
        self.use_right_as_reference
    }

    pub fn use_right_as_reference_mut(&mut self) -> &mut bool {
        &mut self.use_right_as_reference
    }
}