package gojay

import (
	
)

// DecodeString reads the next JSON-encoded value from the decoder's input (io.Reader) and stores it in the string pointed to by v.
//
// See the documentation for Unmarshal for details about the conversion of JSON into a Go value.
func ( *Decoder) ( *string) error {
	if .isPooled == 1 {
		panic(InvalidUsagePooledDecoderError("Invalid usage of pooled decoder"))
	}
	return .decodeString()
}
func ( *Decoder) ( *string) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch .data[.cursor] {
		case ' ', '\n', '\t', '\r', ',':
			// is string
			continue
		case '"':
			.cursor++
			, ,  := .getString()
			if  != nil {
				return 
			}
			// we do minus one to remove the last quote
			 := .data[ : -1]
			* = *(*string)(unsafe.Pointer(&))
			.cursor = 
			return nil
		// is nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return nil
}

func ( *Decoder) ( **string) error {
	for ; .cursor < .length || .read(); .cursor++ {
		switch .data[.cursor] {
		case ' ', '\n', '\t', '\r', ',':
			// is string
			continue
		case '"':
			.cursor++
			, ,  := .getString()

			if  != nil {
				return 
			}
			if * == nil {
				* = new(string)
			}
			// we do minus one to remove the last quote
			 := .data[ : -1]
			** = *(*string)(unsafe.Pointer(&))
			.cursor = 
			return nil
		// is nil
		case 'n':
			.cursor++
			 := .assertNull()
			if  != nil {
				return 
			}
			return nil
		default:
			.err = .makeInvalidUnmarshalErr()
			 := .skipData()
			if  != nil {
				return 
			}
			return nil
		}
	}
	return nil
}

func ( *Decoder) () error {
	if .cursor >= .length && !.read() {
		return .raiseInvalidJSONErr(.cursor)
	}
	switch .data[.cursor] {
	case '"':
		.data[.cursor] = '"'
	case '\\':
		.data[.cursor] = '\\'
	case '/':
		.data[.cursor] = '/'
	case 'b':
		.data[.cursor] = '\b'
	case 'f':
		.data[.cursor] = '\f'
	case 'n':
		.data[.cursor] = '\n'
	case 'r':
		.data[.cursor] = '\r'
	case 't':
		.data[.cursor] = '\t'
	case 'u':
		 := .cursor
		.cursor++
		,  := .parseUnicode()
		if  != nil {
			return 
		}
		 := .cursor - 
		.data = append(append(.data[:-1], ...), .data[.cursor:]...)
		.length = len(.data)
		.cursor += len() -  - 1

		return nil
	default:
		return .raiseInvalidJSONErr(.cursor)
	}

	.data = append(.data[:.cursor-1], .data[.cursor:]...)
	.length--

	// Since we've lost a character, our dec.cursor offset is now
	// 1 past the escaped character which is precisely where we
	// want it.

	return nil
}

func ( *Decoder) () (int, int, error) {
	// extract key
	var  = .cursor
	// var str *Builder
	for .cursor < .length || .read() {
		switch .data[.cursor] {
		// string found
		case '"':
			.cursor = .cursor + 1
			return , .cursor, nil
		// slash found
		case '\\':
			.cursor = .cursor + 1
			 := .parseEscapedString()
			if  != nil {
				return 0, 0, 
			}
		default:
			.cursor = .cursor + 1
			continue
		}
	}
	return 0, 0, .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () error {
	 := .cursor
	for ; .cursor < .length || .read(); .cursor++ {
		if .data[.cursor] != '\\' {
			 := .data[.cursor]
			.cursor = .cursor + 1
			 := .cursor - 
			switch  {
			case '"':
				// nSlash must be odd
				if &1 != 1 {
					return .raiseInvalidJSONErr(.cursor)
				}
				return nil
			case 'u': // is unicode, we skip the following characters and place the cursor one one byte backward to avoid it breaking when returning to skipString
				if  := .skipString();  != nil {
					return 
				}
				.cursor--
				return nil
			case 'n', 'r', 't', '/', 'f', 'b':
				return nil
			default:
				// nSlash must be even
				if &1 == 1 {
					return .raiseInvalidJSONErr(.cursor)
				}
				return nil
			}
		}
	}
	return .raiseInvalidJSONErr(.cursor)
}

func ( *Decoder) () error {
	for .cursor < .length || .read() {
		switch .data[.cursor] {
		// found the closing quote
		// let's return
		case '"':
			.cursor = .cursor + 1
			return nil
		// solidus found start parsing an escaped string
		case '\\':
			.cursor = .cursor + 1
			 := .skipEscapedString()
			if  != nil {
				return 
			}
		default:
			.cursor = .cursor + 1
			continue
		}
	}
	return .raiseInvalidJSONErr(len(.data) - 1)
}

// Add Values functions

// AddString decodes the JSON value within an object or an array to a *string.
// If next key is not a JSON string nor null, InvalidUnmarshalError will be returned.
func ( *Decoder) ( *string) error {
	return .String()
}

// AddStringNull decodes the JSON value within an object or an array to a *string.
// If next key is not a JSON string nor null, InvalidUnmarshalError will be returned.
// If a `null` is encountered, gojay does not change the value of the pointer.
func ( *Decoder) ( **string) error {
	return .StringNull()
}

// String decodes the JSON value within an object or an array to a *string.
// If next key is not a JSON string nor null, InvalidUnmarshalError will be returned.
func ( *Decoder) ( *string) error {
	 := .decodeString()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}

// StringNull decodes the JSON value within an object or an array to a **string.
// If next key is not a JSON string nor null, InvalidUnmarshalError will be returned.
// If a `null` is encountered, gojay does not change the value of the pointer.
func ( *Decoder) ( **string) error {
	 := .decodeStringNull()
	if  != nil {
		return 
	}
	.called |= 1
	return nil
}