search

package
v0.0.0-...-0df88b9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package search implements the DLNA query language, defined in the ContentDirectory spec.

Index

Constants

View Source
const (
	And = LogicOp("and")
	Or  = LogicOp("or")

	Equal            = BinaryOp("=")
	NotEqual         = BinaryOp("!=")
	LessThan         = BinaryOp("<")
	LessThanEqual    = BinaryOp("<=")
	GreaterThan      = BinaryOp(">")
	GreaterThanEqual = BinaryOp(">=")
	Contains         = BinaryOp("contains")
	DoesNotContain   = BinaryOp("doesNotContain")

	// DerivedFrom is useful for restricting a query to only certain media kinds.
	// For example, `itemClass derivedfrom "object.item.audioItem"`.
	DerivedFrom = BinaryOp("derivedfrom")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryExpr

type BinaryExpr struct {
	Property string
	Op       BinaryOp
	Operand  string
}

BinaryExpr matches Directory Objects where Property matches the relation to Operand by Op. For example, `artist = "The Birthday Massacre"`.

func (BinaryExpr) CanonicalExpr

func (b BinaryExpr) CanonicalExpr() Expr

func (BinaryExpr) String

func (b BinaryExpr) String() string

type BinaryOp

type BinaryOp string

BinaryOp is a binary operation on a property, such as `=` or `contains`.

type Criteria

type Criteria interface {
	Criteria() Criteria
	String() string
}

Criteria is a `searchCrit` from the ContentDirectory specification.

func Parse

func Parse(src string) (Criteria, error)

Parse parses a DLNA query string and returns a Criteria. TODO: Support operator precidence for And and Or (And binds stronger than Or).

type Everything

type Everything struct{}

Everything matches everything, a.k.a. "*".

func (Everything) Criteria

func (e Everything) Criteria() Criteria

func (Everything) String

func (e Everything) String() string

type ExistsExpr

type ExistsExpr struct {
	Property string
	Exists   bool
}

ExistsExpr matches Directory Objects that either do or don't have a given property.

func (ExistsExpr) CanonicalExpr

func (e ExistsExpr) CanonicalExpr() Expr

func (ExistsExpr) String

func (e ExistsExpr) String() string

type Expr

type Expr interface {
	CanonicalExpr() Expr
	String() string
}

Expr is a query or subquery expression.

type LogicExpr

type LogicExpr struct {
	Op       LogicOp
	SubExprs []Expr
}

LogicExpr is the conjunction or disjunction of one or more subquery Exprs.

func (LogicExpr) CanonicalExpr

func (l LogicExpr) CanonicalExpr() Expr

func (LogicExpr) String

func (l LogicExpr) String() string

type LogicOp

type LogicOp string

LogicOp is a logical operation, like `&&` or `||`.

type Query

type Query struct {
	Expr
}

Query wraps some query expression.

func (Query) Criteria

func (q Query) Criteria() Criteria

func (Query) String

func (q Query) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL