// ConvertAreas converts between internal and external REST representation
488138
func ConvertAreas(db application.DB, request *http.Request, areas []area.Area, additional ...AreaConvertFunc) []*app.Area {
	var is = []*app.Area{}
	for _, i := range areas {
		is = append(is, ConvertArea(db, request, i, additional...))
	}
	return is
}
593190
func Convert(h string) string {
	rh := []rune(h)

	for i, c := range rh {
		h, ok := table[c]
		if ok {
			rh[i] = h
		}
	}

	return string(rh)
}
338366
func convertPayload(payload interface{}, onlyFields []string) (body []byte, err error) {
	if payload != nil {
		switch t := payload.(type) {
		case string:
			body = []byte(t)
		case []byte:
			body = t
		default:
			v := reflect.Indirect(reflect.ValueOf(payload))
			if v.Kind() == reflect.Ptr {
				return convertPayload(v.Interface(), onlyFields)
			} else if v.Kind() == reflect.Struct {
				body, err = json.Marshal(buildMap(v, onlyFields))
				if err != nil {
					return body, err
				}
			}
		}
		if DebugLevel == LevelDebugFull {
			log.Println("Body:", string(body))
		}
	}
	return body, err
}
1350874
func (surface *Surface) ConvertFormat(pixelFormat uint32, flags uint32) (*Surface, error) {
	_surface := (*Surface)(unsafe.Pointer(C.SDL_ConvertSurfaceFormat(surface.cptr(), C.Uint32(pixelFormat), C.Uint32(flags))))
	if _surface == nil {
		return nil, GetError()
	}
	return _surface, nil
}
322233
func (orig *InnerJSON) Convert() (*Inner, error) {
	ret := &Inner{}

	b := NewInnerJSONBuilder().AddAll()
	for _, info := range b._properties {
		if err := info.Decoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
646694
func (g *Polygon) Area() float64 {
	return doubleArea2(g.flatCoords, 0, g.ends, g.stride) / 2
}
937730
func convertToUserResources(request *goa.RequestData, resourceType string, resourceIDs []string) *app.UserResourcesList {
	data := make([]*app.UserResourceData, 0)
	for _, resourceID := range resourceIDs {
		resourceHref := rest.AbsoluteURL(request, app.ResourceHref(resourceID), nil)
		data = append(data, &app.UserResourceData{
			ID:   resourceID,
			Type: "resources",
			Links: &app.GenericLinks{
				Related: &resourceHref,
			},
		})
	}
	return &app.UserResourcesList{
		Data: data,
	}
}
1184402
func ConvertPages(r io.Reader) (string, map[string]string, error) {
	meta := make(map[string]string)
	var textBody string

	b, err := ioutil.ReadAll(r)
	if err != nil {
		return "", nil, fmt.Errorf("error reading data: %v", err)
	}

	zr, err := zip.NewReader(bytes.NewReader(b), int64(len(b)))
	if err != nil {
		return "", nil, fmt.Errorf("error unzipping data: %v", err)
	}

	for _, f := range zr.File {
		if strings.HasSuffix(f.Name, "Preview.pdf") {
			// There is a preview PDF version we can use
			if rc, err := f.Open(); err == nil {
				return ConvertPDF(rc)
			}
		}
		if f.Name == "index.xml" {
			// There's an XML version we can use
			if rc, err := f.Open(); err == nil {
				return ConvertXML(rc)
			}
		}
		if f.Name == "Index/Document.iwa" {
			rc, _ := f.Open()
			defer rc.Close()
			bReader := bufio.NewReader(snappy.NewReader(io.MultiReader(strings.NewReader("\xff\x06\x00\x00sNaPpY"), rc)))
			archiveLength, err := binary.ReadVarint(bReader)
			archiveInfoData, err := ioutil.ReadAll(io.LimitReader(bReader, archiveLength))
			archiveInfo := &TSP.ArchiveInfo{}
			err = proto.Unmarshal(archiveInfoData, archiveInfo)
			fmt.Println("archiveInfo:", archiveInfo, err)
		}
	}

	return textBody, meta, nil
}
797077
func (orig *HogeJSON) Convert() (*Hoge, error) {
	ret := &Hoge{}

	b := NewHogeJSONBuilder().AddAll()
	for _, info := range b._properties {
		if err := info.Decoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
1313813
func convertMap(m map[string]string) map[string]interface{} {
	c := make(map[string]interface{}, len(m))
	for k, v := range m {
		c[k] = v
	}
	return c
}
58608
func convertSpacesFromConstraints(spaces *[]string) ([]string, []string) {
	if spaces == nil || len(*spaces) == 0 {
		return nil, nil
	}
	return parseDelimitedValues(*spaces)
}
1349890
func convertError(err error, format string, args ...interface{}) error {
	message := format
	if len(args) > 0 {
		message = fmt.Sprintf(format, args...)
	}

	cause := errs.Cause(err)
	if statusError, ok := cause.(*kubeErrors.StatusError); ok {
		message = fmt.Sprintf("%s: %s", message, statusError.Error())
		// Pass through certain HTTP statuses to our API response
		if kubeErrors.IsBadRequest(statusError) {
			return errors.NewBadParameterErrorFromString(message)
		} else if kubeErrors.IsNotFound(statusError) {
			return errors.NewNotFoundErrorFromString(message)
		}
	}
	return errors.NewInternalError(nil /* unused */, errs.Wrap(err, message))
}
12930
func convertOffers(
	store string, loggedInUser names.UserTag, offers ...*crossmodel.ApplicationOfferDetails,
) (map[string]ShowOfferedApplication, error) {
	if len(offers) == 0 {
		return nil, nil
	}
	output := make(map[string]ShowOfferedApplication, len(offers))
	for _, one := range offers {
		access := accessForUser(loggedInUser, one.Users)
		app := ShowOfferedApplication{
			Access:    access,
			Endpoints: convertRemoteEndpoints(one.Endpoints...),
			Users:     convertUsers(one.Users...),
		}
		if one.ApplicationDescription != "" {
			app.Description = one.ApplicationDescription
		}
		url, err := crossmodel.ParseOfferURL(one.OfferURL)
		if err != nil {
			return nil, err
		}
		if url.Source == "" {
			url.Source = store
		}
		output[url.String()] = app
	}
	return output, nil
}
1364390
func Convert(obj interface{}) (url.Values, error) {
	result := url.Values{}
	if obj == nil {
		return result, nil
	}
	var sv reflect.Value
	switch reflect.TypeOf(obj).Kind() {
	case reflect.Ptr, reflect.Interface:
		sv = reflect.ValueOf(obj).Elem()
	default:
		return nil, fmt.Errorf("expecting a pointer or interface")
	}
	st := sv.Type()
	if !isStructKind(st.Kind()) {
		return nil, fmt.Errorf("expecting a pointer to a struct")
	}

	// Check all object fields
	convertStruct(result, st, sv)

	return result, nil
}
1144185
func convertMapNumbers(m map[string]interface{}) error {
	var err error
	for k, v := range m {
		switch v := v.(type) {
		case json.Number:
			m[k], err = convertNumber(v)
		case map[string]interface{}:
			err = convertMapNumbers(v)
		case []interface{}:
			err = convertSliceNumbers(v)
		}
		if err != nil {
			return err
		}
	}
	return nil
}
639817
func NewAreaController(service *goa.Service, db application.DB, config AreaControllerConfiguration) *AreaController {
	return &AreaController{
		Controller: service.NewController("AreaController"),
		db:         db,
		config:     config}
}
2227
func (hg *Histogram) ConvertTo(sc *stmtctx.StatementContext, tp *types.FieldType) (*Histogram, error) {
	hist := NewHistogram(hg.ID, hg.NDV, hg.NullCount, hg.LastUpdateVersion, tp, hg.Len(), hg.TotColSize)
	iter := chunk.NewIterator4Chunk(hg.Bounds)
	for row := iter.Begin(); row != iter.End(); row = iter.Next() {
		d := row.GetDatum(0, hg.Tp)
		d, err := d.ConvertTo(sc, tp)
		if err != nil {
			return nil, errors.Trace(err)
		}
		hist.Bounds.AppendDatum(0, &d)
	}
	hist.Buckets = hg.Buckets
	return hist, nil
}