GnuCash  3.1-182-gd906ac4+
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 807 of file qofbook.cpp.

809 {
810  const gchar *conv_start, *base, *tmp = NULL;
811  gchar *normalized_str = NULL, *aux_str = NULL;
812 
813  /* Validate a counter format. This is a very simple "parser" that
814  * simply checks for a single gint64 conversion specification,
815  * allowing all modifiers and flags that printf(3) specifies (except
816  * for the * width and precision, which need an extra argument). */
817  base = p;
818 
819  /* Skip a prefix of any character except % */
820  while (*p)
821  {
822  /* Skip two adjacent percent marks, which are literal percent
823  * marks */
824  if (p[0] == '%' && p[1] == '%')
825  {
826  p += 2;
827  continue;
828  }
829  /* Break on a single percent mark, which is the start of the
830  * conversion specification */
831  if (*p == '%')
832  break;
833  /* Skip all other characters */
834  p++;
835  }
836 
837  if (!*p)
838  {
839  if (err_msg)
840  *err_msg = g_strdup("Format string ended without any conversion specification");
841  return NULL;
842  }
843 
844  /* Store the start of the conversion for error messages */
845  conv_start = p;
846 
847  /* Skip the % */
848  p++;
849 
850  /* See whether we have already reached the correct format
851  * specification (e.g. "li" on Unix, "I64i" on Windows). */
852  tmp = strstr(p, gint64_format);
853 
854  if (!tmp)
855  {
856  if (err_msg)
857  *err_msg = g_strdup_printf("Format string doesn't contain requested format specifier: %s", gint64_format);
858  return NULL;
859  }
860 
861  /* Skip any number of flag characters */
862  while (*p && (tmp != p) && strchr("#0- +'I", *p))
863  {
864  p++;
865  tmp = strstr(p, gint64_format);
866  }
867 
868  /* Skip any number of field width digits,
869  * and precision specifier digits (including the leading dot) */
870  while (*p && (tmp != p) && strchr("0123456789.", *p))
871  {
872  p++;
873  tmp = strstr(p, gint64_format);
874  }
875 
876  if (!*p)
877  {
878  if (err_msg)
879  *err_msg = g_strdup_printf("Format string ended during the conversion specification. Conversion seen so far: %s", conv_start);
880  return NULL;
881  }
882 
883  /* See if the format string starts with the correct format
884  * specification. */
885  tmp = strstr(p, gint64_format);
886  if (tmp == NULL)
887  {
888  if (err_msg)
889  *err_msg = g_strdup_printf("Invalid length modifier and/or conversion specifier ('%.4s'), it should be: %s", p, gint64_format);
890  return NULL;
891  }
892  else if (tmp != p)
893  {
894  if (err_msg)
895  *err_msg = g_strdup_printf("Garbage before length modifier and/or conversion specifier: '%*s'", (int)(tmp - p), p);
896  return NULL;
897  }
898 
899  /* Copy the string we have so far and add normalized format specifier for long int */
900  aux_str = g_strndup (base, p - base);
901  normalized_str = g_strconcat (aux_str, PRIi64, NULL);
902  g_free (aux_str);
903 
904  /* Skip length modifier / conversion specifier */
905  p += strlen(gint64_format);
906  tmp = p;
907 
908  /* Skip a suffix of any character except % */
909  while (*p)
910  {
911  /* Skip two adjacent percent marks, which are literal percent
912  * marks */
913  if (p[0] == '%' && p[1] == '%')
914  {
915  p += 2;
916  continue;
917  }
918  /* Break on a single percent mark, which is the start of the
919  * conversion specification */
920  if (*p == '%')
921  {
922  if (err_msg)
923  *err_msg = g_strdup_printf("Format string contains unescaped %% signs (or multiple conversion specifications) at '%s'", p);
924  g_free (normalized_str);
925  return NULL;
926  }
927  /* Skip all other characters */
928  p++;
929  }
930 
931  /* Add the suffix to our normalized string */
932  aux_str = normalized_str;
933  normalized_str = g_strconcat (aux_str, tmp, NULL);
934  g_free (aux_str);
935 
936  /* If we end up here, the string was valid, so return no error
937  * message */
938  return normalized_str;
939 }

◆ 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:204
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:254
const QofObject * qof_object_lookup(QofIdTypeConst name)
Lookup an object definition.
Definition: qofobject.cpp:343