// stateE is the state after reading the mantissa and e in a number,
// such as after reading `314e` or `0.314e`.
333137
func stateE(s *Scanner, c int) int {
	if c == '+' {
		s.Step = stateESign
		return ScanContinue
	}
	if c == '-' {
		s.Step = stateESign
		return ScanContinue
	}
	return stateESign(s, c)
}
573912
func State(typeOfState int) string {
	if typeOfState == Small {
		return randomFrom(jsonData.StatesSmall)
	}
	return randomFrom(jsonData.States)
}
1123844
func processState(stateDriver core.StateDriver, stateName, stateID, fieldName, setVal string) error {
	var typeRegistry = make(map[string]core.State)

	// build the type registry
	typeRegistry[reflect.TypeOf(mastercfg.CfgEndpointState{}).Name()] = &mastercfg.CfgEndpointState{}
	typeRegistry[reflect.TypeOf(mastercfg.CfgNetworkState{}).Name()] = &mastercfg.CfgNetworkState{}
	typeRegistry[reflect.TypeOf(mastercfg.CfgBgpState{}).Name()] = &mastercfg.CfgBgpState{}
	typeRegistry[reflect.TypeOf(mastercfg.EndpointGroupState{}).Name()] = &mastercfg.EndpointGroupState{}
	typeRegistry[reflect.TypeOf(mastercfg.GlobConfig{}).Name()] = &mastercfg.GlobConfig{}
	typeRegistry[reflect.TypeOf(mastercfg.EpgPolicy{}).Name()] = &mastercfg.EpgPolicy{}
	typeRegistry[reflect.TypeOf(mastercfg.SvcProvider{}).Name()] = &mastercfg.SvcProvider{}
	typeRegistry[reflect.TypeOf(mastercfg.CfgServiceLBState{}).Name()] = &mastercfg.CfgServiceLBState{}
	typeRegistry[reflect.TypeOf(resources.AutoVLANCfgResource{}).Name()] = &resources.AutoVLANCfgResource{}
	typeRegistry[reflect.TypeOf(resources.AutoVLANOperResource{}).Name()] = &resources.AutoVLANOperResource{}
	typeRegistry[reflect.TypeOf(resources.AutoVXLANCfgResource{}).Name()] = &resources.AutoVXLANCfgResource{}
	typeRegistry[reflect.TypeOf(resources.AutoVXLANOperResource{}).Name()] = &resources.AutoVXLANOperResource{}
	typeRegistry[reflect.TypeOf(drivers.OvsDriverOperState{}).Name()] = &drivers.OvsDriverOperState{}
	typeRegistry[reflect.TypeOf(drivers.OperEndpointState{}).Name()] = &drivers.OperEndpointState{}
	typeRegistry[reflect.TypeOf(docknet.DnetOperState{}).Name()] = &docknet.DnetOperState{}

	// find the type by name
	cfgType := typeRegistry[stateName]

	// Some reflect magic to set the state driver
	s := reflect.ValueOf(cfgType).Elem()
	if s.Kind() == reflect.Struct {
		f := s.FieldByName("StateDriver")
		if f.IsValid() && f.CanSet() {
			if f.Kind() == reflect.Interface {
				f.Set(reflect.ValueOf(stateDriver))
				log.Debugf("Set: %+v", reflect.ValueOf(cfgType).Elem().FieldByName("StateDriver"))
			} else {
				log.Errorf("Invalid kind")
				return fmt.Errorf("can not set state driver")
			}
		} else {
			log.Errorf("Could not find the field.")
			return fmt.Errorf("can not set state driver")
		}
	} else {
		log.Errorf("Invalid type: %v", s.Kind())
		return fmt.Errorf("can not set state driver")
	}

	// read the object
	log.Debugf("cfgType: %+v", cfgType)
	err := cfgType.Read(stateID)
	if err != nil {
		log.Errorf("Error reading state %s{id: %s}. Err: %v", stateName, stateID, err)
		return err
	}

	// print the object
	content, err := json.MarshalIndent(cfgType, "", "  ")
	if err != nil {
		log.Errorf("Error marshaling json: %+v", cfgType)
		return err
	}
	fmt.Printf("Current value of id: %s{ id: %s }\n%s\n", stateName, stateID, content)

	// See if we need to set a field
	if fieldName != "" && setVal != "" {
		// more reflect magic to set a field
		s := reflect.ValueOf(cfgType).Elem()
		if s.Kind() == reflect.Struct {
			f := s.FieldByName(fieldName)
			if f.IsValid() && f.CanSet() {
				switch f.Kind() {
				case reflect.String:
					f.SetString(setVal)
				case reflect.Int:
					intVal, err := strconv.ParseInt(setVal, 10, 0)
					if err != nil {
						log.Errorf("Can not convert %s to int. Err: %v", setVal, err)
						return err
					}
					f.SetInt(intVal)
				case reflect.Uint:
					intVal, err := strconv.ParseUint(setVal, 10, 0)
					if err != nil {
						log.Errorf("Can not convert %s to uint. Err: %v", setVal, err)
						return err
					}
					f.SetUint(intVal)
				case reflect.Bool:
					boolVal, err := strconv.ParseBool(setVal)
					if err != nil {
						log.Errorf("Can not convert %s to bool. Err: %v", setVal, err)
						return err
					}
					f.SetBool(boolVal)
				default:
					log.Errorf("Invalid kind")
					return fmt.Errorf("invalid kind")
				}
			} else {
				log.Errorf("Could not find the field. or its not setable")
				return fmt.Errorf("could not find the field. or its not setable")
			}
		} else {
			log.Errorf("Invalid type: %v", s.Kind())
		}

		// print the modified object
		content, err := json.MarshalIndent(cfgType, "", "  ")
		if err != nil {
			log.Errorf("Error marshaling json: %+v", cfgType)
			return err
		}
		fmt.Printf("Writing values:\n%s\n", content)

		// write it
		err = cfgType.Write()
		if err != nil {
			log.Errorf("Error writing %s{ id: %s }. Err: %v", stateName, stateID, err)
			return err
		}
	}

	return nil
}
340295
func StateGet(pdf *Fpdf) (st StateType) {
	st.clrDraw.R, st.clrDraw.G, st.clrDraw.B = pdf.GetDrawColor()
	st.clrFill.R, st.clrFill.G, st.clrFill.B = pdf.GetFillColor()
	st.clrText.R, st.clrText.G, st.clrText.B = pdf.GetTextColor()
	st.lineWd = pdf.GetLineWidth()
	_, st.fontSize = pdf.GetFontSize()
	st.alpha, st.blendStr = pdf.GetAlpha()
	st.cellMargin = pdf.GetCellMargin()
	return
}
136787
func stateGreater(a, b state) bool {
	switch a {
	case stateIncreaseRate:
		return false
	case stateDecreaseAndGuessRate:
		return b == stateIncreaseRate
	case stateEmergency:
		return b == stateIncreaseRate || b == stateDecreaseAndGuessRate
	default:
		panic(fmt.Sprintf("BUG: cannot compare states: %v and %v", a, b))
	}
}
1265049
func (d *decoder) state() json.Delim {
	if len(d.parseState) == 0 {
		return 0
	}
	return d.parseState[len(d.parseState)-1]
}
796735
func (b ValExprBuilder) Gte(val interface{}) BoolExprBuilder {
	return b.makeComparisonExpr(astGE, makeValExpr(val))
}
1278431
func (f Float32) OrElse(v float32) float32 {
	if f.Present() {
		return *f.value
	}
	return v
}
888991
func (d *digest) State() ([]byte, error) {
	var buf bytes.Buffer
	encoder := gob.NewEncoder(&buf)

	// We encode this way so that we do not have
	// to export these fields of the digest struct.
	vals := []interface{}{
		d.h, d.x, d.nx, d.len, d.is224,
	}

	for _, val := range vals {
		if err := encoder.Encode(val); err != nil {
			return nil, err
		}
	}

	return buf.Bytes(), nil
}
1334083
func state0(s *scanner, c int) int {
	if c == '.' {
		s.step = stateDot
		return scanContinue
	}
	if c == 'e' || c == 'E' {
		s.step = stateE
		return scanContinue
	}
	return stateEndValue(s, c)
}
493284
func (s *server) State() string {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	return s.state
}
971759
func (d *JsonNullDetector) nextState(b byte) int {
	switch d.state {
	case stateInit:
		if isJsonSpace(b) {
			return stateInit
		}
		if b == 'n' {
			return stateN
		}
	case stateN:
		if b == 'u' {
			return stateU
		}
	case stateU:
		if b == 'l' {
			return stateL
		}
	case stateL:
		if b == 'l' {
			return stateAccept
		}
	case stateAccept:
		if isJsonSpace(b) {
			return stateAccept
		}
	}
	return stateInvalid
}
997683
func stateRightDelim(l *lexer) stateFn {
	l.seek(len(l.rightDelim))
	l.emit(tokenRightDelim)
	return stateText
}
332511
func (a *MobileAppState) State() keybase1.MobileAppState {
	a.Lock()
	defer a.Unlock()
	return a.state
}
642954
func (s String) OrElse(v string) string {
	if s.Present() {
		return *s.value
	}
	return v
}
486274
func (b Byte) OrElse(v byte) byte {
	if b.Present() {
		return *b.value
	}
	return v
}
1001760
func stateInStringEscU(s *scanner, c byte) int {
	if '0' <= c && c <= '9' || 'a' <= c && c <= 'f' || 'A' <= c && c <= 'F' {
		s.step = stateInStringEscU1
		return scanContinue
	}
	// numbers
	return s.error(c, "in \\u hexadecimal character escape")
}