Xmlb.Silo¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/en |
|||
r/w/c/en |
|||
r/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class Xmlb.Silo(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
- classmethod new()¶
-
Creates a new silo.
Added in version 0.1.0.
- classmethod new_from_xml(xml)¶
- Parameters:
xml (
str) – XML string- Raises:
- Returns:
- Return type:
Creates a new silo from an XML string.
Added in version 0.1.0.
- export(flags)¶
- Parameters:
flags (
Xmlb.NodeExportFlags) – someXmlb.NodeExportFlags, e.g.Xmlb.NodeExportFlags.NONE- Raises:
- Returns:
XML data, or
Nonefor an error- Return type:
Exports the silo back to XML.
Added in version 0.1.0.
- export_file(file, flags, cancellable)¶
- Parameters:
flags (
Xmlb.NodeExportFlags) – someXmlb.NodeExportFlags, e.g.Xmlb.NodeExportFlags.NONEcancellable (
Gio.CancellableorNone) – aGio.Cancellable, orNone
- Raises:
- Returns:
Trueon success- Return type:
Exports the silo back to an XML file.
Added in version 0.1.2.
- get_bytes()¶
- Returns:
A
GLib.Bytes, orNoneif never set- Return type:
Gets the backing object that created the blob.
You should never *ever* modify this data.
Added in version 0.1.0.
- get_enable_node_cache()¶
- Return type:
Get
Xmlb.Silo:enable-node-cache.Added in version 0.2.0.
- get_guid()¶
-
Gets the GUID used to identify this silo.
Added in version 0.1.0.
- get_profile_string()¶
- Returns:
text profiling data
- Return type:
Returns the profiling data. This will only return profiling text if
Xmlb.Silo.set_profile_flags() was used withXmlb.SiloProfileFlags.APPEND.Added in version 0.1.1.
- get_root()¶
-
Gets the root node for the silo. (MIGHT BE MORE).
Added in version 0.1.0.
- get_size()¶
- Returns:
a integer, or 0 is an empty blob
- Return type:
Gets the number of nodes in the silo.
Added in version 0.1.0.
- invalidate()¶
Invalidates a silo. Future calls
Xmlb.Silo.is_valid() will returnFalse.Added in version 0.1.1.
- is_valid()¶
-
Checks is the silo is valid. The usual reason the silo is invalidated is when the backing mmapped file has changed, or one of the imported files have been modified.
Added in version 0.1.0.
- load_from_bytes(blob, flags)¶
- Parameters:
blob (
GLib.Bytes) – aGLib.Bytesflags (
Xmlb.SiloLoadFlags) –Xmlb.SiloLoadFlags, e.g.Xmlb.SiloLoadFlags.NONE
- Raises:
- Returns:
Truefor success, otherwise error is set.- Return type:
Loads a silo from memory location.
Added in version 0.1.0.
- load_from_file(file, flags, cancellable)¶
- Parameters:
flags (
Xmlb.SiloLoadFlags) –Xmlb.SiloLoadFlags, e.g.Xmlb.SiloLoadFlags.NONEcancellable (
Gio.CancellableorNone) – aGio.Cancellable, orNone
- Raises:
- Returns:
Truefor success, otherwise error is set.- Return type:
Loads a silo from file.
Added in version 0.1.0.
- lookup_query(xpath)¶
- Parameters:
xpath (
str) – an XPath query string- Returns:
an
Xmlb.Queryrepresenting xpath- Return type:
Create an
Xmlb.Queryfrom the given xpath XPath string, or return it from the query cache in theXmlb.Silo.xpath must be valid: it is a programmer error if creating the query fails (i.e. if
Xmlb.Query.new() returns an error).This function is thread-safe.
Added in version 0.3.0.
- lookup_query_full(xpath)¶
- Parameters:
xpath (
str) – an XPath query string- Raises:
- Returns:
an
Xmlb.Queryrepresenting xpath- Return type:
Create an
Xmlb.Queryfrom the given xpath XPath string, or return it from the query cache in theXmlb.Silo.xpath must be valid: it is a programmer error if creating the query fails (i.e. if
Xmlb.Query.new() returns an error).This function is thread-safe.
Added in version 0.3.27.
- query(xpath, limit)¶
- Parameters:
- Raises:
- Returns:
results, or
Noneif unfound- Return type:
Searches the silo using an XPath query, returning up to limit results.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a subset of XPath is supported.
Added in version 0.1.0.
- query_build_index(xpath, attr)¶
- Parameters:
- Raises:
- Returns:
Truefor success- Return type:
Adds the
attr()ortext()results of a query to the index.Added in version 0.1.4.
- query_first(xpath)¶
- Parameters:
xpath (
str) – An XPath, e.g./components/component[@type=desktop]/id[abe.desktop]- Raises:
- Returns:
- Return type:
Searches the silo using an XPath query, returning up to one result.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a tiny subset of XPath 1.0 is supported.
Added in version 0.1.0.
- query_first_full(query)¶
- Parameters:
query (
Xmlb.Query) – anXmlb.Query- Raises:
- Returns:
- Return type:
Searches the silo using an XPath query, returning up to one result.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a tiny subset of XPath 1.0 is supported.
Added in version 0.1.13.
- query_first_with_context(query, context)¶
- Parameters:
query (
Xmlb.Query) – anXmlb.Querycontext (
Xmlb.QueryContextorNone) – context including values bound to opcodes of typeXmlb.OpcodeKind.BOUND_INTEGERorXmlb.OpcodeKind.BOUND_TEXT, orNoneif the query doesn’t need any context
- Raises:
- Returns:
- Return type:
Searches the silo using an XPath query, returning up to one result.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a tiny subset of XPath 1.0 is supported.
Added in version 0.3.0.
- query_full(query)¶
- Parameters:
query (
Xmlb.Query) – anXmlb.Query- Raises:
- Returns:
results, or
Noneif unfound- Return type:
Searches the silo using an XPath query.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a subset of XPath is supported.
Added in version 0.1.13.
- query_with_context(query, context)¶
- Parameters:
query (
Xmlb.Query) – anXmlb.Querycontext (
Xmlb.QueryContextorNone) – context including values bound to opcodes of typeXmlb.OpcodeKind.BOUND_INTEGERorXmlb.OpcodeKind.BOUND_TEXT, orNoneif the query doesn’t need any context
- Raises:
- Returns:
results, or
Noneif unfound- Return type:
Searches the silo using an XPath query.
It is safe to call this function from a different thread to the one that created the
Xmlb.Silo.Please note: Only a subset of XPath is supported.
Added in version 0.3.0.
- save_to_file(file, cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – aGio.Cancellable, orNone
- Raises:
- Returns:
Truefor success, otherwise error is set.- Return type:
Saves a silo to a file.
Added in version 0.1.0.
- set_enable_node_cache(enable_node_cache)¶
-
Set
Xmlb.Silo:enable-node-cache.This is not thread-safe, and can only be called before the
Xmlb.Silois passed between threads.Added in version 0.2.0.
- set_profile_flags(profile_flags)¶
- Parameters:
profile_flags (
Xmlb.SiloProfileFlags) – someXmlb.SiloProfileFlags, e.g.Xmlb.SiloProfileFlags.DEBUG
Enables or disables the collection of profiling data.
Added in version 0.1.1.
- to_string()¶
- Raises:
- Returns:
A string, or
Nonefor an error- Return type:
Converts the silo to an internal string representation. This is only really useful for debugging
Xmlb.Siloitself.Added in version 0.1.0.
- watch_file(file, cancellable)¶
- Parameters:
cancellable (
Gio.CancellableorNone) – aGio.Cancellable, orNone
- Raises:
- Returns:
Truefor success, otherwise error is set.- Return type:
Adds a file monitor to the silo. If the file or directory for file changes then the silo will be invalidated.
The monitor will internally use the
GLib.MainContextwhich was the thread default when theXmlb.Silowas created, so thatGLib.MainContextmust be iterated for monitoring to work.Added in version 0.1.0.
Property Details¶
- Xmlb.Silo.props.enable_node_cache¶
- Name:
enable-node-cache- Type:
- Default Value:
- Flags:
Whether to cache all
Xmlb.Nodeinstances ever constructed in a single cache in theXmlb.Silo, so that the sameXmlb.Nodeinstance is always returned in query results for a given XPath. This is a form of memoisation, and allowsXmlb.Node.get_data() andXmlb.Node.set_data() to be used.This is enabled by default to preserve compatibility with older versions of libxmlb, but most clients will want to disable it. It adds a large memory overhead (no
Xmlb.Nodeis ever finalised) but achieves moderately low hit rates for typical XML parsing workloads where most nodes are accessed only once or twice as they are processed and then processing moves on to other nodes.This property can only be changed before the
Xmlb.Silois passed between threads. Changing it is not thread-safe.Added in version 0.2.0.
- Xmlb.Silo.props.guid¶
- Xmlb.Silo.props.valid¶
- Name:
valid- Type:
- Default Value:
- Flags: