// View returns a pointer to the view with the given name, or error
// ErrUnknownView if a view with that name does not exist.
433492
func (g *Gui) View(name string) (*View, error) {
	for _, v := range g.views {
		if v.name == name {
			return v, nil
		}
	}
	return nil, ErrUnknownView
}
1164512
func (c *Client) DeleteView(ctx context.Context, id platform.ID) error {
	return c.db.Update(func(tx *bolt.Tx) error {
		if pe := c.deleteView(ctx, tx, id); pe != nil {
			return &platform.Error{
				Err: pe,
				Op:  getOp(platform.OpDeleteView),
			}
		}
		return nil
	})
}
261969
func (p *Pages) AddView(addr string, v Views) {
	v.UseHistory(p.HistoryProvider)
	p.UseState(addr, v)
}
367418
func (h *Holder) view(index, field, name string) *view {
	f := h.Field(index, field)
	if f == nil {
		return nil
	}
	return f.view(name)
}
94138
func (s *Service) CreateView(ctx context.Context, c *platform.View) error {
	c.ID = s.IDGenerator.ID()
	if err := s.PutView(ctx, c); err != nil {
		return &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpCreateView,
		}
	}
	return nil
}
638528
func view(ctx context.Context, db transactor, fn func(*bolt.Tx) error) error {
	tx, ok := ctx.Value(transactionKey{}).(*bolt.Tx)
	if !ok {
		return db.View(fn)
	}
	return fn(tx)
}
182219
func (g *Gui) SetViewOnTop(name string) (*View, error) {
	for i, v := range g.views {
		if v.name == name {
			s := append(g.views[:i], g.views[i+1:]...)
			g.views = append(s, v)
			return v, nil
		}
	}
	return nil, ErrUnknownView
}
441453
func (app *Application) RegisterView(viewEngine view.Engine) {
	app.view.Register(viewEngine)
}
283413
func NewView() *View {
	view := new(View)
	view.templateLoader = make(map[string]*TemplateManager)
	view.FuncMap = make(template.FuncMap)
	view.FuncMap["Html"] = func(s string) template.HTML { return template.HTML(s) }
	return view
}
574191
func (vv VectorisedView) ToView() View {
	if len(vv.views) == 1 {
		return vv.views[0]
	}
	u := make([]byte, 0, vv.size)
	for _, v := range vv.views {
		u = append(u, v...)
	}
	return u
}
11724
func (v *view) open() error {

	// Never keep a cache for field views.
	if strings.HasPrefix(v.name, viewBSIGroupPrefix) {
		v.cacheType = CacheTypeNone
	}

	if err := func() error {
		// Ensure the view's path exists.
		v.logger.Debugf("ensure view path exists: %s", v.path)
		if err := os.MkdirAll(v.path, 0777); err != nil {
			return errors.Wrap(err, "creating view directory")
		} else if err := os.MkdirAll(filepath.Join(v.path, "fragments"), 0777); err != nil {
			return errors.Wrap(err, "creating fragments directory")
		}

		v.logger.Debugf("open fragments for index/field/view: %s/%s/%s", v.index, v.field, v.name)
		if err := v.openFragments(); err != nil {
			return errors.Wrap(err, "opening fragments")
		}

		return nil
	}(); err != nil {
		v.close()
		return err
	}

	v.logger.Debugf("successfully opened index/field/view: %s/%s/%s", v.index, v.field, v.name)
	return nil
}
100738
func (api *API) Views(ctx context.Context, indexName string, fieldName string) ([]*view, error) {
	span, _ := tracing.StartSpanFromContext(ctx, "API.Views")
	defer span.Finish()

	if err := api.validate(apiViews); err != nil {
		return nil, errors.Wrap(err, "validating api method")
	}

	// Retrieve views.
	f := api.holder.Field(indexName, fieldName)
	if f == nil {
		return nil, ErrFieldNotFound
	}

	// Fetch views.
	views := f.views()
	return views, nil
}
978620
func View(db DB, f func(tx ReadTx) error) error {
	tx, err := db.BeginReadTx()
	if err != nil {
		return err
	}
	err = f(tx)
	rollbackErr := tx.Rollback()
	if err != nil {
		return err
	}
	if rollbackErr != nil {
		return rollbackErr
	}
	return nil
}
513639
func (v *view) relPath() string {
	escapedName := pathEscape(v.name)
	return path.Join(v.db.relPath(), "_api", "view", escapedName)
}
724966
func (s *Service) DeleteView(ctx context.Context, id platform.ID) error {
	if _, err := s.FindViewByID(ctx, id); err != nil {
		return &platform.Error{
			Err: err,
			Op:  OpPrefix + platform.OpDeleteView,
		}
	}
	s.viewKV.Delete(id.String())
	return nil
}
709730
func (v *ViewDefinition) Context() string {
	var prefix, suffix string
	if v.Name != "" {
		prefix = fmt.Sprintf("view %#v", v.Name)
	} else {
		prefix = "unnamed view"
	}
	if v.Parent != nil {
		suffix = fmt.Sprintf(" of %s", v.Parent.Context())
	}
	return prefix + suffix
}
519979
func (s *session) FindView(view View, keys KeyList, container TableListContainer, opts ...GetOption) error {
	action, err := s.recursivelyLoadView(view, keys, container, s.applyGetOption(opts))
	if err != nil {
		return s.catch("FindView: "+action, err)
	}
	return nil
}