decoder_native.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //go:build (amd64 && go1.17 && !go1.25) || (arm64 && go1.20 && !go1.25)
  2. // +build amd64,go1.17,!go1.25 arm64,go1.20,!go1.25
  3. /*
  4. * Copyright 2023 ByteDance Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package decoder
  19. import (
  20. `github.com/bytedance/sonic/internal/decoder/api`
  21. )
  22. // Decoder is the decoder context object
  23. type Decoder = api.Decoder
  24. // SyntaxError represents json syntax error
  25. type SyntaxError = api.SyntaxError
  26. // MismatchTypeError represents mismatching between json and object
  27. type MismatchTypeError = api.MismatchTypeError
  28. // Options for decode.
  29. type Options = api.Options
  30. const (
  31. OptionUseInt64 Options = api.OptionUseInt64
  32. OptionUseNumber Options = api.OptionUseNumber
  33. OptionUseUnicodeErrors Options = api.OptionUseUnicodeErrors
  34. OptionDisableUnknown Options = api.OptionDisableUnknown
  35. OptionCopyString Options = api.OptionCopyString
  36. OptionValidateString Options = api.OptionValidateString
  37. OptionNoValidateJSON Options = api.OptionNoValidateJSON
  38. OptionCaseSensitive Options = api.OptionCaseSensitive
  39. )
  40. // StreamDecoder is the decoder context object for streaming input.
  41. type StreamDecoder = api.StreamDecoder
  42. var (
  43. // NewDecoder creates a new decoder instance.
  44. NewDecoder = api.NewDecoder
  45. // NewStreamDecoder adapts to encoding/json.NewDecoder API.
  46. //
  47. // NewStreamDecoder returns a new decoder that reads from r.
  48. NewStreamDecoder = api.NewStreamDecoder
  49. // Pretouch compiles vt ahead-of-time to avoid JIT compilation on-the-fly, in
  50. // order to reduce the first-hit latency.
  51. //
  52. // Opts are the compile options, for example, "option.WithCompileRecursiveDepth" is
  53. // a compile option to set the depth of recursive compile for the nested struct type.
  54. Pretouch = api.Pretouch
  55. // Skip skips only one json value, and returns first non-blank character position and its ending position if it is valid.
  56. // Otherwise, returns negative error code using start and invalid character position using end
  57. Skip = api.Skip
  58. )