// DatumsToString converts several datums to formatted string.
967213
func DatumsToString(datums []Datum, handleSpecialValue bool) (string, error) {
	strs := make([]string, 0, len(datums))
	for _, datum := range datums {
		if handleSpecialValue {
			switch datum.Kind() {
			case KindNull:
				strs = append(strs, "NULL")
				continue
			case KindMinNotNull:
				strs = append(strs, "-inf")
				continue
			case KindMaxValue:
				strs = append(strs, "+inf")
				continue
			}
		}
		str, err := datum.ToString()
		if err != nil {
			return "", errors.Trace(err)
		}
		strs = append(strs, str)
	}
	size := len(datums)
	if size > 1 {
		strs[0] = "(" + strs[0]
		strs[size-1] = strs[size-1] + ")"
	}
	return strings.Join(strs, ", "), nil
}
1176476
func Int64ToString(from int64) (string, error) {
	return strconv.FormatInt(int64(from), DefeultNumericBase), nil
}
1255338
func SizeToString(s int64) string {
	v := float64(s)
	i := 0
	for ; i < len(units); i++ {
		if v < 1024. {
			break
		}
		v /= 1024.
	}
	if i == 0 {
		return fmt.Sprintf("%d%s", s, units[i])
	}
	if v >= 10 {
		return fmt.Sprintf("%.1f%s", v, units[i])
	}
	return fmt.Sprintf("%.2f%s", v, units[i])
}
1129395
func (d *Datum) SetBytesAsString(b []byte) {
	d.k = KindString
	d.b = b
}
272403
func (d *Datum) SetString(s string) {
	d.k = KindString
	sink(s)
	d.b = hack.Slice(s)
}
218574
func MsgsToString(msgs []Msg, lineSep, linePrefix string) string {
	linePrefixRest := lineSep + linePrefix

	var buf bytes.Buffer

	for i := range msgs {
		msg := &msgs[i]

		body := ""
		bodySep := ""
		if msg.Body != nil {
			body = string(msg.Body)
			bodySep = " "
		}

		linePrefixCur := ""
		if i > 0 {
			linePrefixCur = linePrefixRest
		}

		if msg.Repeats > 1 {
			fmt.Fprintf(&buf, "%s%s (%dx)%s%s",
				linePrefixCur, msg.Title, msg.Repeats, bodySep, body)
		} else {
			fmt.Fprintf(&buf, "%s%s%s%s",
				linePrefixCur, msg.Title, bodySep, body)
		}
	}

	return buf.String()
}
453562
func (v *Value) bytesToString() string {
	bytes, _ := v.ToBytes()
	return string(bytes)
}
721308
func algoString(algo string) string {
	switch algo {
	case gossh.KeyAlgoRSA:
		return "RSA"
	case gossh.KeyAlgoDSA:
		return "DSA"
	case gossh.KeyAlgoECDSA256, gossh.KeyAlgoECDSA384, gossh.KeyAlgoECDSA521:
		return "ECDSA"
	}
	return algo
}
874577
func (e *Encoding) EncodeToString(src []byte) string {
	dst := make([]byte, EncodedLen(len(src)))
	e.Encode(dst, src)
	return string(dst)
}
654485
func NewString(into *string, v string) *StringValue {
	*into = v
	return (*StringValue)(into)
}
554668
func labelsToString(labels map[string][]string) string {
	ls := []string{}
	for k, v := range labels {
		ls = append(ls, fmt.Sprintf("%s:%v", k, v))
	}
	sort.Strings(ls)
	return strings.Join(ls, " ")
}
367034
func toDateString(d Date) string {
	year, month, day := d.Date()
	sign := ""
	if year < 0 {
		year = -year
		sign = "-"
	}
	return fmt.Sprintf("%s%04d-%02d-%02d", sign, year, int(month), day)
}
313576
func DurationToString(d time.Duration) string {
	minutes := int(d.Minutes()) % 60
	hours := int(d.Hours())
	days := hours / 24
	hours = hours % 24
	if days > 0 {
		return fmt.Sprintf("%dd %dhr", days, hours)
	}
	if hours > 0 {
		return fmt.Sprintf("%dhr %dm", hours, minutes)
	}
	return fmt.Sprintf("%dm", minutes)
}
312301
func ModeToString(mode Mode) (string, bool) {
	m := map[Mode]string{
		Recursive: linkRecursive,
		Direct:    linkDirect,
		Indirect:  linkIndirect,
		Internal:  linkInternal,
		NotPinned: linkNotPinned,
		Any:       linkAny,
	}
	s, ok := m[mode]
	return s, ok
}
283134
func ConvertToString(b []byte) string {
	s := make([]string, len(b))
	for i := range b {
		s[i] = strconv.Itoa(int(b[i]))
	}
	return strings.Join(s, ",")
}
920267
func UintToString(from uint) (string, error) {
	return strconv.FormatUint(uint64(from), DefeultNumericBase), nil
}
97481
func EmailsToString(mails []string) (s string) {
	for i, mail := range mails {
		if i > 0 {
			s += ", "
		}
		s += mail
	}
	return
}