// ParseStringValue is used to parse a user provided flag argument.
336075
func (n *NullBool) ParseStringValue(val string) error {
	if val == "" {
		return nil
	}

	boolVal, err := strconv.ParseBool(val)
	if err != nil {
		return err
	}

	n.Value = boolVal
	n.IsSet = true

	return nil
}
1034586
func (c *Config) ValueString(name string) (string, bool) {
	v, ok := c.attrs[name].(string)
	return v, ok
}
1176188
func StringValue(item interface{}) (value string, ok bool) {
	value, ok = item.(string)
	if ok {
		return value, ok
	}
	intValue, ok := item.(int)
	if ok {
		return strconv.Itoa(intValue), true
	}
	return "", false
}
1308674
func stringValue(v reflect.Value) string {
	if v.CanInterface() {
		return fmt.Sprintf("%#v", v.Interface())
	} else {
		return v.String()
	}
}
534014
func (p *Parser) parseExactValue() (string, error) {
	tok, lit := p.consume()
	if tok != IdentifierToken && tok != EndOfStringToken {
		return "", fmt.Errorf("found '%s', expected: identifier", lit)
	}
	if err := validateLabelValue(lit); err != nil {
		return "", err
	}
	return lit, nil
}
1088134
func GetStringMapValue(mapVal, keyVal interface{}) (interface{}, error) {
	key, ok := keyVal.(string)
	if !ok {
		return nil, trace.BadParameter("only string keys are supported")
	}
	switch m := mapVal.(type) {
	case map[string][]string:
		if len(m) == 0 {
			// to return nil with a proper type
			var n []string
			return n, nil
		}
		return m[key], nil
	case Traits:
		if len(m) == 0 {
			// to return nil with a proper type
			var n []string
			return n, nil
		}
		return m[key], nil
	case map[string]string:
		if len(m) == 0 {
			return "", nil
		}
		return m[key], nil
	default:
		_, ok := mapVal.(map[string][]string)
		return nil, trace.BadParameter("type %T is not supported, but %v %#v", m, ok, mapVal)
	}
}
1257294
func (app *App) GetStringFlag(name string) (string, bool) {
	if !flag.Parsed() && !flagsDisabled {
		flag.Parse()
	}
	if app.Flags.values != nil {
		if bindFlag, ok := app.Flags.values[name]; ok {
			return *bindFlag.Value, ok
		}
	}

	return "", false
}
714093
func (p *Parser) parseString() (string, error) {
	tok, pos, lit := p.ScanIgnoreWhitespace()
	if tok != STRING {
		return "", newParseError(tokstr(tok, lit), []string{"string"}, pos)
	}
	return lit, nil
}
1297782
func (p *Parser) ParseString(s string, v interface{}) error {
	return p.Parse(strings.NewReader(s), v)
}
1190732
func parseString(s string) (string, string, error) {

	if s[0] != '\'' && s[0] != '"' {
		panic("string should start with open quote. calling code should have asserted this")
	}

	match := s[0]

	s = s[1:]

	var i int
	for i < len(s) && s[i] != match {
		i++
	}

	if i == len(s) {
		return "", "", ErrMissingQuote

	}

	return s[:i], s[i+1:], nil
}
1284553
func parseResourceValueArg(raw string) (name string, value string, _ error) {
	vals := strings.SplitN(raw, "=", 2)
	if len(vals) < 2 {
		msg := fmt.Sprintf("expected name=path format")
		return "", "", errors.NewNotValid(nil, msg)
	}

	name, value = vals[0], vals[1]
	if name == "" {
		return "", "", errors.NewNotValid(nil, "missing resource name")
	}
	if value == "" {
		return "", "", errors.NewNotValid(nil, "missing resource value")
	}
	return name, value, nil
}
1105901
func (s *Value) SetStringValue(v string) *Value {
	s.StringValue = &v
	return s
}
1339402
func ParseStringParam(paramString string, info SearchParamInfo) *StringParam {
	return &StringParam{info, unescape(paramString)}
}
1130690
func ParseString(s string) (key, value string, err error) {
	s = strings.TrimSpace(s)
	if strings.HasPrefix(s, "#") {
		err = ErrCommentln
		return
	}
	if s == "" {
		err = ErrEmptyln
		return
	}
	if !strings.Contains(s, "=") {
		err = ErrInvalidln
		return
	}

	var (
		buf            bytes.Buffer
		quoteType      rune
		hasEq, inQuo   bool
		mapPos, escPos int = posKey, -1
	)

	for i, r := range s {
		if inQuo {
			if i == escPos {
				switch r {
				case 'n':
					buf.WriteString("\n")
				case 'r':
					buf.WriteString("\r")
				default:
					buf.WriteRune(r)
				}
				continue
			}
			// Mark escapes
			if r == '\\' {
				escPos = i + 1
				continue
			}
		}
		// Check for quote delimiters
		if r == '\'' || r == '"' {
			// Look for closing delimiter
			if inQuo && r == quoteType {
				inQuo = false
				// Don't parse beyond a value's terminating quote
				if mapPos == posVal {
					break
				}
				continue
			}
			// Mark quote as delimiter if at start of key/val
			if !inQuo && buf.Len() == 0 {
				quoteType = r
				inQuo = true
				continue
			}
		}
		// If we're inside quotes and not being escaped,
		// ignore certain tokens.
		if !inQuo {
			// Whitespace is ignored outside quoted content
			if unicode.IsSpace(r) {
				continue
			}
			// Hash indicates a comment segment. Cease parsing.
			if r == '#' {
				break
			}
			// If we are parsing the key, '=' indicates the key is written to buffer.
			// Save the key string, and inc pos to value parsing.
			if mapPos == posKey && r == '=' {
				key = buf.String()
				buf.Reset()
				hasEq = true
				mapPos++
				continue
			}
		}
		buf.WriteRune(r)
	}
	// If we've never encountered a '=', the line is invalid. (probably quoted incorrectly)
	if !hasEq {
		err = ErrInvalidln
		return
	}
	value = buf.String()
	// While unlikely, an unquoted value may begin with a literal quote.
	// This would trigger our escape sequence for the char, but never close the quo delimiter.
	// Prepend the quote we marked to compensate for this.
	if inQuo {
		value = string(quoteType) + value
	}
	return
}
697370
func NewStringValue(t int64, v string) Value {
	return StringValue{unixnano: t, value: v}
}
797841
func (schema *Schema) stringOrStringArrayValue(v interface{}) *StringOrStringArray {
	switch v := v.(type) {
	default:
		fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v)
	case []string:
		s := &StringOrStringArray{}
		s.StringArray = &v
		return s
	case string:
		s := &StringOrStringArray{}
		s.String = &v
		return s
	case []interface{}:
		a := make([]string, 0)
		for _, v2 := range v {
			switch v2 := v2.(type) {
			default:
				fmt.Printf("arrayOfStringsValue: unexpected type %T\n", v2)
			case string:
				a = append(a, v2)
			}
		}
		s := &StringOrStringArray{}
		s.StringArray = &a
		return s
	}
	return nil
}
716657
func (v Value) StringValue() string {
	switch v.Type {
	case StringType:
		return strings.TrimFunc(string(v.raw), isTrimmable)
	case QuotedStringType:
		// preserve all characters in the quotes
		return string(removeEscapedCharacters(v.raw[1 : len(v.raw)-1]))
	default:
		return strings.TrimFunc(string(v.raw), isTrimmable)
	}
}