GnuCash  3.7-134-g71bdcdfa6+
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 850 of file qofbook.cpp.

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

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