// nocode returns true if the provided Section contains
// no Code elements with Play enabled.
326770
func nocode(s present.Section) bool {
	for _, e := range s.Elem {
		if c, ok := e.(present.Code); ok && c.Play {
			return false
		}
	}
	return true
}
334638
func (s *CreateFunctionInput) SetCode(v *FunctionCode) *CreateFunctionInput {
	s.Code = v
	return s
}
694890
func (s *Error) SetCode(v string) *Error {
	s.Code = &v
	return s
}
503376
func Encode(content string, includeChecksum bool, fullASCIIMode bool) (barcode.Barcode, error) {
	if fullASCIIMode {
		var err error
		content, err = prepare(content)
		if err != nil {
			return nil, err
		}
	} else if strings.ContainsRune(content, '*') {
		return nil, errors.New("invalid data! content may not contain '*'")
	}

	data := content + string(getChecksum(content, 20))
	data += string(getChecksum(data, 15))

	data = "*" + data + "*"
	result := new(utils.BitList)

	for _, r := range data {
		info, ok := encodeTable[r]
		if !ok {
			return nil, errors.New("invalid data!")
		}
		result.AddBits(info.data, 9)
	}
	result.AddBit(true)

	return utils.New1DCode(barcode.TypeCode93, content, result), nil
}
885025
func (s *MessageData) SetCode(v string) *MessageData {
	s.Code = &v
	return s
}
611380
func statusCode(e kerrors.Error) int {
	if e.Code > 0 {
		return e.Code
	}
	switch e.Reference {
	case kerrors.InternalError:
		return http.StatusInternalServerError
	case kerrors.InvalidData:
		return http.StatusUnprocessableEntity
	case kerrors.MalformedData:
		return http.StatusBadRequest
	case kerrors.Forbidden:
		return http.StatusForbidden
	case kerrors.NotFound:
		return http.StatusNotFound
	default:
		return http.StatusInternalServerError
	}
}
298190
func (c *ConfigFile) DeleteKey(section, key string) bool {
	// Blank section name represents DEFAULT section.
	if len(section) == 0 {
		section = DEFAULT_SECTION
	}

	// Check if section exists.
	if _, ok := c.data[section]; !ok {
		return false
	}

	// Check if key exists.
	if _, ok := c.data[section][key]; ok {
		delete(c.data[section], key)
		// Remove comments of key.
		c.SetKeyComments(section, key, "")
		// Get index of key.
		i := 0
		for _, keyName := range c.keyList[section] {
			if keyName == key {
				break
			}
			i++
		}
		// Remove from key list.
		c.keyList[section] = append(c.keyList[section][:i], c.keyList[section][i+1:]...)
		return true
	}
	return false
}
356958
func (f File) Section(name string) Section {
	section := f[name]
	if section == nil {
		section = make(Section)
		f[name] = section
	}
	return section
}
238644
func (c *Constant) HashCode() []byte {
	var bytes []byte
	bytes, _ = codec.EncodeValue(bytes, c.Value)
	return bytes
}
1333526
func (fp *formatParser) staticCode(i int, r rune) error {
	data := []byte(fp.format[fp.start:i])
	fp.addStatic(data)
	fp.start = i
	fp.code = (*formatParser).codeCode
	fp.next = (*formatParser).codeNext
	fp.end = (*formatParser).codeEnd
	return nil
}
323908
func Encode(text string, level Level) (*Code, error) {
	// Pick data encoding, smallest first.
	// We could split the string and use different encodings
	// but that seems like overkill for now.
	var enc coding.Encoding
	switch {
	case coding.Num(text).Check() == nil:
		enc = coding.Num(text)
	case coding.Alpha(text).Check() == nil:
		enc = coding.Alpha(text)
	default:
		enc = coding.String(text)
	}

	// Pick size.
	l := coding.Level(level)
	var v coding.Version
	for v = coding.MinVersion; ; v++ {
		if v > coding.MaxVersion {
			return nil, errors.New("text too long to encode as QR")
		}
		if enc.Bits(v) <= v.DataBytes(l)*8 {
			break
		}
	}

	// Build and execute plan.
	p, err := coding.NewPlan(v, l, 0)
	if err != nil {
		return nil, err
	}
	cc, err := p.Encode(enc)
	if err != nil {
		return nil, err
	}

	// TODO: Pick appropriate mask.

	return &Code{cc.Bitmap, cc.Size, cc.Stride, 8}, nil
}
909884
func Encode(content string) (barcode.Barcode, error) {
	checkValid, _ := regexp.Compile(`[ABCD][0123456789\-\$\:/\.\+]*[ABCD]$`)
	if content == "!" || checkValid.ReplaceAllString(content, "!") != "!" {
		return nil, fmt.Errorf("can not encode \"%s\"", content)
	}
	resBits := new(utils.BitList)
	for i, r := range content {
		if i > 0 {
			resBits.AddBit(false)
		}
		resBits.AddBit(encodingTable[r]...)
	}
	return utils.New1DCode(barcode.TypeCodabar, content, resBits), nil
}
1257393
func (s *Shape) GoCode() string {
	w := &bytes.Buffer{}

	switch {
	case s.EventStreamAPI != nil:
		if err := renderEventStreamAPIShape(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"failed to generate eventstream API shape, %s, %v",
					s.ShapeName, err),
			)
		}
	case s.Type == "structure":
		if err := structShapeTmpl.Execute(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"Failed to generate struct shape %s, %v",
					s.ShapeName, err),
			)
		}
	case s.IsEnum():
		if err := enumShapeTmpl.Execute(w, s); err != nil {
			panic(
				fmt.Sprintf(
					"Failed to generate enum shape %s, %v",
					s.ShapeName, err),
			)
		}
	default:
		panic(fmt.Sprintln("Cannot generate toplevel shape for", s.Type))
	}

	return w.String()
}
113958
func (c *Config) Section(name string) *Section {
	for i := len(c.Sections) - 1; i >= 0; i-- {
		s := c.Sections[i]
		if s.IsName(name) {
			return s
		}
	}

	s := &Section{Name: name}
	c.Sections = append(c.Sections, s)
	return s
}
1014716
func (s *StepStateChangeReason) SetCode(v string) *StepStateChangeReason {
	s.Code = &v
	return s
}
425268
func (e *Error) StatusCode() int {
	code, ok := errorTypeToStatusCodeMap[e.Type]
	if !ok || code == 0 {
		return 500
	}

	return code
}
747184
func isValidRegionCode(regionCode string) bool {
	_, contains := readFromSupportedRegions(regionCode)
	return len(regionCode) != 0 && contains
}