GnuCash  4.12-74-g36b33262ad+
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 853 of file qofbook.cpp.

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

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

99 {
100  const GncGUID *guid;
101 
102  if (!col || !ent) return;
103  guid = qof_instance_get_guid(ent);
104  if (guid_equal(guid, guid_null())) return;
105  g_return_if_fail (col->e_type == ent->e_type);
106  qof_collection_remove_entity (ent);
107  g_hash_table_insert (col->hash_of_entities, (gpointer)guid, ent);
108  qof_instance_set_collection(ent, col);
109 }
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 179 of file qofobject.cpp.

180 {
181  const QofObject *obj;
182 
183  obj = qof_object_lookup(type_name);
184  if ((obj->create == NULL) || (obj->foreach == NULL))
185  {
186  if (warn)
187  {
188  PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
189  }
190  return FALSE;
191  }
192  return TRUE;
193 }
#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:340