// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package norm

import 

type input struct {
	str   string
	bytes []byte
}

func ( []byte) input {
	return input{bytes: }
}

func ( string) input {
	return input{str: }
}

func ( *input) ( []byte) {
	.str = ""
	.bytes = 
}

func ( *input) ( string) {
	.str = 
	.bytes = nil
}

func ( *input) ( int) byte {
	if .bytes == nil {
		return .str[]
	}
	return .bytes[]
}

func ( *input) (,  int) int {
	if .bytes == nil {
		for ;  <  && .str[] < utf8.RuneSelf; ++ {
		}
	} else {
		for ;  <  && .bytes[] < utf8.RuneSelf; ++ {
		}
	}
	return 
}

func ( *input) ( int) int {
	if .bytes == nil {
		for ;  < len(.str) && !utf8.RuneStart(.str[]); ++ {
		}
	} else {
		for ;  < len(.bytes) && !utf8.RuneStart(.bytes[]); ++ {
		}
	}
	return 
}

func ( *input) ( []byte, ,  int) []byte {
	if .bytes != nil {
		return append(, .bytes[:]...)
	}
	for  := ;  < ; ++ {
		 = append(, .str[])
	}
	return 
}

func ( *input) ( []byte, ,  int) int {
	if .bytes == nil {
		return copy(, .str[:])
	}
	return copy(, .bytes[:])
}

func ( *input) ( int) (uint16, int) {
	if .bytes == nil {
		return nfcData.lookupString(.str[:])
	}
	return nfcData.lookup(.bytes[:])
}

func ( *input) ( int) (uint16, int) {
	if .bytes == nil {
		return nfkcData.lookupString(.str[:])
	}
	return nfkcData.lookup(.bytes[:])
}

func ( *input) ( int) ( rune) {
	var  int
	if .bytes == nil {
		if !isHangulString(.str[:]) {
			return 0
		}
		,  = utf8.DecodeRuneInString(.str[:])
	} else {
		if !isHangul(.bytes[:]) {
			return 0
		}
		,  = utf8.DecodeRune(.bytes[:])
	}
	if  != hangulUTF8Size {
		return 0
	}
	return 
}