github.com/wI2L/jettison@v0.7.5-0.20230106001914-c70014c6417a/integer.go (about)

     1  package jettison
     2  
     3  import (
     4  	"strconv"
     5  	"unsafe"
     6  )
     7  
     8  // nolint:unparam
     9  func encodeInt(
    10  	p unsafe.Pointer, dst []byte, _ encOpts,
    11  ) ([]byte, error) {
    12  	return strconv.AppendInt(dst, int64(*(*int)(p)), 10), nil
    13  }
    14  
    15  // nolint:unparam
    16  func encodeInt8(
    17  	p unsafe.Pointer, dst []byte, _ encOpts,
    18  ) ([]byte, error) {
    19  	return strconv.AppendInt(dst, int64(*(*int8)(p)), 10), nil
    20  }
    21  
    22  // nolint:unparam
    23  func encodeInt16(
    24  	p unsafe.Pointer, dst []byte, _ encOpts,
    25  ) ([]byte, error) {
    26  	return strconv.AppendInt(dst, int64(*(*int16)(p)), 10), nil
    27  }
    28  
    29  // nolint:unparam
    30  func encodeInt32(
    31  	p unsafe.Pointer, dst []byte, _ encOpts,
    32  ) ([]byte, error) {
    33  	return strconv.AppendInt(dst, int64(*(*int32)(p)), 10), nil
    34  }
    35  
    36  // nolint:unparam
    37  func encodeInt64(
    38  	p unsafe.Pointer, dst []byte, _ encOpts,
    39  ) ([]byte, error) {
    40  	return strconv.AppendInt(dst, *(*int64)(p), 10), nil
    41  }
    42  
    43  // nolint:unparam
    44  func encodeUint(
    45  	p unsafe.Pointer, dst []byte, _ encOpts,
    46  ) ([]byte, error) {
    47  	return strconv.AppendUint(dst, uint64(*(*uint)(p)), 10), nil
    48  }
    49  
    50  // nolint:unparam
    51  func encodeUint8(
    52  	p unsafe.Pointer, dst []byte, _ encOpts,
    53  ) ([]byte, error) {
    54  	return strconv.AppendUint(dst, uint64(*(*uint8)(p)), 10), nil
    55  }
    56  
    57  // nolint:unparam
    58  func encodeUint16(
    59  	p unsafe.Pointer, dst []byte, _ encOpts,
    60  ) ([]byte, error) {
    61  	return strconv.AppendUint(dst, uint64(*(*uint16)(p)), 10), nil
    62  }
    63  
    64  // nolint:unparam
    65  func encodeUint32(
    66  	p unsafe.Pointer, dst []byte, _ encOpts,
    67  ) ([]byte, error) {
    68  	return strconv.AppendUint(dst, uint64(*(*uint32)(p)), 10), nil
    69  }
    70  
    71  // nolint:unparam
    72  func encodeUint64(
    73  	p unsafe.Pointer, dst []byte, _ encOpts,
    74  ) ([]byte, error) {
    75  	return strconv.AppendUint(dst, *(*uint64)(p), 10), nil
    76  }
    77  
    78  // nolint:unparam
    79  func encodeUintptr(
    80  	p unsafe.Pointer, dst []byte, _ encOpts,
    81  ) ([]byte, error) {
    82  	return strconv.AppendUint(dst, uint64(*(*uintptr)(p)), 10), nil
    83  }