feature_any_bool.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package jsoniter
  2. type trueAny struct {
  3. baseAny
  4. }
  5. func (any *trueAny) LastError() error {
  6. return nil
  7. }
  8. func (any *trueAny) ToBool() bool {
  9. return true
  10. }
  11. func (any *trueAny) ToInt() int {
  12. return 1
  13. }
  14. func (any *trueAny) ToInt32() int32 {
  15. return 1
  16. }
  17. func (any *trueAny) ToInt64() int64 {
  18. return 1
  19. }
  20. func (any *trueAny) ToUint() uint {
  21. return 1
  22. }
  23. func (any *trueAny) ToUint32() uint32 {
  24. return 1
  25. }
  26. func (any *trueAny) ToUint64() uint64 {
  27. return 1
  28. }
  29. func (any *trueAny) ToFloat32() float32 {
  30. return 1
  31. }
  32. func (any *trueAny) ToFloat64() float64 {
  33. return 1
  34. }
  35. func (any *trueAny) ToString() string {
  36. return "true"
  37. }
  38. func (any *trueAny) WriteTo(stream *Stream) {
  39. stream.WriteTrue()
  40. }
  41. func (any *trueAny) Parse() *Iterator {
  42. return nil
  43. }
  44. func (any *trueAny) GetInterface() interface{} {
  45. return true
  46. }
  47. func (any *trueAny) ValueType() ValueType {
  48. return Bool
  49. }
  50. type falseAny struct {
  51. baseAny
  52. }
  53. func (any *falseAny) LastError() error {
  54. return nil
  55. }
  56. func (any *falseAny) ToBool() bool {
  57. return false
  58. }
  59. func (any *falseAny) ToInt() int {
  60. return 0
  61. }
  62. func (any *falseAny) ToInt32() int32 {
  63. return 0
  64. }
  65. func (any *falseAny) ToInt64() int64 {
  66. return 0
  67. }
  68. func (any *falseAny) ToUint() uint {
  69. return 0
  70. }
  71. func (any *falseAny) ToUint32() uint32 {
  72. return 0
  73. }
  74. func (any *falseAny) ToUint64() uint64 {
  75. return 0
  76. }
  77. func (any *falseAny) ToFloat32() float32 {
  78. return 0
  79. }
  80. func (any *falseAny) ToFloat64() float64 {
  81. return 0
  82. }
  83. func (any *falseAny) ToString() string {
  84. return "false"
  85. }
  86. func (any *falseAny) WriteTo(stream *Stream) {
  87. stream.WriteFalse()
  88. }
  89. func (any *falseAny) Parse() *Iterator {
  90. return nil
  91. }
  92. func (any *falseAny) GetInterface() interface{} {
  93. return false
  94. }
  95. func (any *falseAny) ValueType() ValueType {
  96. return Bool
  97. }