GnuCash 2.3.0
Data Structures | Files
Object_Private
Object: Dynamic Object Class Framework

Data Structures

struct  QofBackendProvider_s
struct  QofBackend_s

Files

file  qofbackend-p.h
 

private api for data storage backend


file  qofobject-p.h
 

the Core Object Registration/Lookup Private Interface


Backend_Private

Pseudo-object defining how the engine can interact with different back-ends (which may be SQL databases, or network interfaces to remote QOF servers. File-io is just one type of backend).

The callbacks will be called at the appropriate times during a book session to allow the backend to store the data as needed.

enum  QofBackendLoadType { LOAD_TYPE_INITIAL_LOAD, LOAD_TYPE_LOAD_ALL }
void qof_backend_register_provider (QofBackendProvider *)
void qof_backend_set_message (QofBackend *be, const char *format,...)
char * qof_backend_get_message (QofBackend *be)
void qof_backend_init (QofBackend *be)
void qof_backend_destroy (QofBackend *be)
gchar qof_book_get_open_marker (const QofBook *book)
gint32 qof_book_get_version (const QofBook *book)
void qof_book_set_version (QofBook *book, gint32 version)

Book_Private

void qof_book_set_backend (QofBook *book, QofBackend *be)
gboolean qof_book_register (void)
gchar * qof_book_validate_counter_format_internal (const gchar *p, const gchar *gint64_format)
void qof_book_print_dirty (const QofBook *book)
#define qof_book_set_guid(book, guid)   qof_instance_set_guid(QOF_INSTANCE(book), guid)

Class_Private

void qof_class_init (void)
void qof_class_shutdown (void)
QofSortFunc qof_class_get_default_sort (QofIdTypeConst obj_name)

Entity_Private

void qof_collection_insert_entity (QofCollection *, QofInstance *)
void qof_collection_mark_clean (QofCollection *)
void qof_collection_mark_dirty (QofCollection *)
void qof_collection_print_dirty (const QofCollection *col, gpointer dummy)

Objects_Private

void qof_object_book_begin (QofBook *book)
void qof_object_book_end (QofBook *book)
gboolean qof_object_is_dirty (const QofBook *book)
void qof_object_mark_clean (QofBook *book)
gboolean qof_object_compliance (QofIdTypeConst type_name, gboolean warn)
 check an object can be created and supports iteration

Detailed Description

Private interfaces, not meant to be used by applications.


Define Documentation

#define qof_book_set_guid (   book,
  guid 
)    qof_instance_set_guid(QOF_INSTANCE(book), guid)
Deprecated:
use qof_instance_set_guid instead but only in backends (when reading the GncGUID from the data source).

Definition at line 61 of file qofbook-p.h.


Function Documentation

char* qof_backend_get_message ( QofBackend be)

The qof_backend_get_message() pops the error message string from the Backend. This string should be freed with g_free().

Definition at line 92 of file qofbackend.c.

{
    char * msg;

    if (!be) return g_strdup("ERR_BACKEND_NO_BACKEND");
    if (!be->error_msg) return NULL;

    /*
     * Just return the contents of the error_msg and then set it to
     * NULL. This is necessary, because the Backends don't seem to
     * have a destroy_backend function to take care of freeing stuff
     * up. The calling function should free the copy.
     * Also, this is consistent with the qof_backend_get_error() popping.
     */

    msg = be->error_msg;
    be->error_msg = NULL;
    return msg;
}
void qof_backend_register_provider ( QofBackendProvider )

Let the sytem know about a new provider of backends. This function is typically called by the provider library at library load time. This function allows the backend library to tell the QOF infrastructure that it can handle URL's of a certain type. Note that a single backend library may register more than one provider, if it is capable of handling more than one URL access method.

Definition at line 93 of file qofsession.c.

{
    provider_list = g_slist_append (provider_list, prov);
}
void qof_backend_set_message ( QofBackend be,
const char *  format,
  ... 
)

The qof_backend_set_message() assigns a string to the backend error message.

Definition at line 68 of file qofbackend.c.

{
    va_list args;
    char * buffer;

    if (!be) return;

    /* If there's already something here, free it */
    if (be->error_msg) g_free(be->error_msg);

    if (!format)
    {
        be->error_msg = NULL;
        return;
    }

    va_start(args, format);
    buffer = (char *)g_strdup_vprintf(format, args);
    va_end(args);

    be->error_msg = buffer;
}
gchar qof_book_get_open_marker ( const QofBook book)

Allow backends to see if the book is open

Returns:
'y' if book is open, otherwise 'n'.
gint32 qof_book_get_version ( const QofBook book)

get the book version

used for tracking multiuser updates in backends.

Returns:
-1 if no book exists, 0 if the book is new, otherwise the book version number.
void qof_book_print_dirty ( const QofBook book)

This debugging function can be used to traverse the book structure and all subsidiary structures, printing out which structures have been marked dirty.

gchar* qof_book_validate_counter_format_internal ( const gchar *  p,
const gchar *  gint64_format 
)

Validate a counter format string with the given G_GINT64_FORMAT. Returns an error message if the format string was invalid, or NULL if it is ok. The caller should free the error message with g_free.

Definition at line 517 of file qofbook.c.

{
    const gchar *conv_start, *tmp = NULL;

    /* Validate a counter format. This is a very simple "parser" that
     * simply checks for a single gint64 conversion specification,
     * allowing all modifiers and flags that printf(3) specifies (except
     * for the * width and precision, which need an extra argument). */

    /* Skip a prefix of any character except % */
    while (*p)
    {
        /* Skip two adjacent percent marks, which are literal percent
         * marks */
        if (p[0] == '%' && p[1] == '%')
        {
            p += 2;
            continue;
        }
        /* Break on a single percent mark, which is the start of the
         * conversion specification */
        if (*p == '%')
            break;
        /* Skip all other characters */
        p++;
    }

    if (!*p)
        return g_strdup("Format string ended without any conversion specification");

    /* Store the start of the conversion for error messages */
    conv_start = p;

    /* Skip the % */
    p++;

    /* See whether we have already reached the correct format
     * specification (e.g. "li" on Unix, "I64i" on Windows). */
    tmp = strstr(p, gint64_format);

    /* Skip any number of flag characters */
    while (*p && (tmp != p) && strchr("#0- +'I", *p))
    {
        p++;
        tmp = strstr(p, gint64_format);
    }

    /* Skip any number of field width digits */
    while (*p && (tmp != p) && strchr("0123456789", *p))
    {
        p++;
        tmp = strstr(p, gint64_format);
    }

    /* A precision specifier always starts with a dot */
    if (*p && *p == '.')
    {
        /* Skip the . */
        p++;
        /* Skip any number of precision digits */
        while (*p && strchr("0123456789", *p)) p++;
    }

    if (!*p)
        return g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);

    /* See if the format string starts with the correct format
     * specification. */
    tmp = strstr(p, gint64_format);
    if (tmp == NULL)
    {
        return g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
    }
    else if (tmp != p)
    {
        return g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
    }

    /* Skip length modifier / conversion specifier */
    p += strlen(gint64_format);

    /* Skip a suffix of any character except % */
    while (*p)
    {
        /* Skip two adjacent percent marks, which are literal percent
         * marks */
        if (p[0] == '%' && p[1] == '%')
        {
            p += 2;
            continue;
        }
        /* Break on a single percent mark, which is the start of the
         * conversion specification */
        if (*p == '%')
            return g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
        /* Skip all other characters */
        p++;
    }

    /* If we end up here, the string was valid, so return no error
     * message */
    return NULL;
}
void qof_collection_insert_entity ( QofCollection ,
QofInstance  
)

Take entity, remove it from whatever collection its currently in, and place it in a new collection. To be used only for moving entity from one book to another.

Definition at line 111 of file qofid.c.

{
    const GncGUID *guid;

    if (!col || !ent) return;
    guid = qof_instance_get_guid(ent);
    if (guid_equal(guid, guid_null())) return;
    g_return_if_fail (col->e_type == ent->e_type);
    qof_collection_remove_entity (ent);
    g_hash_table_insert (col->hash_of_entities, (gpointer)guid, ent);
    if (!qof_alt_dirty_mode)
        qof_collection_mark_dirty(col);
    qof_instance_set_collection(ent, col);
}
void qof_collection_mark_clean ( QofCollection )

reset value of dirty flag

Definition at line 278 of file qofid.c.

{
    if (col)
    {
        col->is_dirty = FALSE;
    }
}
void qof_object_book_begin ( QofBook book)

To be called from within the book

Definition at line 93 of file qofobject.c.

{
    GList *l;

    if (!book) return;
    ENTER (" ");
    for (l = object_modules; l; l = l->next)
    {
        QofObject *obj = l->data;
        if (obj->book_begin)
            obj->book_begin (book);
    }

    /* Remember this book for later */
    book_list = g_list_prepend (book_list, book);
    LEAVE (" ");
}
gboolean qof_object_compliance ( QofIdTypeConst  type_name,
gboolean  warn 
)

check an object can be created and supports iteration

Parameters:
type_nameobject to check
warnIf called only once per operation, pass TRUE to log objects that fail the compliance check. To prevent repeated log messages when calling more than once, pass FALSE.
Returns:
TRUE if object can be created and supports iteration, else FALSE.

Definition at line 180 of file qofobject.c.

{
    const QofObject *obj;

    obj = qof_object_lookup(type_name);
    if ((obj->create == NULL) || (obj->foreach == NULL))
    {
        if (warn)
        {
            PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
        }
        return FALSE;
    }
    return TRUE;
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines