package pgtype

import (
	
	
	
	
	
	

	
)

type Lseg struct {
	P      [2]Vec2
	Status Status
}

func ( *Lseg) ( interface{}) error {
	return fmt.Errorf("cannot convert %v to Lseg", )
}

func ( Lseg) () interface{} {
	switch .Status {
	case Present:
		return 
	case Null:
		return nil
	default:
		return .Status
	}
}

func ( *Lseg) ( interface{}) error {
	return fmt.Errorf("cannot assign %v to %T", , )
}

func ( *Lseg) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Lseg{Status: Null}
		return nil
	}

	if len() < 11 {
		return fmt.Errorf("invalid length for Lseg: %v", len())
	}

	 := string([2:])

	var  int
	 = strings.IndexByte(, ',')

	,  := strconv.ParseFloat([:], 64)
	if  != nil {
		return 
	}

	 = [+1:]
	 = strings.IndexByte(, ')')

	,  := strconv.ParseFloat([:], 64)
	if  != nil {
		return 
	}

	 = [+3:]
	 = strings.IndexByte(, ',')

	,  := strconv.ParseFloat([:], 64)
	if  != nil {
		return 
	}

	 = [+1 : len()-2]

	,  := strconv.ParseFloat(, 64)
	if  != nil {
		return 
	}

	* = Lseg{P: [2]Vec2{{, }, {, }}, Status: Present}
	return nil
}

func ( *Lseg) ( *ConnInfo,  []byte) error {
	if  == nil {
		* = Lseg{Status: Null}
		return nil
	}

	if len() != 32 {
		return fmt.Errorf("invalid length for Lseg: %v", len())
	}

	 := binary.BigEndian.Uint64()
	 := binary.BigEndian.Uint64([8:])
	 := binary.BigEndian.Uint64([16:])
	 := binary.BigEndian.Uint64([24:])

	* = Lseg{
		P: [2]Vec2{
			{math.Float64frombits(), math.Float64frombits()},
			{math.Float64frombits(), math.Float64frombits()},
		},
		Status: Present,
	}
	return nil
}

func ( Lseg) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	 = append(, fmt.Sprintf(`(%s,%s),(%s,%s)`,
		strconv.FormatFloat(.P[0].X, 'f', -1, 64),
		strconv.FormatFloat(.P[0].Y, 'f', -1, 64),
		strconv.FormatFloat(.P[1].X, 'f', -1, 64),
		strconv.FormatFloat(.P[1].Y, 'f', -1, 64),
	)...)

	return , nil
}

func ( Lseg) ( *ConnInfo,  []byte) ([]byte, error) {
	switch .Status {
	case Null:
		return nil, nil
	case Undefined:
		return nil, errUndefined
	}

	 = pgio.AppendUint64(, math.Float64bits(.P[0].X))
	 = pgio.AppendUint64(, math.Float64bits(.P[0].Y))
	 = pgio.AppendUint64(, math.Float64bits(.P[1].X))
	 = pgio.AppendUint64(, math.Float64bits(.P[1].Y))
	return , nil
}
Scan implements the database/sql Scanner interface.
func ( *Lseg) ( interface{}) error {
	if  == nil {
		* = Lseg{Status: Null}
		return nil
	}

	switch src := .(type) {
	case string:
		return .DecodeText(nil, []byte())
	case []byte:
		 := make([]byte, len())
		copy(, )
		return .DecodeText(nil, )
	}

	return fmt.Errorf("cannot scan %T", )
}
Value implements the database/sql/driver Valuer interface.
func ( Lseg) () (driver.Value, error) {
	return EncodeValueText()