XbSilo

XbSilo — A read-only store of parsed XML data

Stability Level

Stable, unless otherwise indicated

Functions

Types and Values

Includes

#include <xmlb.h>

Description

XbSilo provides read-only access and querying of a previously parsed blob of XML data.

All signal emissions from XbSilo (currently only “notify” emissions) will happen in the GMainContext which is the thread default when the XbSilo is constructed.

This GMainContext must be iterated for file monitoring using xb_silo_watch_file() to function correctly.

Functions

xb_silo_new ()

XbSilo *
xb_silo_new (void);

Creates a new silo.

Returns

a new XbSilo

Since: 0.1.0


xb_silo_new_from_xml ()

XbSilo *
xb_silo_new_from_xml (const gchar *xml,
                      GError **error);

Creates a new silo from an XML string.

Parameters

xml

XML string

 

error

the GError, or NULL

 

Returns

a new XbSilo, or NULL

Since: 0.1.0


xb_silo_get_bytes ()

GBytes *
xb_silo_get_bytes (XbSilo *self);

Gets the backing object that created the blob.

You should never *ever* modify this data.

Parameters

self

a XbSilo

 

Returns

A GBytes, or NULL if never set.

[transfer full]

Since: 0.1.0


xb_silo_load_from_bytes ()

gboolean
xb_silo_load_from_bytes (XbSilo *self,
                         GBytes *blob,
                         XbSiloLoadFlags flags,
                         GError **error);

Loads a silo from memory location.

Parameters

self

a XbSilo

 

blob

a GBytes

 

flags

XbSiloLoadFlags, e.g. XB_SILO_LOAD_FLAG_NONE

 

error

the GError, or NULL

 

Returns

TRUE for success, otherwise error is set.

Since: 0.1.0


xb_silo_load_from_file ()

gboolean
xb_silo_load_from_file (XbSilo *self,
                        GFile *file,
                        XbSiloLoadFlags flags,
                        GCancellable *cancellable,
                        GError **error);

Loads a silo from file.

Parameters

self

a XbSilo

 

file

a GFile

 

flags

XbSiloLoadFlags, e.g. XB_SILO_LOAD_FLAG_NONE

 

cancellable

a GCancellable, or NULL

 

error

the GError, or NULL

 

Returns

TRUE for success, otherwise error is set.

Since: 0.1.0


xb_silo_save_to_file ()

gboolean
xb_silo_save_to_file (XbSilo *self,
                      GFile *file,
                      GCancellable *cancellable,
                      GError **error);

Saves a silo to a file.

Parameters

self

a XbSilo

 

file

a GFile

 

cancellable

a GCancellable, or NULL

 

error

the GError, or NULL

 

Returns

TRUE for success, otherwise error is set.

Since: 0.1.0


xb_silo_to_string ()

gchar *
xb_silo_to_string (XbSilo *self,
                   GError **error);

Converts the silo to an internal string representation. This is only really useful for debugging XbSilo itself.

Parameters

self

a XbSilo

 

error

the GError, or NULL

 

Returns

A string, or NULL for an error

Since: 0.1.0


xb_silo_get_size ()

guint
xb_silo_get_size (XbSilo *self);

Gets the number of nodes in the silo.

Parameters

self

a XbSilo

 

Returns

a integer, or 0 is an empty blob

Since: 0.1.0


xb_silo_get_guid ()

const gchar *
xb_silo_get_guid (XbSilo *self);

Gets the GUID used to identify this silo.

Parameters

self

a XbSilo

 

Returns

a string, otherwise NULL

Since: 0.1.0


xb_silo_get_root ()

XbNode *
xb_silo_get_root (XbSilo *self);

Gets the root node for the silo. (MIGHT BE MORE).

Parameters

self

a XbSilo

 

Returns

A XbNode, or NULL for an error.

[transfer full]

Since: 0.1.0


xb_silo_invalidate ()

void
xb_silo_invalidate (XbSilo *self);

Invalidates a silo. Future calls xb_silo_is_valid() will return FALSE.

Parameters

self

a XbSilo

 

Since: 0.1.1


xb_silo_is_valid ()

gboolean
xb_silo_is_valid (XbSilo *self);

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.

Parameters

self

a XbSilo

 

Returns

TRUE if valid

Since: 0.1.0


xb_silo_watch_file ()

gboolean
xb_silo_watch_file (XbSilo *self,
                    GFile *file,
                    GCancellable *cancellable,
                    GError **error);

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 GMainContext which was the thread default when the XbSilo was created, so that GMainContext must be iterated for monitoring to work.

Parameters

self

a XbSilo

 

file

a GFile

 

cancellable

a GCancellable, or NULL

 

error

the GError, or NULL

 

Returns

TRUE for success, otherwise error is set.

Since: 0.1.0


xb_silo_set_profile_flags ()

void
xb_silo_set_profile_flags (XbSilo *self,
                           XbSiloProfileFlags profile_flags);

Enables or disables the collection of profiling data.

Parameters

self

a XbSilo

 

profile_flags

some XbSiloProfileFlags, e.g. XB_SILO_PROFILE_FLAG_DEBUG

 

Since: 0.1.1


xb_silo_get_profile_string ()

const gchar *
xb_silo_get_profile_string (XbSilo *self);

Returns the profiling data. This will only return profiling text if xb_silo_set_profile_flags() was used with XB_SILO_PROFILE_FLAG_APPEND.

Parameters

self

a XbSilo

 

Returns

text profiling data

Since: 0.1.1


xb_silo_get_enable_node_cache ()

gboolean
xb_silo_get_enable_node_cache (XbSilo *self);

Get “enable-node-cache”.

Parameters

self

an XbSilo

 

Since: 0.2.0


xb_silo_set_enable_node_cache ()

void
xb_silo_set_enable_node_cache (XbSilo *self,
                               gboolean enable_node_cache);

Set “enable-node-cache”.

This is not thread-safe, and can only be called before the XbSilo is passed between threads.

Parameters

self

an XbSilo

 

enable_node_cache

TRUE to enable the node cache, FALSE otherwise

 

Since: 0.2.0


xb_silo_lookup_query ()

XbQuery *
xb_silo_lookup_query (XbSilo *self,
                      const gchar *xpath);

Create an XbQuery from the given xpath XPath string, or return it from the query cache in the XbSilo.

xpath must be valid: it is a programmer error if creating the query fails (i.e. if xb_query_new() returns an error).

This function is thread-safe.

Parameters

self

an XbSilo

 

xpath

an XPath query string

 

Returns

an XbQuery representing xpath .

[transfer full]

Since: 0.3.0

Types and Values

XB_TYPE_SILO

#define             XB_TYPE_SILO

struct XbSiloClass

struct XbSiloClass {
	GObjectClass parent_class;
};

enum XbSiloLoadFlags

The flags for loading a silo.

Members

XB_SILO_LOAD_FLAG_NONE

   

XB_SILO_LOAD_FLAG_NO_MAGIC

   

XB_SILO_LOAD_FLAG_WATCH_BLOB

   

enum XbSiloProfileFlags

The flags used when profiling a silo.

Members

XB_SILO_PROFILE_FLAG_NONE

   

XB_SILO_PROFILE_FLAG_DEBUG

   

XB_SILO_PROFILE_FLAG_APPEND

   

XB_SILO_PROFILE_FLAG_XPATH

   

XB_SILO_PROFILE_FLAG_OPTIMIZER

   

XbSilo

typedef struct _XbSilo XbSilo;