GnuCash  5.6-150-g038405b370+
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
 
struct  QofBook
 QofBook reference. More...
 
struct  QofBookTestFunctions
 

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

QofBookTestFunctions_utest_qofbook_fill_functions (void)
 
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.
 

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.

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 785 of file qofbook.cpp.

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

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

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