GnuCash  4.901
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 774 of file qofbook.cpp.

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

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

96 {
97  const GncGUID *guid;
98 
99  if (!col || !ent) return;
100  guid = qof_instance_get_guid(ent);
101  if (guid_equal(guid, guid_null())) return;
102  g_return_if_fail (col->e_type == ent->e_type);
103  qof_collection_remove_entity (ent);
104  g_hash_table_insert (col->hash_of_entities, (gpointer)guid, ent);
105  qof_instance_set_collection(ent, col);
106 }
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:201
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition: guid.cpp:128
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 167 of file qofobject.cpp.

168 {
169  const QofObject *obj;
170 
171  obj = qof_object_lookup(type_name);
172  if ((obj->create == NULL) || (obj->foreach == NULL))
173  {
174  if (warn)
175  {
176  PINFO (" Object type %s is not fully QOF compliant", obj->e_type);
177  }
178  return FALSE;
179  }
180  return TRUE;
181 }
#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:328