logo

const class

sys::Bool

sys::Obj
  sys::Bool
  1  //
  2  // Copyright (c) 2006, Brian Frank and Andy Frank
  3  // Licensed under the Academic Free License version 3.0
  4  //
  5  // History:
  6  //   2 Dec 05  Brian Frank  Creation
  7  //
  8  
  9  **
 10  ** Bool represents a boolean condition of true or false.
 11  **
 12  const final class Bool
 13  {
 14  
 15  //////////////////////////////////////////////////////////////////////////
 16  // Constructor
 17  //////////////////////////////////////////////////////////////////////////
 18  
 19    **
 20    ** Parse a Str into a Bool.  Valid formats are "true" or "false".
 21    ** If invalid format and checked is false return null, otherwise
 22    ** throw ParseErr.
 23    **
 24    static Bool fromStr(Str s, Bool checked := true)
 25  
 26    **
 27    ** Private constructor.
 28    **
 29    private new make()
 30  
 31  //////////////////////////////////////////////////////////////////////////
 32  // Obj Overrides
 33  //////////////////////////////////////////////////////////////////////////
 34  
 35    **
 36    ** Return if same boolean value.
 37    **
 38    override Bool equals(Obj obj)
 39  
 40    **
 41    ** Return 1231 for true and 1237 for false.
 42    **
 43    override Int hash()
 44  
 45    **
 46    ** Return "true" or "false".
 47    **
 48    override Str toStr()
 49  
 50  //////////////////////////////////////////////////////////////////////////
 51  // Methods
 52  //////////////////////////////////////////////////////////////////////////
 53  
 54    **
 55    ** Return the logical not: if true return false; if false return true.
 56    **
 57    Bool not()
 58  
 59    **
 60    ** Bitwise "and" of this and b.  Shortcut is a&b.  Note boolean bitwise
 61    ** "and" does not short circuit like logical "and" (&& operator).
 62    **
 63    Bool amp(Bool b)
 64  
 65    **
 66    ** Bitwise "or" of this and b.  Shortcut is a|b.  Note boolean bitwise
 67    ** "or" does not short circuit like logical "or" (|| operator).
 68    **
 69    Bool pipe(Bool b)
 70  
 71    **
 72    ** Bitwise "exclusive-or" of this and b.  Shortcut is a^b.  Note this
 73    ** operator does not short circuit like && or ||.
 74    **
 75    Bool caret(Bool b)
 76  
 77  
 78  }