

#ifndef FIELD_CORE_H
#define FIELD_CORE_H  1

#include "FieldType.h"

#include "bool.h"
#include "darray.h"

typedef struct AlFieldCore_str *AlFieldCore;
 

#ifdef __STDC__ 
extern AlFieldCore AlFieldCore_create(const char *); 
   /* IN: takes as input the field type NAME (as a string) you wish 
          this FieldCore's field type to be. 
      RE: an initialized Field Core Object */

extern AlFieldCore AlFieldCore_create_with_obj(AlFieldType); 
   /* IN: takes as input the field type OBJECT you wish 
          this FieldCore's field type to be. 
      RE: an initialized Field Core Object */

extern void      AlFieldCore_delete(AlFieldCore);
  /* IN: an old FieldCore object to be deleted.
     DOES: This funtion DOES free the parsedData Field .  
           It also frees the key field so USE THE 
	   AlFieldCore_set_key() 
	   function (it makes copies)  */

extern void      AlFieldCore_destroy(AlFieldCore);
  /* IN: an old FieldCore object to be deleted.
     DOES: This funtion DOES free the parsedData Field .  
           It also frees the key field so USE THE 
	   AlFieldCore_set_key() 
	   function (it makes copies)  
     NOTE: duplicates the AlFieldCore_delete(..) function */

extern Bool      AlFieldCore_compare_with_field_op(AlFieldCore,
						   AlFieldCore,
						   FieldOperatorProc *);
  /* IN: tewo FieldCore objects to be compared by the operator specified by
         FieldOperatorProc function.
     DOES: This function will presumably be used by the Rule Runner to
           determine if two Field Cores 'match' according to the
	   oeprator (passed as the char *).  The operands will be
	   passed in order to the appropriate operator function for the
	   field types of the AlFieldCores.  Thus, lets say we had a
	   Float field type with a ">" operator, then the 'order
     	   of operation' as seen by the appropriate operator function
	   and as coded by the author of Run Rules would be
                    AlFieldCore1 > AlFieldCore2
	   thus in this example AlFieldCore1 would come from the Msg
	   Object and AlFieldCore2 from the Rule Object.
     RE: A Bool_TRUE if the two FieldCore objects are considered to 'match'
         according to the operator.   */

extern void      AlFieldCore_set_key(AlFieldCore,const char *);
  /* IN: a string, the key for the FieldCore.
     DOES: sets it. Makes a personal copy of it.
     RE: nothing.  */

extern const char *    AlFieldCore_get_key(AlFieldCore);
  /* IN: a FieldCore object
     RE: a string */

extern AlFieldCore AlFieldCore_duplicate(AlFieldCore); 
  /* IN: a FieldCore object 
     DOES: This Field DOES make a private copy of the key
           and fieldTypeName fields BUT it DOES NOT duplicate the parsedData
	   field--you must reparse the returned AlFieldCore with
	   AlFieldCore_parse(..) to make a complete copy
     RE: the duplicate. */

extern Bool       AlFieldCore_parse(AlFieldCore,const char *); 
  /* IN: a FieldCore object and a string to be parsed by it
     DOES: This function parses the string and puts it into the 
           AlFieldCore object  
     RE: Bool_FALSE if there was an error, Bool_TRUE ptherwise */

extern const char *     AlFieldCore_un_parse(AlFieldCore);
  /* IN: a FieldCore object 
     DOES: This function unparses the AlFieldCore object and returns a string.
     RE:  NULL if there was an error, a string otherwise */

extern Bool      AlFieldCore_equal(AlFieldCore,AlFieldCore);
  /* IN: two FieldCore objects
     DOES: sees if they are equivalent in 'nature' not in 'instance'.  That is
           it only checks to see if the two FieldCores have the same key and
	   the same Field Type, it DOES NOT CHECK the PARSED DATA, i.e. what
	   has been put into them by the AlFieldCore_parse(..) routine is
	   not conidered
     RE: Bool_TRUE if the two fields are the same, i.e. they have the same
         keys and they are of the same field type.  */

extern const char *    AlFieldCore_get_field_type_name(AlFieldCore);
  /* IN: a FieldCore object
     RE: the name of the FieldCore's FieldType as a string */

extern AlFieldType    AlFieldCore_get_field_type(AlFieldCore);
  /* IN: a FieldCore object
     RE: the FieldCore's FieldType as a FieldType object */
 
extern void           AlFieldCore_set_field_type(AlFieldCore,AlFieldType);
#else
extern AlFieldCore AlFieldCore_create();
extern AlFieldCore AlFieldCore_create_with_obj(); 
extern void      AlFieldCore_delete();
extern void      AlFieldCore_destroy();
extern void      AlFieldCore_set_key();
extern char *    AlFieldCore_get_key();
extern AlFieldCore AlFieldCore_duplicate();
extern Bool      AlFieldCore_parse();
extern char *    AlFieldCore_un_parse();
extern Bool      AlFieldCore_equal();
extern char *    AlFieldCore_get_field_type_name();
extern Bool      AlFieldCore_compare_with_field_op();
extern AlFieldType  AlFieldCore_get_field_type();
extern void           AlFieldCore_set_field_type();
#endif

#endif


