You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.0 KiB

4 years ago
package value
import (
"fmt"
4 years ago
"strconv"
"time"
)
4 years ago
var (
_ ParseValue = Uint64(0)
_ SliceValue = (Uint64s)(nil)
4 years ago
)
func NewUint64s(in []uint64) Slice {
return Slice{SliceValue: Uint64s(in)}
}
type Uint64s []uint64
func (u Uint64s) Any() interface{} {
return u.Uint64s()
4 years ago
}
func (u Uint64s) Unmarshal(val interface{}) error {
res, ok := val.(*[]uint64)
if !ok {
return fmt.Errorf("%w: expect *[]uint64", ErrWrongType)
4 years ago
}
*res = u
4 years ago
return nil
}
func (u Uint64s) Strings() []string {
return nil
}
func (u Uint64s) Ints() []int {
return nil
}
func (u Uint64s) Int64s() []int64 {
return nil
}
func (u Uint64s) Uints() []uint {
return nil
}
func (u Uint64s) Uint64s() []uint64 {
out := make([]uint64, len(u))
copy(out, u)
return out
}
func (u Uint64s) Float64s() []float64 {
return nil
}
func (u Uint64s) Bools() []bool {
return nil
}
func (u Uint64s) Durations() []time.Duration {
return nil
}
func (u Uint64s) Times() []time.Time {
return nil
}
func NewUint64(in uint64) Read {
return Read{ParseValue: Uint64(in)}
}
type Uint64 uint64
func (u Uint64) ParseString() (string, error) {
return strconv.FormatUint(uint64(u), 10), nil
}
func (u Uint64) ParseInt() (int, error) {
return int(u), nil
}
func (u Uint64) ParseInt64() (int64, error) {
return int64(u), nil
}
func (u Uint64) ParseUint() (uint, error) {
return uint(u), nil
}
func (u Uint64) ParseUint64() (uint64, error) {
return uint64(u), nil
}
func (u Uint64) ParseFloat64() (float64, error) {
return float64(u), nil
}
4 years ago
func (u Uint64) ParseBool() (bool, error) {
return false, fmt.Errorf("uint64 bool:%w", ErrWrongType)
4 years ago
}
func (u Uint64) ParseDuration() (time.Duration, error) {
return time.Duration(u), nil
4 years ago
}
func (u Uint64) ParseTime() (time.Time, error) {
return time.Unix(0, int64(0)), nil
}
func (u Uint64) Unmarshal(val interface{}) error {
res, ok := val.(*uint64)
if !ok {
return fmt.Errorf("%w: expect *uint64", ErrWrongType)
4 years ago
}
*res = uint64(u)
return nil
}
func (u Uint64) Any() interface{} {
return uint64(u)
4 years ago
}