// NewUnaryBooleanExpression creates a new unary boolean evaluator.
166107
func NewUnaryBooleanExpression(op OP, lE Evaluator) (Evaluator, error) {
	switch op {
	case NOT:
		return &booleanNode{
			op: op,
			lS: true,
			lE: lE,
			rS: false,
		}, nil
	default:
		return nil, errors.New("unary boolean expressions require the operation to be one for the follwing 'not'")
	}
}
130014
func (v *printVisitor) VisitBoolean(node *BooleanLiteral) interface{} {
	if v.original {
		v.str(node.Original)
	} else {
		v.str(fmt.Sprintf("BOOLEAN{%s}", node.Canonical()))
	}

	return nil
}
501220
func isBooleanOp(op token.Token) bool {
	switch op {
	case token.EQL, token.NEQ, token.LEQ, token.GEQ, token.LSS, token.GTR:
		return true
	default:
		return false
	}
}
317490
func (s *Session) GetBoolean(key string) (bool, error) {
	v := s.Get(key)
	if v == nil {
		return false, errFindParse.Format("bool", key, "nil")
	}

	// here we could check for "true", "false" and 0 for false and 1 for true
	// but this may cause unexpected behavior from the developer if they expecting an error
	// so we just check if bool, if yes then return that bool, otherwise return false and an error.
	if vb, ok := v.(bool); ok {
		return vb, nil
	}
	if vstring, ok := v.(string); ok {
		return strconv.ParseBool(vstring)
	}

	return false, errFindParse.Format("bool", key, v)
}
1173840
func (s *numericCompilerVisitor) AcceptBooleanLiteral(v tree.BooleanLiteral) {
	s.err = errors.New("a boolean literal was found in a numeric expression - this is likely a programmer error")
}
1037665
func NewBool(ok bool) *AtomicBool {
	ab := New()
	if ok {
		ab.Set()
	}
	return ab
}
79467
func (me *DefaultAdapter) BooleanExpressionSql(buf *SqlBuilder, operator BooleanExpression) error {
	buf.WriteRune(left_paren_rune)
	if err := me.Literal(buf, operator.Lhs()); err != nil {
		return err
	}
	buf.WriteRune(space_rune)
	operatorOp := operator.Op()
	if operator.Rhs() == nil {
		switch operatorOp {
		case EQ_OP:
			operatorOp = IS_OP
		case NEQ_OP:
			operatorOp = IS_NOT_OP
		}
	}
	if val, ok := me.BooleanOperatorLookup[operatorOp]; ok {
		buf.Write(val)
	} else {
		return NewGoquError("Boolean operator %+v not supported", operatorOp)
	}
	rhs := operator.Rhs()
	if (operatorOp == IS_OP || operatorOp == IS_NOT_OP) && me.UseLiteralIsBools {
		if rhs == true {
			rhs = L("TRUE")
		} else if rhs == false {
			rhs = L("FALSE")
		}
	}
	buf.WriteRune(space_rune)
	if err := me.Literal(buf, rhs); err != nil {
		return err
	}
	buf.WriteRune(right_paren_rune)
	return nil
}
681687
func NewBoolFlag(fl cli.BoolFlag) *BoolFlag {
	return &BoolFlag{BoolFlag: fl, set: nil}
}
1335610
func NewBooleanOr(Variable node.Node, Expression node.Node) *BooleanOr {
	return &BooleanOr{
		FreeFloating: nil,
		Left:         Variable,
		Right:        Expression,
	}
}
399149
func ParseBool(s string) (bool, error) {
	v, err := boolParser.Parse(s)
	if err != nil {
		return false, err
	}
	return v.(bool), nil
}
741561
func NewBool(name string, description string, metadata *types.MetricMetadata, fields ...field.Field) Bool {
	if metadata == nil {
		metadata = &types.MetricMetadata{}
	}
	m := &boolMetric{metric{
		MetricInfo: types.MetricInfo{
			Name:        name,
			Description: description,
			Fields:      fields,
			ValueType:   types.BoolType,
		},
		MetricMetadata: *metadata,
	}}
	registry.Add(m)
	return m
}
1317563
func (v *Object) GetBoolean(keys ...string) (bool, error) {
	child, err := v.getPath(keys)

	if err != nil {
		return false, err
	}
	return child.Boolean()
}
529513
func NewUnary(operator lex.Token, arg Node) Node {
	nn, ok := arg.(NegateableNode)
	switch operator.T {
	case lex.TokenNegate:
		if ok {
			nn.ReverseNegation()
			return nn.Collapse()
		}
	}

	// In the event we are adding a binary here, we might have
	// rewritten a little so lets make sure its interpreted/nested coorectly
	bn, isBinary := arg.(*BinaryNode)
	if isBinary {
		bn.Paren = true
	}

	return &UnaryNode{Arg: arg, Operator: operator}
}
1090780
func NewBooleanFieldMapping() *FieldMapping {
	return &FieldMapping{
		Type:         "boolean",
		Store:        true,
		Index:        true,
		IncludeInAll: true,
		DocValues:    true,
	}
}
889243
func NewAnyMatcher(p Pos, v string) *AnyMatcher {
	return &AnyMatcher{posValue{p, v}}
}
674570
func ParseBool(b string) *bool {
	var truth bool
	switch b {
	case "enabled":
		truth = true
	case "disabled":
		truth = false
	default:
		return nil
	}
	return &truth
}
404451
func NewBooleanLiteral(pos int, line int, val bool, original string) *BooleanLiteral {
	return &BooleanLiteral{
		NodeType: NodeBoolean,
		Loc:      Loc{pos, line},

		Value:    val,
		Original: original,
	}
}