GnuCash  2.6.99
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 571 of file gncAddress.c.

572 {
573  if (!a && !b) return 0;
574  if (!a && b) return 1;
575  if (a && !b) return -1;
577  return g_strcmp0 (a->name, b->name);
578 }

◆ gncAddressEqual()

gboolean gncAddressEqual ( const GncAddress a,
const GncAddress b 

Deeply compare two addresses.

TRUE if all fields match, FALSE otherwise

Definition at line 581 of file gncAddress.c.

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