The project is to develop a package that implements a structure called a "Property List." A property list is a list of elements, each of which consists of a name, a type, and a value. Within a property list, the same name may occur multiple times, but each name-type combination must be unique. The operations defined for a property list include insert, which adds an element to the list, delete, which removes an element from the list, and getValue, which retrieves a value given a name and type.
Homework 5a is to implement the first part of an interactive program that allows a user to insert entries into a property list. Homework 5b is to implement the property list package itself.
Here is an example of the execution of this program (named plist in this example):
qcunix1> plist Enter name or command: vickery Enter type of value: int Enter integer value: 100 Integer insert: vickery 100 Insert succeeded Enter name or command: vickery Enter type of value: float Enter float value: 3.14159 Float insert: vickery 3.14159 Insert succeeded Enter name or command: exit qcunix1>For this part of the assignment, I am providing you with an object module named
plist.o
which contains the code for a set of
functions named insert(), one for each of the recognized data
types. I am also providing you with a header file named
plist.h
that contains function prototypes for the
insert() functions and a definition for an enum
called types.
In the sample output above, the messages that start "Integer insert"
and "Float insert" were output by the code in plist.o
and
all other messages were output by main().
To do this part of the project, create a project directory, change to
it, and copy all the files from ~vickery/CS-200/Homework_5
into it:
qcunix1> cp ~vickery/CS-200/Homework_5/* .You will get one
.o
file, one .h
file, and a
Makefile
. If you name your own program file
main.cc
, all you need to do to build an executable program
named plist
is to type "gmake" (no arguments needed).You can type "gmake clean" to delete unneeded files from the project directory before you submit it.
#include "plist.h
" statement
in your main.cc
file, and your calls to insert()
must match the prototypes given in plist.h
. This means
that you must use the enum for types
that I provided. Look
in plist.h
to see how this was set up. (Tuesday students:
I changed the names of the enum values from "INT," etc. as given in
class to "T_INT," etc.)
^C
to abort the program!). Optional: display
a list of valid type names if the user enters something invalid, maybe
like this:
qcunix1> plist Enter name or command: vickery Enter type of value: garbage Valid types are int, long, char, float, double, Enter type of value: int Enter integer value: 100 Integer insert: vickery 100 Insert succeeded Enter name or command: exit qcunix1>
^C
if
your program goes into that endless loop, by the way.