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 ¶
func NativeOf(v Value) interface{}
NativeOf safely call v.Native, returning nil in case of nil Value.
func RegisterStringConversion ¶
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 ¶
type Bool bool
Bool is a native wrapper for bool type.
It uses NQuad notation similar to TypedString.
type ByQuadString ¶
type ByQuadString []Quad
func (ByQuadString) Len ¶
func (o ByQuadString) Len() int
func (ByQuadString) Less ¶
func (o ByQuadString) Less(i, j int) bool
func (ByQuadString) Swap ¶
func (o ByQuadString) Swap(i, j int)
type ByValueString ¶
type ByValueString []Value
func (ByValueString) Len ¶
func (o ByValueString) Len() int
func (ByValueString) Less ¶
func (o ByValueString) Less(i, j int) bool
func (ByValueString) Swap ¶
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 Float ¶
type Float float64
Float is a native wrapper for float64 type.
It uses NQuad notation similar to TypedString.
type Int ¶
type Int int64
Int is a native wrapper for int64 type.
It uses NQuad notation similar to TypedString.
type LangString ¶
LangString is an RDF string with language (ex: "name"@lang).
func (LangString) Native ¶
func (s LangString) Native() interface{}
func (LangString) String ¶
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 ¶
func Make(subject, predicate, object, label interface{}) (q Quad)
Make creates a quad with provided values.
func (Quad) MarshalJSON ¶
func (*Quad) UnmarshalJSON ¶
type StringConversion ¶
StringConversion is a function to convert string values with a specific IRI type to their native equivalents.
type Time ¶
Time is a native wrapper for time.Time type.
It uses NQuad notation similar to TypedString.
type TypedString ¶
TypedString is an RDF value with type (ex: "name"^^<type>).
func (TypedString) Native ¶
func (s TypedString) Native() interface{}
func (TypedString) ParseValue ¶
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 ¶
func (s TypedString) String() string
type Unmarshaler ¶
type Value ¶
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 ¶
AsValue converts native type into closest Value representation. It returns false if type was not recognized.
func StringToValue ¶
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. |