PROLOGIO for data file manipulation

The fact that the output is in Prolog syntax may be irrelevant for most programmers, who just need a reasonable I/O facility. Typical output looks like this:

diagram_definition(type = "Spirit Belief Network").

node_definition(type = "Model",
  image_type = "Diamond",
  attribute_for_label = "name",
  attribute_for_status_line = "label",
  colour = "CYAN",
  default_width = 120,
  default_height = 80,
  text_size = 10,
  can_resize = 1,
  has_hypertext_item = 1,
  attributes = ["name", "combining_function", "level_of_belief"]).

arc_definition(type = "Potentially Confirming",
  image_type = "Spline",
  arrow_type = "End",
  line_style = "Solid",
  width = 1,
  segmentable = 0,
  attribute_for_label = "label",
  attribute_for_status_line = "label",
  colour = "BLACK",
  text_size = 10,
  has_hypertext_item = 1,
  can_connect_to = ["Evidence", "Cluster", "Model", "Evidence", "Evidence", "Cluster"],
  can_connect_from = ["Data", "Evidence", "Cluster", "Evidence", "Data", "Cluster"]).
This is substantially easier to read and debug than a series of numbers and strings.

Note the object-oriented style: a file comprises a series of clauses. Each clause is an object with a functor or object name, followed by a list of attribute-value pairs enclosed in parentheses, and finished with a full stop. Each attribute value may be a string, a word (no quotes), an integer, a real number, or a list with potentially recursive elements.

The way that the facility is used by an application to read in a file is as follows:

  1. The application creates a PrologDatabase instance.
  2. The application tells the database to read in the entire file.
  3. The application searches the database for objects it requires, decomposing the objects using the PROLOGIO API. The database may be hashed, allowing rapid linking-up of application data.
  4. The application deletes or clears the PrologDatabase.

Writing a file is just as easy:

  1. The application creates a PrologDatabase instance.
  2. The application adds objects to the database using the API.
  3. The application tells the database to write out the entire database, in Prolog, LISP or CLIPS notation.
  4. The application deletes or clears the PrologDatabase.

To use the library, include "wx.h", "read.h" and link with libproio.a (UNIX) or prologio.lib (PC) and the wxWindows library.