GnuCash  4.8a-176-g88ecf8dd1
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 851 of file qofbook.cpp.

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

◆ 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