/*
reslove setting to sepcified data type class and valiadator classes
set: { type: 'string', required: true, ... }  /  set: 'string'
321189
function(set) {
        var dtype, valids, typeClass, self = this;
        //
        if (utils.isString(set)) {
            // resolve data type
            typeClass = this.dataTypes.get(set);
            if (typeClass) { dtype = new typeClass(); }
        }
        else if (set) {
            utils.each(set, function(key, val) {
                if (!utils.hasOwn(set, key)) {
                    return;
                }
                if (key.toLowerCase() === 'type') {
                    // resolve data type
                    typeClass = self.dataTypes.get(val);
                    if (typeClass) { dtype = new typeClass(); }
                } else {
                    // resolve validators
                    typeClass = self.validators.get(key);
                    if (typeClass) {
                        if (!valids) { valids = []; }
                        valids.push(new typeClass(set[key]));
                    }
                }
            });
        }
        return new modellingMetas(dtype, valids);
    }
547042
func SetValueFromStrings(f reflect.Value, values []string) error {
	ft := f.Type()

	if ft.Kind() != reflect.Slice && len(values) == 1 {
		err := SetValueFromString(f, values[0])
		if err != nil {
			return err
		}
		return nil
	}

	switch el := ft.Elem(); el.Kind() {
	case reflect.String:
		f.Set(reflect.ValueOf(values))
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		{
			resultList := reflect.MakeSlice(ft, 0, len(values))
			for _, value := range values {
				v, err := strconv.ParseInt(value, 0, el.Bits())
				if err != nil {
					return newBadRequestf("%s is not int format", value)
				}

				resultList = reflect.Append(resultList, reflect.ValueOf(v).Convert(el))
			}
			f.Set(resultList)
		}
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		{
			resultList := reflect.MakeSlice(ft, 0, len(values))
			for _, value := range values {
				v, err := strconv.ParseUint(value, 0, el.Bits())
				if err != nil {
					return newBadRequestf("%s is not uint format", value)
				}

				resultList = reflect.Append(resultList, reflect.ValueOf(v).Convert(el))
			}
			f.Set(resultList)
		}
	case reflect.Float32, reflect.Float64:
		{
			resultList := reflect.MakeSlice(ft, 0, len(values))
			for _, value := range values {
				v, err := strconv.ParseFloat(value, el.Bits())
				if err != nil {
					return newBadRequestf("%s is not float format", value)
				}

				resultList = reflect.Append(resultList, reflect.ValueOf(v).Convert(el))
			}
			f.Set(resultList)
		}
	case reflect.Bool:
		{
			resultList := make([]bool, 0, len(values))
			for _, value := range values {
				v, err := strconv.ParseBool(value)
				if err != nil {
					return newBadRequestf("%s is not bool format", value)
				}
				resultList = append(resultList, v)
			}
			f.Set(reflect.ValueOf(resultList))
		}
	default:
		return fmt.Errorf("unsupported format %s", el.Name())
	}

	return nil
}
227197
func init() {
	for k, v := range ChanModeToString {
		StringToChanMode[v] = k
	}
	for k, v := range ChanPrivToString {
		StringToChanPriv[v] = k
	}
	for k, v := range ChanPrivToModeChar {
		ModeCharToChanPriv[v] = k
	}
}
1164791
func Use(vv ...string) *Set {
	sort.Strings(vv)
	return &Set{items: vv}
}
363137
func (value *StringMapValue) Set(v string) error {
	dict := make(map[string]string)
	pairs := parseListWithEscapes(v, ',')
	for _, pair := range pairs {
		parts := strings.SplitN(pair, ":", 2)
		dict[parts[0]] = parts[1]
	}
	*value = dict
	return nil
}
316503
func (ns *Namespaces) Set(str string) error {
	fargs := func(c rune) bool {
		return c == ',' || c == ';'
	}
	// get function
	slice := strings.FieldsFunc(str, fargs)
	*ns = append(*ns, slice...)
	return nil
}
494834
func init() {
	noTraverseTypeList = map[reflect.Type]bool{}
	converterMap = map[reflect.Type]map[reflect.Type]Converter{}

	// Default NoTraverseTypeList
	// --------------------------
	// Auto No Traverse struct list for not traversing Deep Level
	// However, field value will be evaluated/processed by go-model library
	AddNoTraverseType(
		time.Time{},
		&time.Time{},
		os.File{},
		&os.File{},
		http.Request{},
		&http.Request{},
		http.Response{},
		&http.Response{},

		// it's better to add it to the list for appropriate type(s)
	)
}
1013779
func typeToString(typ reflect.Type) string {
	switch typ.Kind() {
	case reflect.Bool:
		return "xsd:boolean"
	case reflect.Int8:
		return "xsd:byte"
	case reflect.Int16:
		return "xsd:short"
	case reflect.Int32:
		return "xsd:int"
	case reflect.Int, reflect.Int64:
		return "xsd:long"
	case reflect.Uint8:
		return "xsd:unsignedByte"
	case reflect.Uint16:
		return "xsd:unsignedShort"
	case reflect.Uint32:
		return "xsd:unsignedInt"
	case reflect.Uint, reflect.Uint64:
		return "xsd:unsignedLong"
	case reflect.Float32:
		return "xsd:float"
	case reflect.Float64:
		return "xsd:double"
	case reflect.String:
		name := typ.Name()
		if name == "string" {
			return "xsd:string"
		}
		return name
	case reflect.Struct:
		if typ == stringToTypeMap["xsd:dateTime"] {
			return "xsd:dateTime"
		}

		// Expect any other struct to be handled...
		return typ.Name()
	case reflect.Slice:
		if typ.Elem().Kind() == reflect.Uint8 {
			return "xsd:base64Binary"
		}
	case reflect.Array:
		if typ.Elem().Kind() == reflect.Uint8 {
			return "xsd:base64Binary"
		}
	}

	panic("don't know what to do for type: " + typ.String())
}
1330266
func (s *Strings) Set(str string) error {
	for _, t := range strings.Split(str, ",") {
		*s = append(*s, t)
	}

	return nil
}
1278023
func (me *TxsdRunTypeSequenceSequenceDataBlockSequenceFilesSequenceFileQualityScoringSystem) Set(s string) {
	(*xsdt.String)(me).Set(s)
}
434797
func (mmap MarshalMap) Set(key string, val interface{}) {
	mmap.resolvePath(key, mmap, func(p, k reflect.Value, v interface{}) {
		p.SetMapIndex(k, reflect.ValueOf(val))
	})
}
394828
func StringOrBytes(value interface{}) (isString bool, str string, isBytes bool, bs []byte) {
	v := reflect.ValueOf(value)
	if v.Kind() == reflect.String {
		str = v.String()
		isString = true
	} else if v.Kind() == reflect.Slice && v.Type() == bytesType {
		bs = v.Interface().([]byte)
		isBytes = true
	}
	return
}
909934
func ValueToString(val Value) (string, bool) {
	if val == nil || val.Err() {
		return "", false
	}
	switch v := val.(type) {
	case StringValue:
		return v.Val(), true
	case TimeValue:
		return fmt.Sprintf("%v", v.Val()), true
	case ByteSliceValue:
		return string(v.Val()), true
	case NumericValue, BoolValue, IntValue:
		return val.ToString(), true
	case Slice:
		// This is controversial, if we are demanding a "ToString"
		// should we:
		// 1)  take first?
		// 2)  append comma separated?
		// 3)  error?
		//
		// Our answer is that we are demanding a scalar string
		// and going to take first.  calling function would have had to do type detection
		// if they wanted something else.
		if v.Len() == 0 {
			return "", false
		}
		v1 := v.SliceValue()[0]
		if v1 == nil {
			return "", false
		}
		return v1.ToString(), true
	}
	return "", false
}
147143
func StringKeySet(theMap interface{}) String {
	v := reflect.ValueOf(theMap)
	ret := String{}

	for _, keyValue := range v.MapKeys() {
		ret.Insert(keyValue.Interface().(string))
	}
	return ret
}
1129395
func (d *Datum) SetBytesAsString(b []byte) {
	d.k = KindString
	d.b = b
}
901326
func (m *MapStringString) Set(value string) error {
	if m.Map == nil {
		return fmt.Errorf("no target (nil pointer to map[string]string)")
	}
	if !m.initialized || *m.Map == nil {
		// clear default values, or allocate if no existing map
		*m.Map = make(map[string]string)
		m.initialized = true
	}

	// account for comma-separated key-value pairs in a single invocation
	if !m.NoSplit {
		for _, s := range strings.Split(value, ",") {
			if len(s) == 0 {
				continue
			}
			arr := strings.SplitN(s, "=", 2)
			if len(arr) != 2 {
				return fmt.Errorf("malformed pair, expect string=string")
			}
			k := strings.TrimSpace(arr[0])
			v := strings.TrimSpace(arr[1])
			(*m.Map)[k] = v
		}
		return nil
	}

	// account for only one key-value pair in a single invocation
	arr := strings.SplitN(value, "=", 2)
	if len(arr) != 2 {
		return fmt.Errorf("malformed pair, expect string=string")
	}
	k := strings.TrimSpace(arr[0])
	v := strings.TrimSpace(arr[1])
	(*m.Map)[k] = v
	return nil

}
110974
func EnsureString(value interface{}) (string, error) {
	v := reflect.ValueOf(value)
	if v.Kind() == reflect.String {
		return v.String(), nil
	}
	if v.Type() == bytesType {
		return string(v.Interface().([]byte)), nil
	}
	return "", errors.New("must be either a string or byte slice")
}