// ToBool converts a string ("true" or "false") to its boolean equivalent
8325
func ToBool(s string) (b bool) {
	if len(s) == 0 {
		log.Fatal("ERROR: variable empty, cannot convert to boolean")
	}
	switch s {
	case "false":
		b = false
	case "true":
		b = true
	}
	return b
}
941947
func (lx *lexer) isBool() bool {
	str := strings.ToLower(lx.input[lx.start:lx.pos])
	return str == "true" || str == "false" ||
		str == "on" || str == "off" ||
		str == "yes" || str == "no"
}
877281
func (d Data) GetBool(key string) bool {
	if !d.KeyExists(key) || len(d.Values[key]) == 0 {
		return false
	}
	str := d.Get(key)
	if result, err := strconv.ParseBool(str); err != nil {
		panic(err)
	} else {
		return result
	}
}
394098
func (f *Queries) MustBool(key string, defaults ...bool) bool {
	if v, ok := f.Values()[key]; ok {
		i, err := strconv.ParseBool(v[0])
		if err == nil {
			return i
		}
	}
	if len(defaults) > 0 {
		return defaults[0]
	}
	return false
}
1209161
func toBoolean(value string) (interface{}, error) {
	switch strings.ToLower(value) {
	case "y", "yes", "true", "on":
		return true, nil
	case "n", "no", "false", "off":
		return false, nil
	default:
		return nil, errors.Errorf("invalid boolean: %s", value)
	}
}
599560
func (d *Datum) ToBool(sc *stmtctx.StatementContext) (int64, error) {
	var err error
	isZero := false
	switch d.Kind() {
	case KindInt64:
		isZero = d.GetInt64() == 0
	case KindUint64:
		isZero = d.GetUint64() == 0
	case KindFloat32:
		isZero = RoundFloat(d.GetFloat64()) == 0
	case KindFloat64:
		isZero = RoundFloat(d.GetFloat64()) == 0
	case KindString, KindBytes:
		iVal, err1 := StrToInt(sc, d.GetString())
		isZero, err = iVal == 0, err1
	case KindMysqlTime:
		isZero = d.GetMysqlTime().IsZero()
	case KindMysqlDuration:
		isZero = d.GetMysqlDuration().Duration == 0
	case KindMysqlDecimal:
		v, err1 := d.GetMysqlDecimal().ToFloat64()
		isZero, err = RoundFloat(v) == 0, err1
	case KindMysqlEnum:
		isZero = d.GetMysqlEnum().ToNumber() == 0
	case KindMysqlSet:
		isZero = d.GetMysqlSet().ToNumber() == 0
	case KindBinaryLiteral, KindMysqlBit:
		val, err1 := d.GetBinaryLiteral().ToInt(sc)
		isZero, err = val == 0, err1
	default:
		return 0, errors.Errorf("cannot convert %v(type %T) to bool", d.GetValue(), d.GetValue())
	}
	var ret int64
	if isZero {
		ret = 0
	} else {
		ret = 1
	}
	if err != nil {
		return ret, errors.Trace(err)
	}
	return ret, nil
}
125453
func readBool(input string) (value bool, valid bool) {
	switch input {
	case "1", "true", "TRUE", "True":
		return true, true
	case "0", "false", "FALSE", "False":
		return false, true
	}

	// Not a valid bool value
	return
}
791311
func (j *Json) MustBool(args ...bool) bool {
	var def bool

	switch len(args) {
	case 0:
	case 1:
		def = args[0]
	default:
		log.Panicf("MustBool() received too many arguments %d", len(args))
	}

	b, err := j.Bool()
	if err == nil {
		return b
	}

	return def
}
1172717
func (enc *Encoder) WriteBool(val bool) error {
	if val {
		return enc.writeUnsigned(1)
	}
	return enc.writeUnsigned(0)
}
223054
func AsBool(v string) bool {
	if v == "" {
		return false
	}
	out, _ := ParseBool(v)
	return out
}
343329
func (o *IntOptions) SetBool(key string, value bool) {
	intValue := OptionDisabled
	if value {
		intValue = OptionEnabled
	}
	o.optsMU.Lock()
	o.Opts[key] = intValue
	o.optsMU.Unlock()
}
1063595
func parseBool(str string) (bool, error) {
	switch strings.ToLower(str) {
	case "1", "t", "true", "y", "yes":
		return true, nil
	case "0", "f", "false", "n", "no":
		return false, nil
	}
	return false, fmt.Errorf("%s is not valid. Please choose between (y)es or (n)o", str)
}
388538
func (s *Session) GetBool(key string) bool {
	r, _ := s.Get(key).(bool)
	return r
}
1188189
func (f *Flag) Bool(name string) (bool, error) {
	v, err := f.value(name)
	if err != nil {
		return false, err
	}

	return strconv.ParseBool(v)
}
273904
func (s Slice) GetBool() (bool, error) {
	if err := s.AssertType(Bool); err != nil {
		return false, WithStack(err)
	}
	return s.IsTrue(), nil
}
76031
func (e *Environment) Bool(name string) (bool, error) {
	v, err := e.value(name)
	if err != nil {
		return false, err
	}

	return strconv.ParseBool(v)
}
308858
func parseBool(v string) (bool, error) {
	switch strings.ToLower(v) {
	case "true", "t", "yes", "y", "1", "":
		return true, nil
	case "false", "f", "no", "n", "0":
		return false, nil
	}
	return false, fmt.Errorf(`illegal input "%s" for bool value`, v)
}