cql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFieldDescription

func GetFieldDescription(field string) string

GetFieldDescription returns the description of a CQL field. Returns empty string if the field is not valid.

func GetValidFields

func GetValidFields() []string

GetValidFields returns a slice of all valid field names.

func IsValidField

func IsValidField(field string) bool

IsValidField checks if a field name is valid in EPO CQL.

func IsValidOperator

func IsValidOperator(op string) bool

IsValidOperator checks if an operator is valid in EPO CQL.

Types

type CQLQuery

type CQLQuery struct {
	// Raw is the original query string
	Raw string

	// Tokens is the parsed token stream
	Tokens []CQLToken

	// Valid indicates whether the query passed validation
	Valid bool

	// Errors contains any validation errors
	Errors []string
}

CQLQuery represents a parsed CQL query.

func ParseCQL

func ParseCQL(query string) (*CQLQuery, error)

ParseCQL parses a CQL query string and returns a CQLQuery object.

Example queries:

  • "ti=bluetooth"
  • "ti=bluetooth AND pa=ericsson"
  • "(ti=5g OR ab=5g) AND pd>=20200101"
  • "pa=\"Apple Inc\" AND ic=H04W"

Returns:

  • *CQLQuery: The parsed query with tokens and validation status
  • error: An error if the query is completely invalid or empty

func (*CQLQuery) GetFields

func (q *CQLQuery) GetFields() []string

GetFields returns all unique fields used in the query.

func (*CQLQuery) HasField

func (q *CQLQuery) HasField(field string) bool

HasField checks if the query contains a specific field.

func (*CQLQuery) String

func (q *CQLQuery) String() string

String returns the raw query string.

func (*CQLQuery) TokenCount

func (q *CQLQuery) TokenCount() int

TokenCount returns the number of tokens in the parsed query.

func (*CQLQuery) URLEncode

func (q *CQLQuery) URLEncode() string

URLEncode returns the CQL query properly URL-encoded for use in API requests.

func (*CQLQuery) Validate

func (q *CQLQuery) Validate() error

Validate checks if the CQL query is valid. Returns an error with details if the query is invalid.

type CQLToken

type CQLToken struct {
	Type  TokenType
	Value string
	Pos   int // Position in original string
}

CQLToken represents a token in a CQL query.

type TokenType

type TokenType int

TokenType represents the type of a CQL token.

const (
	TokenField TokenType = iota
	TokenOperator
	TokenValue
	TokenEquals
	TokenLParen
	TokenRParen
	TokenQuote
	TokenWhitespace
	TokenUnknown
)

func (TokenType) String

func (t TokenType) String() string

String returns a string representation of a token type.

Jump to

Keyboard shortcuts

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