Created
August 29, 2018 23:27
-
-
Save shrugs/92f1a268fe0fd0d21c39efbb09c11875 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.24; | |
library Flags { | |
function makeFlagSet(bytes8[] _flags) | |
internal | |
pure | |
returns (bytes8) | |
{ | |
bytes8 flagSet; | |
for (uint8 i = 0; i < _flags.length; i++) { | |
flagSet = addFlag(flagSet, _flags[i]); | |
} | |
return flagSet; | |
} | |
function hasFlag(bytes8 _field, bytes8 _flag) | |
internal | |
pure | |
returns (bool) | |
{ | |
return _flagIntersection(_field, _flag) != 0; | |
} | |
function addFlag(bytes8 _field, bytes8 _flag) | |
internal | |
pure | |
returns (bytes8) | |
{ | |
return _field | _flag; | |
} | |
function removeFlag(bytes8 _field, bytes8 _flag) | |
internal | |
pure | |
returns (bytes8) | |
{ | |
return _field & ~_flag; | |
} | |
function _flagIntersection(bytes8 _field, bytes8 _flags) | |
internal | |
pure | |
returns (bytes8) | |
{ | |
return (_field & _flags); | |
} | |
} |
Author
shrugs
commented
Aug 29, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment