COGCatDataFile
NAME

COGCatDataFile

FILES

COGCatDataFile.h

COGCatDataFile.cpp

DESCRIPTION

COGCatDataFile is a internal file representation for typical category learning experiments. The COGCatDataFile will create a easy-to-manipulate representation of the abstract structure of a category learning experiment. This data structure is usually coupled with an COGCatEnvFile which defines knowledge about each dimension (see that documentation for more information). Both of these file-types are coupled in a single datastructure called COGCatInputFiles (see that documentation for more information).

COGCatDataFile, thus, very simply defines a specific type of data in memory (namely the abstract structure of a category learning experiment.

AUTHOR

Todd M. Gureckis (gureckis@love.psy.utexas.edu)

LAST MODIFIED DATE

Jan. 31, 2002

LICENSE

GNU General Public License

PUBLIC METHODS

COGParser()
    Default object constructor.


~COGParser()
    Default object constructor.


void Load (const char *filename)
    Overloaded Load() function. Given a filename of a disk file will open and parse the file. Using this Load() function will ignore any lines or partial lines that begin with the '#' character.


void Load (const char *filename, char comment)
    Overloaded Load() function. Given a filename of a disk file will open and parse the file. This is the real Load() function which allows you to define your own comment character (ex. '%', '#', '!', etc...)


int Set (const char *name, char *value)
    This will set a variable called "name" to "value".


const char *GetAsCharStar (char *name)
    Returns a C-type string (NULL terminated) with the value corresponding to "name".


int GetAsInt (char *name)
    Returns a integer containing the value corresponding to "name". If your configuration file has a value other than int as the value of "name" then the return value is undefined.


double GetAsDouble (char *name)
    Returns a double containing the value corresponding to "name". If your configuration file has a value other than double as the value of "name" then the return value is undefined.


int IsSet (char *name)
    Returns TRUE if a variable called "name" has been set, otherwise returns FALSE.


int Clear (char *name)
    Will clear the value of "name".


int ClearAll (void)
    Will clear the value of all variables in the parser object.


int PrintAll (void)
    Prints the value of all variable in the parser object to stdout.


Examples

If you had a file called myparser.dat in your home directory that contained the following:
% here is a path and shows how symbolic references work 
% (the style is similar to makefile's)
mypath = /home/gureckis/models/are/cool
mypathbin = $(mypath)/bin

% it will work if you make references to things 
% that are defined later in the file too like this:

fun = $(temp)
temp = 45.67

%
%above is some whitespace and here are more comments
%

% more variable names and symbolic references
t = 1
g = $(t)
somevarname = 4.567345

Then the following code demonstrates how to use the COGParser to access the data in your program
#include "COGGeneral.h"
#include "COGParser.h"


int 
main(int argc, char **argv) 
{
    COGParser myparser;

	// load file
	myparser.Load("/home/gureckis/myparser.dat", '%');
	
	
	// verify that "t" is set correctly
	assert(myparser.GetAsInt("t") == 1);
	
	// verify that "somevarname" is correct
	assert(myparser.GetAsDouble("somevarname") == 4.567345);
	
	// verify that the reference expanded from "g" to "t"
	assert(myparser.GetAsInt("g") == 1);
	
	// output the strings
	cout << myparser.GetAsCharStar("mypath") << endl;
	cout << myparser.GetAsCharStar("mypathbin") << endl;
	cout << myparser.GetAsDouble("fun") << endl;
	cout << myparser.GetAsDouble("temp") << endl;

}