// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package keys

import (
	
	
	
	

	
)

// Value represents a key for untyped values.
type Value struct {
	name        string
	description string
}

// New creates a new Key for untyped values.
func (,  string) *Value {
	return &Value{name: , description: }
}

func ( *Value) () string        { return .name }
func ( *Value) () string { return .description }

func ( *Value) ( io.Writer,  []byte,  label.Label) {
	fmt.Fprint(, .From())
}

// Get can be used to get a label for the key from a label.Map.
func ( *Value) ( label.Map) interface{} {
	if  := .Find(); .Valid() {
		return .From()
	}
	return nil
}

// From can be used to get a value from a Label.
func ( *Value) ( label.Label) interface{} { return .UnpackValue() }

// Of creates a new Label with this key and the supplied value.
func ( *Value) ( interface{}) label.Label { return label.OfValue(, ) }

// Tag represents a key for tagging labels that have no value.
// These are used when the existence of the label is the entire information it
// carries, such as marking events to be of a specific kind, or from a specific
// package.
type Tag struct {
	name        string
	description string
}

// NewTag creates a new Key for tagging labels.
func (,  string) *Tag {
	return &Tag{name: , description: }
}

func ( *Tag) () string        { return .name }
func ( *Tag) () string { return .description }

func ( *Tag) ( io.Writer,  []byte,  label.Label) {}

// New creates a new Label with this key.
func ( *Tag) () label.Label { return label.OfValue(, nil) }

// Int represents a key
type Int struct {
	name        string
	description string
}

// NewInt creates a new Key for int values.
func (,  string) *Int {
	return &Int{name: , description: }
}

func ( *Int) () string        { return .name }
func ( *Int) () string { return .description }

func ( *Int) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendInt(, int64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *Int) ( int) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *Int) ( label.Map) int {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Int) ( label.Label) int { return int(.Unpack64()) }

// Int8 represents a key
type Int8 struct {
	name        string
	description string
}

// NewInt8 creates a new Key for int8 values.
func (,  string) *Int8 {
	return &Int8{name: , description: }
}

func ( *Int8) () string        { return .name }
func ( *Int8) () string { return .description }

func ( *Int8) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendInt(, int64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *Int8) ( int8) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *Int8) ( label.Map) int8 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Int8) ( label.Label) int8 { return int8(.Unpack64()) }

// Int16 represents a key
type Int16 struct {
	name        string
	description string
}

// NewInt16 creates a new Key for int16 values.
func (,  string) *Int16 {
	return &Int16{name: , description: }
}

func ( *Int16) () string        { return .name }
func ( *Int16) () string { return .description }

func ( *Int16) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendInt(, int64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *Int16) ( int16) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *Int16) ( label.Map) int16 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Int16) ( label.Label) int16 { return int16(.Unpack64()) }

// Int32 represents a key
type Int32 struct {
	name        string
	description string
}

// NewInt32 creates a new Key for int32 values.
func (,  string) *Int32 {
	return &Int32{name: , description: }
}

func ( *Int32) () string        { return .name }
func ( *Int32) () string { return .description }

func ( *Int32) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendInt(, int64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *Int32) ( int32) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *Int32) ( label.Map) int32 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Int32) ( label.Label) int32 { return int32(.Unpack64()) }

// Int64 represents a key
type Int64 struct {
	name        string
	description string
}

// NewInt64 creates a new Key for int64 values.
func (,  string) *Int64 {
	return &Int64{name: , description: }
}

func ( *Int64) () string        { return .name }
func ( *Int64) () string { return .description }

func ( *Int64) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendInt(, .From(), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *Int64) ( int64) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *Int64) ( label.Map) int64 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Int64) ( label.Label) int64 { return int64(.Unpack64()) }

// UInt represents a key
type UInt struct {
	name        string
	description string
}

// NewUInt creates a new Key for uint values.
func (,  string) *UInt {
	return &UInt{name: , description: }
}

func ( *UInt) () string        { return .name }
func ( *UInt) () string { return .description }

func ( *UInt) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendUint(, uint64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *UInt) ( uint) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *UInt) ( label.Map) uint {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *UInt) ( label.Label) uint { return uint(.Unpack64()) }

// UInt8 represents a key
type UInt8 struct {
	name        string
	description string
}

// NewUInt8 creates a new Key for uint8 values.
func (,  string) *UInt8 {
	return &UInt8{name: , description: }
}

func ( *UInt8) () string        { return .name }
func ( *UInt8) () string { return .description }

func ( *UInt8) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendUint(, uint64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *UInt8) ( uint8) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *UInt8) ( label.Map) uint8 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *UInt8) ( label.Label) uint8 { return uint8(.Unpack64()) }

// UInt16 represents a key
type UInt16 struct {
	name        string
	description string
}

// NewUInt16 creates a new Key for uint16 values.
func (,  string) *UInt16 {
	return &UInt16{name: , description: }
}

func ( *UInt16) () string        { return .name }
func ( *UInt16) () string { return .description }

func ( *UInt16) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendUint(, uint64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *UInt16) ( uint16) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *UInt16) ( label.Map) uint16 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *UInt16) ( label.Label) uint16 { return uint16(.Unpack64()) }

// UInt32 represents a key
type UInt32 struct {
	name        string
	description string
}

// NewUInt32 creates a new Key for uint32 values.
func (,  string) *UInt32 {
	return &UInt32{name: , description: }
}

func ( *UInt32) () string        { return .name }
func ( *UInt32) () string { return .description }

func ( *UInt32) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendUint(, uint64(.From()), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *UInt32) ( uint32) label.Label { return label.Of64(, uint64()) }

// Get can be used to get a label for the key from a label.Map.
func ( *UInt32) ( label.Map) uint32 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *UInt32) ( label.Label) uint32 { return uint32(.Unpack64()) }

// UInt64 represents a key
type UInt64 struct {
	name        string
	description string
}

// NewUInt64 creates a new Key for uint64 values.
func (,  string) *UInt64 {
	return &UInt64{name: , description: }
}

func ( *UInt64) () string        { return .name }
func ( *UInt64) () string { return .description }

func ( *UInt64) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendUint(, .From(), 10))
}

// Of creates a new Label with this key and the supplied value.
func ( *UInt64) ( uint64) label.Label { return label.Of64(, ) }

// Get can be used to get a label for the key from a label.Map.
func ( *UInt64) ( label.Map) uint64 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *UInt64) ( label.Label) uint64 { return .Unpack64() }

// Float32 represents a key
type Float32 struct {
	name        string
	description string
}

// NewFloat32 creates a new Key for float32 values.
func (,  string) *Float32 {
	return &Float32{name: , description: }
}

func ( *Float32) () string        { return .name }
func ( *Float32) () string { return .description }

func ( *Float32) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendFloat(, float64(.From()), 'E', -1, 32))
}

// Of creates a new Label with this key and the supplied value.
func ( *Float32) ( float32) label.Label {
	return label.Of64(, uint64(math.Float32bits()))
}

// Get can be used to get a label for the key from a label.Map.
func ( *Float32) ( label.Map) float32 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Float32) ( label.Label) float32 {
	return math.Float32frombits(uint32(.Unpack64()))
}

// Float64 represents a key
type Float64 struct {
	name        string
	description string
}

// NewFloat64 creates a new Key for int64 values.
func (,  string) *Float64 {
	return &Float64{name: , description: }
}

func ( *Float64) () string        { return .name }
func ( *Float64) () string { return .description }

func ( *Float64) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendFloat(, .From(), 'E', -1, 64))
}

// Of creates a new Label with this key and the supplied value.
func ( *Float64) ( float64) label.Label {
	return label.Of64(, math.Float64bits())
}

// Get can be used to get a label for the key from a label.Map.
func ( *Float64) ( label.Map) float64 {
	if  := .Find(); .Valid() {
		return .From()
	}
	return 0
}

// From can be used to get a value from a Label.
func ( *Float64) ( label.Label) float64 {
	return math.Float64frombits(.Unpack64())
}

// String represents a key
type String struct {
	name        string
	description string
}

// NewString creates a new Key for int64 values.
func (,  string) *String {
	return &String{name: , description: }
}

func ( *String) () string        { return .name }
func ( *String) () string { return .description }

func ( *String) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendQuote(, .From()))
}

// Of creates a new Label with this key and the supplied value.
func ( *String) ( string) label.Label { return label.OfString(, ) }

// Get can be used to get a label for the key from a label.Map.
func ( *String) ( label.Map) string {
	if  := .Find(); .Valid() {
		return .From()
	}
	return ""
}

// From can be used to get a value from a Label.
func ( *String) ( label.Label) string { return .UnpackString() }

// Boolean represents a key
type Boolean struct {
	name        string
	description string
}

// NewBoolean creates a new Key for bool values.
func (,  string) *Boolean {
	return &Boolean{name: , description: }
}

func ( *Boolean) () string        { return .name }
func ( *Boolean) () string { return .description }

func ( *Boolean) ( io.Writer,  []byte,  label.Label) {
	.Write(strconv.AppendBool(, .From()))
}

// Of creates a new Label with this key and the supplied value.
func ( *Boolean) ( bool) label.Label {
	if  {
		return label.Of64(, 1)
	}
	return label.Of64(, 0)
}

// Get can be used to get a label for the key from a label.Map.
func ( *Boolean) ( label.Map) bool {
	if  := .Find(); .Valid() {
		return .From()
	}
	return false
}

// From can be used to get a value from a Label.
func ( *Boolean) ( label.Label) bool { return .Unpack64() > 0 }

// Error represents a key
type Error struct {
	name        string
	description string
}

// NewError creates a new Key for int64 values.
func (,  string) *Error {
	return &Error{name: , description: }
}

func ( *Error) () string        { return .name }
func ( *Error) () string { return .description }

func ( *Error) ( io.Writer,  []byte,  label.Label) {
	io.WriteString(, .From().Error())
}

// Of creates a new Label with this key and the supplied value.
func ( *Error) ( error) label.Label { return label.OfValue(, ) }

// Get can be used to get a label for the key from a label.Map.
func ( *Error) ( label.Map) error {
	if  := .Find(); .Valid() {
		return .From()
	}
	return nil
}

// From can be used to get a value from a Label.
func ( *Error) ( label.Label) error {
	,  := .UnpackValue().(error)
	return 
}