📄 tdataasciiinterp.c
字号:
/*
========================================================================
DEVise Data Visualization Software
(c) Copyright 1992-1996
By the DEVise Development Group
Madison, Wisconsin
All Rights Reserved.
========================================================================
Under no circumstances is this software to be copied, distributed,
or altered in any way without prior permission from the DEVise
Development Group.
*/
/*
$Id: TDataAsciiInterp.c,v 1.24 1996/11/01 19:28:23 kmurli Exp $
$Log: TDataAsciiInterp.c,v $
Revision 1.24 1996/11/01 19:28:23 kmurli
Added DQL sources to include access to TDataDQL. This is equivalent to
TDataAscii/TDataBinary. The DQL type in the Tcl/Tk corresponds to this
class.
Revision 1.23 1996/10/07 22:54:00 wenger
Added more error checking and better error messages in response to
some of the problems uncovered by CS 737 students.
Revision 1.22 1996/10/02 15:23:51 wenger
Improved error handling (modified a number of places in the code to use
the DevError class).
Revision 1.21 1996/07/21 02:23:23 jussi
Added code that deletes allocated string space if string not
inserted into string hash table.
Revision 1.20 1996/07/15 17:02:06 jussi
Added support for string attributes in GData.
Revision 1.19 1996/07/01 19:28:07 jussi
Added support for typed data sources (WWW and UNIXFILE). Renamed
'cache' references to 'index' (cache file is really an index).
Added support for asynchronous interface to data sources.
Revision 1.18 1996/06/27 18:12:40 wenger
Re-integrated most of the attribute projection code (most importantly,
all of the TData code) into the main code base (reduced the number of
modules used only in attribute projection).
Revision 1.17 1996/06/27 15:49:32 jussi
TDataAscii and TDataBinary now recognize when a file has been deleted,
shrunk, or has increased in size. The query processor is asked to
re-issue relevant queries when such events occur.
Revision 1.16 1996/05/11 03:14:40 jussi
Made this code independent of some control panel variables like
_fileAlias and _fileName.
Revision 1.15 1996/05/07 16:46:00 jussi
This class now makes a copy of the attribute list so that attribute
hi/lo values can be maintained per data stream, not per schema.
Hi/lo values are now computed after composite parser is executed.
Revision 1.14 1996/05/05 03:07:33 jussi
Removed array of pointers to attribute info for matching values.
Revision 1.13 1996/04/23 15:40:45 jussi
Added debugging statements and allowed decoder to accept integer
values with +/- prefixes.
Revision 1.12 1996/04/19 17:21:21 wenger
Put the GenClassInfo code back in -- this is needed for tape data;
started adding the tape-related code back in (it was previously
deleted for some reason; I'm not yet done adding it back); added
the 'DEVise parseSchema' command and the first parts of the code
related to it.
Revision 1.11 1996/04/16 20:38:51 jussi
Replaced assert() calls with DOASSERT macro.
Revision 1.10 1996/03/29 18:14:20 wenger
Got testWindowRep to compile and run, added drawing in
windows; fixed a few more compile warnings, etc.
Revision 1.9 1996/03/26 21:33:00 jussi
Added computation of max/min attribute values.
Revision 1.8 1996/02/01 18:28:59 jussi
Improved handling of case where data file has more attributes
than schema defined.
Revision 1.7 1996/01/26 19:45:57 jussi
Improved checking of data record validity.
Revision 1.6 1995/12/28 19:48:13 jussi
Small fixes to remove compiler warnings.
Revision 1.5 1995/11/22 17:51:01 jussi
Added missing DoubleAttr case in Decode().
Revision 1.4 1995/11/22 17:04:14 jussi
Added IsValid() method and cleaned up the code.
Revision 1.3 1995/11/21 23:20:49 jussi
Added copyright notice and cleaned up code.
Revision 1.2 1995/09/05 22:15:51 jussi
Added CVS header.
*/
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include "TDataAsciiInterp.h"
#include "AttrList.h"
#include "RecInterp.h"
#include "CompositeParser.h"
#include "Parse.h"
#include "Control.h"
#include "Util.h"
#include "DevError.h"
#ifndef ATTRPROJ
# include "StringStorage.h"
#endif
//#define DEBUG
#ifndef ATTRPROJ
TDataAsciiInterpClassInfo::TDataAsciiInterpClassInfo(char *className,
AttrList *attrList,
int recSize,
char *separators,
int numSeparators,
Boolean isSeparator,
char *commentString)
{
/* Note that this only saves a pointer to the attrList; it doesn't copy it. */
_className = className;
_attrList = attrList;
_separators = separators;
_numSeparators = numSeparators;
_commentString = commentString;
_recSize = recSize;
_isSeparator = isSeparator;
_tdata = NULL;
}
TDataAsciiInterpClassInfo::TDataAsciiInterpClassInfo(char *className,
char *name, char *type, char *param,
TData *tdata)
{
_className = className;
_name = name;
_type = type;
_param = param;
_tdata = tdata;
}
TDataAsciiInterpClassInfo::~TDataAsciiInterpClassInfo()
{
if (_tdata)
delete _tdata;
}
char *TDataAsciiInterpClassInfo::ClassName()
{
return _className;
}
static char buf[3][256];
static char *args[3];
void TDataAsciiInterpClassInfo::ParamNames(int &argc, char **&argv)
{
argc = 3;
argv = args;
args[0] = buf[0];
args[1] = buf[1];
args[2] = buf[2];
strcpy(buf[0], "Name {foobar}");
strcpy(buf[1], "Type {foobar}");
strcpy(buf[2], "Param {foobar}");
}
ClassInfo *TDataAsciiInterpClassInfo::CreateWithParams(int argc, char **argv)
{
if (argc != 2 && argc != 3)
return (ClassInfo *)NULL;
char *name, *type, *param;
if (argc == 2) {
name = CopyString(argv[1]);
type = CopyString("UNIXFILE");
param = CopyString(argv[0]);
} else {
name = CopyString(argv[0]);
type = CopyString(argv[1]);
param = CopyString(argv[2]);
}
TDataAsciiInterp *tdata = new TDataAsciiInterp(name, type,
param, _recSize,
_attrList, _separators,
_numSeparators,
_isSeparator,
_commentString);
return new TDataAsciiInterpClassInfo(_className, name, type, param, tdata);
}
char *TDataAsciiInterpClassInfo::InstanceName()
{
return _name;
}
void *TDataAsciiInterpClassInfo::GetInstance()
{
return _tdata;
}
/* Get parameters that can be used to re-create this instance */
void TDataAsciiInterpClassInfo::CreateParams(int &argc, char **&argv)
{
argc = 3;
argv = args;
args[0] = _name;
args[1] = _type;
args[2] = _param;
}
#endif
TDataAsciiInterp::TDataAsciiInterp(char *name, char *type,
char *param, int recSize,
AttrList *attrs, char *separators,
int numSeparators, Boolean isSeparator,
char *commentString) :
TDataAscii(name, type, param, recSize), _attrList(*attrs)
{
#ifdef DEBUG
printf("TDataAsciiInterp %s, recSize %d\n", name, recSize);
#endif
_recInterp = new RecInterp();
_recInterp->SetAttrs(attrs);
_recSize = recSize;
_separators = separators;
_numSeparators = numSeparators;
_isSeparator = isSeparator;
_commentString = commentString;
if (_commentString)
_commentStringLength = strlen(_commentString);
_numAttrs = _numPhysAttrs = _attrList.NumAttrs();
hasComposite = false;
_attrList.InitIterator();
while(_attrList.More()) {
AttrInfo *info = _attrList.Next();
if (info->isComposite) {
hasComposite = true;
_numPhysAttrs--;
}
}
_attrList.DoneIterator();
Initialize();
}
TDataAsciiInterp::~TDataAsciiInterp()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -