// parseFormatStyleSet provides a function to parse the format settings of the
// cells and conditional formats.
171626
func parseFormatStyleSet(style string) (*formatStyle, error) {
	format := formatStyle{
		DecimalPlaces: 2,
	}
	err := json.Unmarshal([]byte(style), &format)
	return &format, err
}
752954
func DataFormat(format, tmpl string) (DataFormatter, error) {
	switch format {
	case "json":
		if len(tmpl) > 0 {
			return nil, fmt.Errorf("json format does not support template option.")
		}
		return &JSONFormat{}, nil
	case "template":
		return &TemplateFormat{tmpl}, nil
	}
	return nil, fmt.Errorf("Unsupported format is specified.")
}
511437
func ElementsUsingStyle(e Markup, f, val string) []Markup {
	return DeepElementsUsingStyle(e, f, val, 1)
}
82728
func FSTypeSimpleValueOf(s string) (FSType, error) {
	obj, err := simpleValueOf("fs_type", FSType_value, s)
	return FSType(obj), err
}
1360355
func parseMetadata(ctx context.Context, path, scheme string) (string, string, string, error) {
	rc, err := fetchMetadata(ctx, path, scheme)
	if err != nil {
		return "", "", "", err
	}
	defer rc.Close()

	imports, err := parseMetaGoImports(rc)
	if err != nil {
		return "", "", "", err
	}
	match := -1
	for i, im := range imports {
		if !strings.HasPrefix(path, im.Prefix) {
			continue
		}
		if match != -1 {
			return "", "", "", fmt.Errorf("multiple meta tags match import path %q", path)
		}
		match = i
	}
	if match == -1 {
		return "", "", "", fmt.Errorf("go-import metadata not found")
	}
	return imports[match].Prefix, imports[match].VCS, imports[match].RepoRoot, nil
}
605227
func Parse(csstext string) *CSSStyleSheet {
	context := &parserContext{
		State:             STATE_NONE,
		NowSelectorText:   "",
		NowRuleType:       STYLE_RULE,
		CurrentNestedRule: nil,
	}

	css := &CSSStyleSheet{}
	css.CssRuleList = make([]*CSSRule, 0)
	s := scanner.New(csstext)

	for {
		token := s.Next()

		if token.Type == scanner.TokenEOF || token.Type == scanner.TokenError {
			break
		}

		switch token.Type {
		case scanner.TokenCDO:
			break
		case scanner.TokenCDC:
			break
		case scanner.TokenComment:
			break
		case scanner.TokenS:
			break
		case scanner.TokenAtKeyword:
			switch token.Value {
			case "@media":
				context.NowRuleType = MEDIA_RULE
			case "@font-face":
				// Parse as normal rule, would be nice to parse according to syntax
				// https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face
				context.NowRuleType = FONT_FACE_RULE
				parseRule(context, s, css)
				resetContextStyleRule(context)
			case "@import":
				// No validation
				// https://developer.mozilla.org/en-US/docs/Web/CSS/@import
				rule := parseImport(s)
				if rule != nil {
					css.CssRuleList = append(css.CssRuleList, rule)
				}
				resetContextStyleRule(context)
			case "@charset":
				// No validation
				// https://developer.mozilla.org/en-US/docs/Web/CSS/@charset
				rule := parseCharset(s)
				if rule != nil {
					css.CssRuleList = append(css.CssRuleList, rule)
				}
				resetContextStyleRule(context)

			case "@page":
				context.NowRuleType = PAGE_RULE
				parseRule(context, s, css)
				resetContextStyleRule(context)
			case "@keyframes":
				context.NowRuleType = KEYFRAMES_RULE
			case "@-webkit-keyframes":
				context.NowRuleType = WEBKIT_KEYFRAMES_RULE
			case "@counter-style":
				context.NowRuleType = COUNTER_STYLE_RULE
				parseRule(context, s, css)
				resetContextStyleRule(context)
			default:
				log.Println(fmt.Printf("Skip unsupported atrule: %s", token.Value))
				skipRules(s)
				resetContextStyleRule(context)
			}
		default:
			if context.State == STATE_NONE {
				if token.Value == "}" && context.CurrentNestedRule != nil {
					// close media rule
					css.CssRuleList = append(css.CssRuleList, context.CurrentNestedRule)
					context.CurrentNestedRule = nil
					break
				}
			}

			if context.NowRuleType == MEDIA_RULE || context.NowRuleType == KEYFRAMES_RULE || context.NowRuleType == WEBKIT_KEYFRAMES_RULE {
				context.CurrentNestedRule = NewRule(context.NowRuleType)
				context.CurrentNestedRule.Style.SelectorText = strings.TrimSpace(token.Value + parseSelector(s))
				resetContextStyleRule(context)
				break
			} else {
				context.NowSelectorText += token.Value
				parseRule(context, s, css)
				resetContextStyleRule(context)
				break
			}
		}
	}
	return css
}
853356
func (k *Key) parseTimesFormat(format string, strs []string, addInvalid, returnOnInvalid bool) ([]time.Time, error) {
	vals := make([]time.Time, 0, len(strs))
	for _, str := range strs {
		val, err := time.Parse(format, str)
		if err != nil && returnOnInvalid {
			return nil, err
		}
		if err == nil || addInvalid {
			vals = append(vals, val)
		}
	}
	return vals, nil
}
869605
func formatMetaGetFormatBackendXL(formatPath string) (string, error) {
	meta := &formatMetaV1{}
	b, err := ioutil.ReadFile(formatPath)
	if err != nil {
		return "", err
	}
	if err = json.Unmarshal(b, meta); err != nil {
		return "", err
	}
	if meta.Version != formatMetaVersionV1 {
		return "", fmt.Errorf(`format.Version expected: %s, got: %s`, formatMetaVersionV1, meta.Version)
	}
	return meta.Format, nil
}
377937
func ParseFromString(content, env string, subs map[string]string) (SecretsMap, error) {
	return parse(content, env, subs)
}
158134
func parseTabletType(param string, types []topodatapb.TabletType) (topodatapb.TabletType, error) {
	tabletType, err := topoproto.ParseTabletType(param)
	if err != nil {
		return topodatapb.TabletType_UNKNOWN, fmt.Errorf("invalid tablet type %v: %v", param, err)
	}
	if !topoproto.IsTypeInList(topodatapb.TabletType(tabletType), types) {
		return topodatapb.TabletType_UNKNOWN, fmt.Errorf("type %v is not one of: %v", tabletType, strings.Join(topoproto.MakeStringTypeList(types), " "))
	}
	return tabletType, nil
}
370243
func parseFormatPanesSet(formatSet string) (*formatPanes, error) {
	format := formatPanes{}
	err := json.Unmarshal([]byte(formatSet), &format)
	return &format, err
}
392487
func (f *File) stylesReader() *xlsxStyleSheet {
	if f.Styles == nil {
		var styleSheet xlsxStyleSheet
		_ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML("xl/styles.xml")), &styleSheet)
		f.Styles = &styleSheet
	}
	return f.Styles
}
1157083
func (c *Ctx) ParseForm() error {

	if c.formParsed {
		return nil
	}

	if err := c.request.ParseForm(); err != nil {
		return err
	}

	for _, entry := range c.params {
		c.request.Form.Add(entry.Key, entry.Value)
	}

	c.formParsed = true

	return nil
}
1118400
func (fp *formatParser) addFormatFunc(
	f func(*LineData, *bytes.Buffer) error, size int,
) {
	fp.commitStatic()
	fp.formatFuncs = append(fp.formatFuncs, f)
	fp.initialSize += size
}
539870
func (p *parser) parseFieldValue(s string, msgName string, field *descriptor.FieldDescriptorProto) (interface{}, error) {
	switch field.GetType() {

	case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
		return strconv.ParseFloat(s, 64)

	case descriptor.FieldDescriptorProto_TYPE_FLOAT:
		x, err := strconv.ParseFloat(s, 32)
		return float32(x), err

	case
		descriptor.FieldDescriptorProto_TYPE_INT32,
		descriptor.FieldDescriptorProto_TYPE_SFIXED32,
		descriptor.FieldDescriptorProto_TYPE_SINT32:

		x, err := strconv.ParseInt(s, 10, 32)
		return int32(x), err

	case descriptor.FieldDescriptorProto_TYPE_INT64,
		descriptor.FieldDescriptorProto_TYPE_SFIXED64,
		descriptor.FieldDescriptorProto_TYPE_SINT64:

		return strconv.ParseInt(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_UINT32, descriptor.FieldDescriptorProto_TYPE_FIXED32:
		x, err := strconv.ParseUint(s, 10, 32)
		return uint32(x), err

	case descriptor.FieldDescriptorProto_TYPE_UINT64, descriptor.FieldDescriptorProto_TYPE_FIXED64:
		return strconv.ParseUint(s, 10, 64)

	case descriptor.FieldDescriptorProto_TYPE_BOOL:
		return strconv.ParseBool(s)

	case descriptor.FieldDescriptorProto_TYPE_STRING:
		return s, nil

	case descriptor.FieldDescriptorProto_TYPE_MESSAGE:
		return nil, fmt.Errorf(
			"%s.%s is a message field. Specify its field values, not the message itself",
			msgName, field.GetName())

	case descriptor.FieldDescriptorProto_TYPE_BYTES:
		return hex.DecodeString(s)

	case descriptor.FieldDescriptorProto_TYPE_ENUM:
		obj, err := p.resolve(field.GetTypeName())
		if err != nil {
			return nil, err
		}
		enum, ok := obj.(*descriptor.EnumDescriptorProto)
		if !ok {
			return nil, fmt.Errorf(
				"field %s.%s is declared as of type enum %s, but %s is not an enum",
				msgName, field.GetName(),
				field.GetTypeName(), field.GetTypeName(),
			)
		}
		return parseEnum(enum, s)

	default:
		return nil, fmt.Errorf("field type %s is not supported", field.GetType())
	}
}
1357952
func ParseForm(raw url.Values) Form {
	result := make(Form, len(raw))

	for k, v := range raw {
		if len(v) == 0 {
			continue
		}

		fields := strings.FieldsFunc(k, fieldsExtractor)

		pfield, cfield := "", ""
		form := result
		for i := range fields {
			pfield = cfield
			cfield = fields[i]

			if index, err := strconv.Atoi(cfield); err == nil {
				if i == len(fields)-1 {
					form.assigns(pfield, "", index, v[0])
				} else {
					form.assigns(pfield, "", index, nil)
					form = form[pfield][index].(Form)
					cfield = "" // set cfield empty, so unnecesary nesting wont be created in the next loop
				}
			} else {
				if i == len(fields)-1 {
					form.assigns(pfield, cfield, -1, v)
				} else {
					form.assigns(pfield, cfield, -1, nil)
					if pfield != "" {
						index := len(form[pfield]) - 1
						form = form[pfield][index].(Form)
					}
				}
			}
		}
	}

	return result
}
976143
func ParseForm(r *http.Request) error {

	if err := r.ParseForm(); err != nil {
		return err
	}

	if rvi := r.Context().Value(defaultContextIdentifier); rvi != nil {

		rv := rvi.(*requestVars)

		if !rv.formParsed {
			for _, p := range rv.params {
				r.Form.Add(p.key, p.value)
			}

			rv.formParsed = true
		}
	}

	return nil
}