// Provided for compatibility with the Transformer interface. Since Caser has no
// special treatment of bytes, the bytes are converted to and from strings.
// Will treat the entirety of src as ONE variable name.
14
func (c Caser) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
	nSrc = len(src) // Always read all the bytes of src
	result := c.Bytes(src)
	if len(result) > len(dst) {
		err = transform.ErrShortDst
	}
	nDst = copy(dst, result)
	return
}
1020395
func ToString(i interface{}) string {
	switch t := i.(type) {
	case nil:
		return ""
	case []byte:
		return string(t)
	case string:
		return t
	case *string:
		return *t
	case bool:
		return strconv.FormatBool(t)
	case float32:
		return strconv.FormatFloat(float64(t), 'f', -1, 32)
	case float64:
		return strconv.FormatFloat(t, 'f', -1, 64)
	case int:
		return strconv.Itoa(t)
	case int32:
		return strconv.FormatInt(int64(t), 10)
	case int64:
		return strconv.FormatInt(t, 10)
	case template.HTML:
		return string(t)
	case template.URL:
		return string(t)
	case fmt.Stringer:
		return t.String()
	case error:
		return t.Error()
	default:
		return fmt.Sprint(i)
	}
}
1187300
func nameChar(c byte) bool {
	return 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_' || c > 127 ||
		c == '-' || '0' <= c && c <= '9'
}
1273749
func (v *Variable) Bytes() []byte {
	if len(v.Data) > 0 && v.Data[len(v.Data)-1] == 0x00 {
		return v.Data
	}
	return append(v.Data, 0x00)
}
262085
func String(t Transformer, s string) (result string, n int, err error) {
	if s == "" {
		return "", 0, nil
	}

	t.Reset()

	// Allocate only once. Note that both dst and src escape when passed to
	// Transform.
	buf := [2 * initialBufSize]byte{}
	dst := buf[:initialBufSize:initialBufSize]
	src := buf[initialBufSize : 2*initialBufSize]

	// Avoid allocation if the transformed string is identical to the original.
	// After this loop, pDst will point to the furthest point in s for which it
	// could be detected that t gives equal results, src[:nSrc] will
	// indicated the last processed chunk of s for which the output is not equal
	// and dst[:nDst] will be the transform of this chunk.
	var nDst, nSrc int
	pDst := 0 // Used as index in both src and dst in this loop.
	for {
		n := copy(src, s[pDst:])
		nDst, nSrc, err = t.Transform(dst, src[:n], pDst+n == len(s))

		// Note 1: we will not enter the loop with pDst == len(s) and we will
		// not end the loop with it either. So if nSrc is 0, this means there is
		// some kind of error from which we cannot recover given the current
		// buffer sizes. We will give up in this case.
		// Note 2: it is not entirely correct to simply do a bytes.Equal as
		// a Transformer may buffer internally. It will work in most cases,
		// though, and no harm is done if it doesn't work.
		// TODO:  let transformers implement an optional Spanner interface, akin
		// to norm's QuickSpan. This would even allow us to avoid any allocation.
		if nSrc == 0 || !bytes.Equal(dst[:nDst], src[:nSrc]) {
			break
		}

		if pDst += nDst; pDst == len(s) {
			return s, pDst, nil
		}
	}

	// Move the bytes seen so far to dst.
	pSrc := pDst + nSrc
	if pDst+nDst <= initialBufSize {
		copy(dst[pDst:], dst[:nDst])
	} else {
		b := make([]byte, len(s)+nDst-nSrc)
		copy(b[pDst:], dst[:nDst])
		dst = b
	}
	copy(dst, s[:pDst])
	pDst += nDst

	if err != nil && err != ErrShortDst && err != ErrShortSrc {
		return string(dst[:pDst]), pSrc, err
	}

	// Complete the string with the remainder.
	for {
		n := copy(src, s[pSrc:])
		nDst, nSrc, err = t.Transform(dst[pDst:], src[:n], pSrc+n == len(s))
		pDst += nDst
		pSrc += nSrc

		switch err {
		case nil:
			if pSrc == len(s) {
				return string(dst[:pDst]), pSrc, nil
			}
		case ErrShortDst:
			// Do not grow as long as we can make progress. This may avoid
			// excessive allocations.
			if nDst == 0 {
				dst = grow(dst, pDst)
			}
		case ErrShortSrc:
			if nSrc == 0 {
				src = grow(src, 0)
			}
		default:
			return string(dst[:pDst]), pSrc, err
		}
	}
}
8719
func toSnakeCase(name string) (hyphenated string) {
	snakeMemoizer.Lock()
	defer snakeMemoizer.Unlock()
	if hyphenated = snakeMemoizer.memo[name]; hyphenated != "" {
		return hyphenated
	}
	hyphenated = name
	for _, converter := range snakeConverters {
		hyphenated = converter.re.ReplaceAllString(hyphenated, converter.repl)
	}
	hyphenated = strings.ToLower(hyphenated)
	snakeMemoizer.memo[name] = hyphenated
	return
}
61771
func SwapCase(str string) string {
	var r rune
	var size int

	buf := &bytes.Buffer{}

	for len(str) > 0 {
		r, size = utf8.DecodeRuneInString(str)

		switch {
		case unicode.IsUpper(r):
			buf.WriteRune(unicode.ToLower(r))

		case unicode.IsLower(r):
			buf.WriteRune(unicode.ToUpper(r))

		default:
			buf.WriteRune(r)
		}

		str = str[size:]
	}

	return buf.String()
}
467845
func ToLower(src []byte) []byte {
	for i, c := range src {
		if c >= 'A' && c <= 'Z' {
			src[i] = c + ('a' - 'A')
		}
	}
	return src
}
307950
func ExtractCamelCaseAttributes(opts ...interface{}) *opt.CamelCaseAttributesOption {
	for _, o := range opts {
		if v, ok := o.(*opt.CamelCaseAttributesOption); ok {
			return v
		}
	}
	return nil
}
307823
func (p *gc_bin_parser) rawByte() byte {
	b := p.data[0]
	r := 1
	if b == '|' {
		b = p.data[1]
		r = 2
		switch b {
		case 'S':
			b = '$'
		case '|':
			// nothing to do
		default:
			panic("unexpected escape sequence in export data")
		}
	}
	p.data = p.data[r:]
	p.read += r
	return b

}
98821
func ToStr(value interface{}, args ...int) (s string) {
	switch v := value.(type) {
	case bool:
		s = strconv.FormatBool(v)
	case float32:
		s = strconv.FormatFloat(float64(v), 'f', argInt(args).Get(0, -1), argInt(args).Get(1, 32))
	case float64:
		s = strconv.FormatFloat(v, 'f', argInt(args).Get(0, -1), argInt(args).Get(1, 64))
	case int:
		s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
	case int8:
		s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
	case int16:
		s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
	case int32:
		s = strconv.FormatInt(int64(v), argInt(args).Get(0, 10))
	case int64:
		s = strconv.FormatInt(v, argInt(args).Get(0, 10))
	case uint:
		s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
	case uint8:
		s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
	case uint16:
		s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
	case uint32:
		s = strconv.FormatUint(uint64(v), argInt(args).Get(0, 10))
	case uint64:
		s = strconv.FormatUint(v, argInt(args).Get(0, 10))
	case string:
		s = v
	case []byte:
		s = string(v)
	default:
		s = fmt.Sprintf("%v", v)
	}
	return s
}
428133
func (v *Value) Repr() string {
	switch v.vType {
	case typeNull:
		return ":NULL"
	case typeBool, typeInt, typeFloat:
		return fmt.Sprintf("%v:%s", v.value, v.GetTypeString())
	case typeTimestamp:
		return fmt.Sprintf("%s:TIMESTAMP", v.value.(*time.Time))
	case typeString:
		return fmt.Sprintf("\"%s\":%s", v.value.(string), v.GetTypeString())
	case typeBytes:
		return fmt.Sprintf("\"%s\":BYTES", string(v.value.([]byte)))
	default:
		return fmt.Sprintf("%v:INVALID", v.value)
	}
}
706867
func (e NopEncoder) Serialize(src interface{}) ([]byte, error) {
	if b, ok := src.([]byte); ok {
		return b, nil
	}

	return nil, errValueNotByte
}
699695
func PascalCase(s string) string {
	n := ""
	capNext := true
	for _, v := range s {
		if v >= 'a' && v <= 'z' {
			if capNext {
				n += strings.ToUpper(string(v))
				capNext = false
			} else {
				n += string(v)
			}
			continue
		}
		if v == '_' || v == ' ' {
			capNext = true
		} else {
			capNext = false
			n += string(v)
		}
	}
	return n
}
1184298
func BytesSlice(val, sep string) ([][]byte, error) {
	s := strings.Split(val, sep)
	values := make([][]byte, len(s))
	for i, v := range s {
		value, err := Bytes(v)
		if err != nil {
			return values, err
		}
		values[i] = value
	}
	return values, nil
}
723059
func toString(val interface{}) string {
	switch actual := val.(type) {
	case string:
		return actual
	case int:
		return strconv.Itoa(actual)
	case float64:
		return strconv.FormatFloat(actual, 'f', -1, 64)
	case bool:
		return strconv.FormatBool(actual)
	default:
		panic("unexpected key type")
	}
}
548743
func iface2vstr(a interface{}) []string {
	r := []string{}
	switch a.(type) {
	case []interface{}:
		for _, item := range a.([]interface{}) {
			switch item.(type) {
			case string:
				r = append(r, item.(string))
			}
		}
	}
	return r
}