GnuCash  4.12-71-gadd45021a8+
Files | Data Structures | Macros | Functions

An address belongs to another object, determined by the GncOwner. More...


file  gncAddress.h
 an Address object

Data Structures

struct  GncAddress


#define GNC_ADDRESS_MODULE_NAME   "gncAddress"
#define GNC_TYPE_ADDRESS   (gnc_address_get_type ())
#define ADDRESS_NAME   "name"
#define ADDRESS_ONE   "number"
#define ADDRESS_TWO   "street"
#define ADDRESS_THREE   "locality"
#define ADDRESS_FOUR   "city"
#define ADDRESS_PHONE   "phone"
#define ADDRESS_FAX   "fax"
#define ADDRESS_EMAIL   "email"
#define ADDRESS_OWNER   "owner"


GType gnc_address_get_type (void)
gboolean gncAddressIsDirty (const GncAddress *addr)
int gncAddressCompare (const GncAddress *a, const GncAddress *b)
 compare two addresses More...
gboolean gncAddressEqual (const GncAddress *a, const GncAddress *b)
 Deeply compare two addresses. More...

Create/Destroy functions

GncAddressgncAddressCreate (QofBook *book, QofInstance *parent)
void gncAddressDestroy (GncAddress *addr)
void gncAddressBeginEdit (GncAddress *addr)
void gncAddressCommitEdit (GncAddress *addr)

Set functions

void gncAddressSetName (GncAddress *addr, const char *name)
void gncAddressSetAddr1 (GncAddress *addr, const char *addr1)
void gncAddressSetAddr2 (GncAddress *addr, const char *addr2)
void gncAddressSetAddr3 (GncAddress *addr, const char *addr3)
void gncAddressSetAddr4 (GncAddress *addr, const char *addr4)
void gncAddressSetPhone (GncAddress *addr, const char *phone)
void gncAddressSetFax (GncAddress *addr, const char *fax)
void gncAddressSetEmail (GncAddress *addr, const char *email)
void gncAddressClearDirty (GncAddress *address)

Get Functions

const char * gncAddressGetName (const GncAddress *addr)
const char * gncAddressGetAddr1 (const GncAddress *addr)
const char * gncAddressGetAddr2 (const GncAddress *addr)
const char * gncAddressGetAddr3 (const GncAddress *addr)
const char * gncAddressGetAddr4 (const GncAddress *addr)
const char * gncAddressGetPhone (const GncAddress *addr)
const char * gncAddressGetFax (const GncAddress *addr)
const char * gncAddressGetEmail (const GncAddress *addr)

Detailed Description

An address belongs to another object, determined by the GncOwner.

It is the owner that assigns a name and identifier to the address. In effect, an address is just a building - to make it useful to GnuCash, it needs to be tied to a person. After all, you cannot invoice a building, you invoice a person working / living in the building.

QOF needs to handle all objects generically and to tie the address to an owner, QOF must be able to find each - as entities.

This allows QOF to follow the hierarchy of objects without having to call any application-specific routines.

To achieve this, new GncAddress routines have been added. An address is now created with a NULL parent and the parent set explicitly using the QOF object declaration. Whilst this adds functionality, it is important that a valid GncOwner entity is always set as a parent. This is an API issue - QOF will always set the parent provided that a suitable entity is passed to the qofAddressSetOwner routine. It is up to you to pass a suitable entity.

Function Documentation

◆ gncAddressCompare()

int gncAddressCompare ( const GncAddress a,
const GncAddress b 

compare two addresses

0 if identical, -1 if a is empty or less than b and +1 if a is more than b or if b is empty.

Definition at line 567 of file gncAddress.c.

568 {
569  if (!a && !b) return 0;
570  if (!a && b) return 1;
571  if (a && !b) return -1;
573  return g_strcmp0 (a->name, b->name);
574 }

◆ gncAddressEqual()

gboolean gncAddressEqual ( const GncAddress a,
const GncAddress b 

Deeply compare two addresses.

TRUE if all fields match, FALSE otherwise

Definition at line 577 of file gncAddress.c.

578 {
579  if (a == NULL && b == NULL) return TRUE;
580  if (a == NULL || b == NULL) return FALSE;
582  g_return_val_if_fail(GNC_IS_ADDRESS(a), FALSE);
583  g_return_val_if_fail(GNC_IS_ADDRESS(b), FALSE);
585  if (g_strcmp0(a->name, b->name) != 0)
586  {
587  PWARN("names differ: %s vs %s", a->name, b->name);
588  return FALSE;
589  }
590  if (g_strcmp0(a->addr1, b->addr1) != 0)
591  {
592  PWARN("address lines 1 differ: %s vs %s", a->addr1, b->addr1);
593  return FALSE;
594  }
595  if (g_strcmp0(a->addr2, b->addr2) != 0)
596  {
597  PWARN("address lines 2 differ: %s vs %s", a->addr2, b->addr1);
598  return FALSE;
599  }
600  if (g_strcmp0(a->addr3, b->addr3) != 0)
601  {
602  PWARN("address lines 3 differ: %s vs %s", a->addr3, b->addr3);
603  return FALSE;
604  }
605  if (g_strcmp0(a->addr4, b->addr4) != 0)
606  {
607  PWARN("address lines 4 differ: %s vs %s", a->addr4, b->addr4);
608  return FALSE;
609  }
610  if (g_strcmp0(a->phone, b->phone) != 0)
611  {
612  PWARN("phone numbers differ: %s vs %s", a->phone, b->phone);
613  return FALSE;
614  }
615  if (g_strcmp0(a->fax, b->fax) != 0)
616  {
617  PWARN("fax numbers differ: %s vs %s", a->fax, b->fax);
618  return FALSE;
619  }
620  if (g_strcmp0(a->email, b->email) != 0)
621  {
622  PWARN("email addresses differ: %s vs %s", a->email, b->email);
623  return FALSE;
624  }
626  return TRUE;
627 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250