feature_any_int32.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package jsoniter
  2. import (
  3. "strconv"
  4. )
  5. type int32Any struct {
  6. baseAny
  7. val int32
  8. }
  9. func (any *int32Any) LastError() error {
  10. return nil
  11. }
  12. func (any *int32Any) ValueType() ValueType {
  13. return Number
  14. }
  15. func (any *int32Any) ToBool() bool {
  16. return any.val != 0
  17. }
  18. func (any *int32Any) ToInt() int {
  19. return int(any.val)
  20. }
  21. func (any *int32Any) ToInt32() int32 {
  22. return any.val
  23. }
  24. func (any *int32Any) ToInt64() int64 {
  25. return int64(any.val)
  26. }
  27. func (any *int32Any) ToUint() uint {
  28. return uint(any.val)
  29. }
  30. func (any *int32Any) ToUint32() uint32 {
  31. return uint32(any.val)
  32. }
  33. func (any *int32Any) ToUint64() uint64 {
  34. return uint64(any.val)
  35. }
  36. func (any *int32Any) ToFloat32() float32 {
  37. return float32(any.val)
  38. }
  39. func (any *int32Any) ToFloat64() float64 {
  40. return float64(any.val)
  41. }
  42. func (any *int32Any) ToString() string {
  43. return strconv.FormatInt(int64(any.val), 10)
  44. }
  45. func (any *int32Any) WriteTo(stream *Stream) {
  46. stream.WriteInt32(any.val)
  47. }
  48. func (any *int32Any) Parse() *Iterator {
  49. return nil
  50. }
  51. func (any *int32Any) GetInterface() interface{} {
  52. return any.val
  53. }