github.com/goshafaq/sonic@v0.0.0-20231026082336-871835fb94c6/decoder/decoder_amd64.go (about)

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