另客网go项目公用的代码库

any_bool.go 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 BoolValue
  49. }
  50. func (any *trueAny) MustBeValid() Any {
  51. return any
  52. }
  53. type falseAny struct {
  54. baseAny
  55. }
  56. func (any *falseAny) LastError() error {
  57. return nil
  58. }
  59. func (any *falseAny) ToBool() bool {
  60. return false
  61. }
  62. func (any *falseAny) ToInt() int {
  63. return 0
  64. }
  65. func (any *falseAny) ToInt32() int32 {
  66. return 0
  67. }
  68. func (any *falseAny) ToInt64() int64 {
  69. return 0
  70. }
  71. func (any *falseAny) ToUint() uint {
  72. return 0
  73. }
  74. func (any *falseAny) ToUint32() uint32 {
  75. return 0
  76. }
  77. func (any *falseAny) ToUint64() uint64 {
  78. return 0
  79. }
  80. func (any *falseAny) ToFloat32() float32 {
  81. return 0
  82. }
  83. func (any *falseAny) ToFloat64() float64 {
  84. return 0
  85. }
  86. func (any *falseAny) ToString() string {
  87. return "false"
  88. }
  89. func (any *falseAny) WriteTo(stream *Stream) {
  90. stream.WriteFalse()
  91. }
  92. func (any *falseAny) Parse() *Iterator {
  93. return nil
  94. }
  95. func (any *falseAny) GetInterface() interface{} {
  96. return false
  97. }
  98. func (any *falseAny) ValueType() ValueType {
  99. return BoolValue
  100. }
  101. func (any *falseAny) MustBeValid() Any {
  102. return any
  103. }