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
 

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.
 

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

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

◆ 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:204
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
Definition: guid.cpp:130
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