GnuCash  2.6.99
Files | Data Structures

Private interfaces, not meant to be used by applications. More...

Files

file  qofobject-p.h
 the Core Object Registration/Lookup Private Interface
 

Data Structures

struct  QofBackend
 

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 }
 
using GModuleVec = std::vector< GModule * >
 

Book_Private

void qof_book_set_backend (QofBook *book, QofBackend *be)
 
gboolean qof_book_register (void)
 
gchar * qof_book_normalize_counter_format_internal (const gchar *p, const gchar *gint64_format, gchar **err_msg)
 Validate a counter format string with a given format specifier. More...
 
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.
 
#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 *)
 Take entity, remove it from whatever collection its currently in, and place it in a new collection. More...
 
void qof_collection_mark_clean (QofCollection *)
 reset value of dirty flag
 
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)
 To be called from within the 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 More...
 

Detailed Description

Private interfaces, not meant to be used by applications.

Macro Definition Documentation

◆ qof_book_set_guid

#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 64 of file qofbook-p.h.

Function Documentation

◆ qof_book_normalize_counter_format_internal()

gchar* qof_book_normalize_counter_format_internal ( const gchar *  p,
const gchar *  gint64_format,
gchar **  err_msg 
)

Validate a counter format string with a given format specifier.

If valid, returns a normalized format string, that is whatever long int specifier was used will be replaced with the value of the posix "PRIx64" macro. If not valid returns NULL and optionally set an error message is a non-null err_msg parameter was passed. The caller should free the returned format string and error message with g_free.

Definition at line 846 of file qofbook.cpp.

848 {
849  const gchar *conv_start, *base, *tmp = NULL;
850  gchar *normalized_str = NULL, *aux_str = NULL;
851 
852  /* Validate a counter format. This is a very simple "parser" that
853  * simply checks for a single gint64 conversion specification,
854  * allowing all modifiers and flags that printf(3) specifies (except
855  * for the * width and precision, which need an extra argument). */
856  base = p;
857 
858  /* Skip a prefix of any character except % */
859  while (*p)
860  {
861  /* Skip two adjacent percent marks, which are literal percent
862  * marks */
863  if (p[0] == '%' && p[1] == '%')
864  {
865  p += 2;
866  continue;
867  }
868  /* Break on a single percent mark, which is the start of the
869  * conversion specification */
870  if (*p == '%')
871  break;
872  /* Skip all other characters */
873  p++;
874  }
875 
876  if (!*p)
877  {
878  if (err_msg)
879  *err_msg = g_strdup("Format string ended without any conversion specification");
880  return NULL;
881  }
882 
883  /* Store the start of the conversion for error messages */
884  conv_start = p;
885 
886  /* Skip the % */
887  p++;
888 
889  /* See whether we have already reached the correct format
890  * specification (e.g. "li" on Unix, "I64i" on Windows). */
891  tmp = strstr(p, gint64_format);
892 
893  if (!tmp)
894  {
895  if (err_msg)
896  *err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format);
897  return NULL;
898  }
899 
900  /* Skip any number of flag characters */
901  while (*p && (tmp != p) && strchr("#0- +'I", *p))
902  {
903  p++;
904  tmp = strstr(p, gint64_format);
905  }
906 
907  /* Skip any number of field width digits,
908  * and precision specifier digits (including the leading dot) */
909  while (*p && (tmp != p) && strchr("0123456789.", *p))
910  {
911  p++;
912  tmp = strstr(p, gint64_format);
913  }
914 
915  if (!*p)
916  {
917  if (err_msg)
918  *err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);
919  return NULL;
920  }
921 
922  /* See if the format string starts with the correct format
923  * specification. */
924  tmp = strstr(p, gint64_format);
925  if (tmp == NULL)
926  {
927  if (err_msg)
928  *err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
929  return NULL;
930  }
931  else if (tmp != p)
932  {
933  if (err_msg)
934  *err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
935  return NULL;
936  }
937 
938  /* Copy the string we have so far and add normalized format specifier for long int */
939  aux_str = g_strndup (base, p - base);
940  normalized_str = g_strconcat (aux_str, PRIi64, NULL);
941  g_free (aux_str);
942 
943  /* Skip length modifier / conversion specifier */
944  p += strlen(gint64_format);
945  tmp = p;
946 
947  /* Skip a suffix of any character except % */
948  while (*p)
949  {
950  /* Skip two adjacent percent marks, which are literal percent
951  * marks */
952  if (p[0] == '%' && p[1] == '%')
953  {
954  p += 2;
955  continue;
956  }
957  /* Break on a single percent mark, which is the start of the
958  * conversion specification */
959  if (*p == '%')
960  {
961  if (err_msg)
962  *err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
963  g_free (normalized_str);
964  return NULL;
965  }
966  /* Skip all other characters */
967  p++;
968  }
969 
970  /* Add the suffix to our normalized string */
971  aux_str = normalized_str;
972  normalized_str = g_strconcat (aux_str, tmp, NULL);
973  g_free (aux_str);
974 
975  /* If we end up here, the string was valid, so return no error
976  * message */
977  return normalized_str;
978 }

◆ qof_collection_insert_entity()

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 97 of file qofid.cpp.

98 {
99  const GncGUID *guid;
100 
101  if (!col || !ent) return;
102  guid = qof_instance_get_guid(ent);
103  if (guid_equal(guid, guid_null())) return;
104  g_return_if_fail (col->e_type == ent->e_type);
105  qof_collection_remove_entity (ent);
106  g_hash_table_insert (col->hash_of_entities, (gpointer)guid, ent);
107  qof_instance_set_collection(ent, col);
108 }
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition: guid.cpp:202
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition: guid.cpp:131
The type used to store guids in C.
Definition: guid.h:75

◆ qof_object_compliance()

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 182 of file qofobject.cpp.

183 {
184  const QofObject *obj;
185 
186  obj = qof_object_lookup(type_name);
187  if ((obj->create == NULL) || (obj->foreach == NULL))
188  {
189  if (warn)
190  {
191  PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
192  }
193  return FALSE;
194  }
195  return TRUE;
196 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:249
const QofObject * qof_object_lookup(QofIdTypeConst name)
Lookup an object definition.
Definition: qofobject.cpp:343