Documentation ¶
Overview ¶
Package quad defines quad and triple handling.
Index ¶
- Constants
- Variables
- func HashOf(v Value) []byte
- func HashTo(v Value, p []byte)
- func NativeOf(v Value) interface{}
- func RegisterStringConversion(dataType IRI, fnc StringConversion)
- func StringOf(v Value) string
- type BNode
- type Bool
- type ByQuadString
- type ByValueString
- type Direction
- type Equaler
- type Float
- type IRI
- type Int
- type LangString
- type Quad
- type Raw
- type String
- type StringConversion
- type Time
- type TypedString
- type Unmarshaler
- type Value
Constants ¶
const HashSize = sha1.Size
HashSize is a size of the slice, returned by HashOf.
Variables ¶
var ( ErrInvalid = errors.New("invalid N-Quad") ErrIncomplete = errors.New("incomplete N-Quad") )
Functions ¶
func NativeOf ¶ added in v0.6.0
func NativeOf(v Value) interface{}
NativeOf safely call v.Native, returning nil in case of nil Value.
func RegisterStringConversion ¶ added in v0.6.0
func RegisterStringConversion(dataType IRI, fnc StringConversion)
RegisterStringConversion will register an automatic conversion of TypedString values with provided type to a native equivalent such as Int, Time, etc.
If fnc is nil, automatic conversion from selected type will be removed.
Types ¶
type Bool ¶ added in v0.6.0
type Bool bool
Bool is a native wrapper for bool type.
It uses NQuad notation similar to TypedString.
type ByQuadString ¶ added in v0.6.0
type ByQuadString []Quad
func (ByQuadString) Len ¶ added in v0.6.0
func (o ByQuadString) Len() int
func (ByQuadString) Less ¶ added in v0.6.0
func (o ByQuadString) Less(i, j int) bool
func (ByQuadString) Swap ¶ added in v0.6.0
func (o ByQuadString) Swap(i, j int)
type ByValueString ¶ added in v0.6.0
type ByValueString []Value
func (ByValueString) Len ¶ added in v0.6.0
func (o ByValueString) Len() int
func (ByValueString) Less ¶ added in v0.6.0
func (o ByValueString) Less(i, j int) bool
func (ByValueString) Swap ¶ added in v0.6.0
func (o ByValueString) Swap(i, j int)
type Direction ¶
type Direction byte
Direction specifies an edge's type.
List of the valid directions of a quad.
type Equaler ¶ added in v0.6.0
Equaler interface is implemented by values, that needs a special equality check.
type Float ¶ added in v0.6.0
type Float float64
Float is a native wrapper for float64 type.
It uses NQuad notation similar to TypedString.
type IRI ¶ added in v0.6.0
type IRI string
IRI is an RDF Internationalized Resource Identifier (ex: <name>).
type Int ¶ added in v0.6.0
type Int int64
Int is a native wrapper for int64 type.
It uses NQuad notation similar to TypedString.
type LangString ¶ added in v0.6.0
LangString is an RDF string with language (ex: "name"@lang).
func (LangString) Native ¶ added in v0.6.0
func (s LangString) Native() interface{}
func (LangString) String ¶ added in v0.6.0
func (s LangString) String() string
type Quad ¶
type Quad struct { Subject Value `json:"subject"` Predicate Value `json:"predicate"` Object Value `json:"object"` Label Value `json:"label,omitempty"` }
Our quad struct, used throughout.
func Make ¶ added in v0.6.0
func Make(subject, predicate, object, label interface{}) (q Quad)
Make creates a quad with provided values.
func (Quad) GetString ¶ added in v0.6.0
Per-field accessor for quads that returns strings instead of values.
func (Quad) MarshalJSON ¶ added in v0.6.0
func (*Quad) UnmarshalJSON ¶ added in v0.6.0
type StringConversion ¶ added in v0.6.0
StringConversion is a function to convert string values with a specific IRI type to their native equivalents.
type Time ¶ added in v0.6.0
Time is a native wrapper for time.Time type.
It uses NQuad notation similar to TypedString.
type TypedString ¶ added in v0.6.0
TypedString is an RDF value with type (ex: "name"^^<type>).
func (TypedString) Native ¶ added in v0.6.0
func (s TypedString) Native() interface{}
func (TypedString) ParseValue ¶ added in v0.6.0
func (s TypedString) ParseValue() (Value, error)
ParseValue will try to parse underlying string value using registered functions.
It will return unchanged value if suitable function is not available.
Error will be returned if the type was recognizes, but parsing failed.
func (TypedString) String ¶ added in v0.6.0
func (s TypedString) String() string
type Unmarshaler ¶
type Value ¶ added in v0.6.0
type Value interface { String() string // Native converts Value to a closest native Go type. // // If type has no analogs in Go, Native return an object itself. Native() interface{} }
Value is a type used by all quad directions.
func AsValue ¶ added in v0.6.0
AsValue converts native type into closest Value representation. It returns false if type was not recognized.
func StringToValue ¶ added in v0.6.0
StringToValue is a function to convert strings to typed quad values.
Warning: should not be used directly - will be deprecated.
Directories ¶
Path | Synopsis |
---|---|
Package cquads implements parsing N-Quads like line-based syntax for RDF datasets.
|
Package cquads implements parsing N-Quads like line-based syntax for RDF datasets. |
Package nquads implements parsing the RDF 1.1 N-Quads line-based syntax for RDF datasets.
|
Package nquads implements parsing the RDF 1.1 N-Quads line-based syntax for RDF datasets. |