Modified to store records with a visibility option for graphic editors.
The ".db" file now generates "grecord" for visible records and "record" for invisible records.
This commit is contained in:
@@ -111,6 +111,7 @@ typedef struct dbRecordNode {
|
||||
ELLNODE node;
|
||||
void *precord;
|
||||
char *recordname;
|
||||
int visible;
|
||||
}dbRecordNode;
|
||||
|
||||
typedef struct dbRecordType {
|
||||
|
||||
@@ -26,6 +26,7 @@ static int yyreset(void)
|
||||
"driver" {return(tokenDRIVER);}
|
||||
"breaktable" {return(tokenBREAKTABLE);}
|
||||
"record" {return(tokenRECORD);}
|
||||
"grecord" {return(tokenGRECORD);}
|
||||
|
||||
[0-9]+ { /*integer number*/
|
||||
yylval.Str = (char *)malloc(strlen(yytext)+1);
|
||||
|
||||
@@ -68,7 +68,7 @@ static void dbBreakHead(char *name);
|
||||
static void dbBreakItem(char *value);
|
||||
static void dbBreakBody(void);
|
||||
|
||||
static void dbRecordHead(char *recordType,char*name);
|
||||
static void dbRecordHead(char *recordType,char*name,int visible);
|
||||
static void dbRecordField(char *name,char *value);
|
||||
static void dbRecordBody(void);
|
||||
|
||||
@@ -835,7 +835,7 @@ static void dbBreakBody(void)
|
||||
if(!pbrkTable) ellAdd(&pdbbase->bptList,&pnewbrkTable->node);
|
||||
}
|
||||
|
||||
static void dbRecordHead(char *recordType,char *name)
|
||||
static void dbRecordHead(char *recordType,char *name, int visible)
|
||||
{
|
||||
DBENTRY *pdbentry;
|
||||
long status;
|
||||
@@ -852,6 +852,7 @@ static void dbRecordHead(char *recordType,char *name)
|
||||
}
|
||||
/*Duplicate records ok. Thus dont check return status.*/
|
||||
dbCreateRecord(pdbentry,name);
|
||||
if(visible) dbVisibleRecord(pdbentry);
|
||||
free((void *)recordType);
|
||||
free((void *)name);
|
||||
}
|
||||
|
||||
@@ -777,8 +777,12 @@ long dbWriteRecordFP(DBBASE *pdbbase,FILE *fp,char *precordTypename,int level)
|
||||
while(!status) {
|
||||
status = dbFirstRecord(pdbentry);
|
||||
while(!status) {
|
||||
fprintf(fp,"record(%s,\"%s\") {\n",
|
||||
dbGetRecordTypeName(pdbentry),dbGetRecordName(pdbentry));
|
||||
if(dbIsVisibleRecord(pdbentry))
|
||||
fprintf(fp,"grecord(%s,\"%s\") {\n",
|
||||
dbGetRecordTypeName(pdbentry),dbGetRecordName(pdbentry));
|
||||
else
|
||||
fprintf(fp,"record(%s,\"%s\") {\n",
|
||||
dbGetRecordTypeName(pdbentry),dbGetRecordName(pdbentry));
|
||||
status = dbFirstField(pdbentry,dctonly);
|
||||
while(!status) {
|
||||
if(!dbIsDefaultValue(pdbentry) || level>0) {
|
||||
@@ -1408,6 +1412,29 @@ long dbRenameRecord(DBENTRY *pdbentry,char *newName)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long dbVisibleRecord(DBENTRY *pdbentry)
|
||||
{
|
||||
dbRecordNode *precnode = pdbentry->precnode;
|
||||
if(!precnode) return(S_dbLib_recNotFound);
|
||||
precnode->visible=1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long dbInvisibleRecord(DBENTRY *pdbentry)
|
||||
{
|
||||
dbRecordNode *precnode = pdbentry->precnode;
|
||||
if(!precnode) return(S_dbLib_recNotFound);
|
||||
precnode->visible=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dbIsVisibleRecord(DBENTRY *pdbentry)
|
||||
{
|
||||
dbRecordNode *precnode = pdbentry->precnode;
|
||||
if(!precnode) return 0;
|
||||
return precnode->visible?1:0;
|
||||
}
|
||||
|
||||
long dbCopyRecord(DBENTRY *pdbentry,char *newRecordName,int overWriteOK)
|
||||
{
|
||||
dbRecordType *precordType = pdbentry->precordType;
|
||||
|
||||
@@ -142,6 +142,10 @@ char *dbGetRecordName(DBENTRY *pdbentry);
|
||||
long dbRenameRecord(DBENTRY *pdbentry,char *newName);
|
||||
long dbCopyRecord(DBENTRY *pdbentry,char *newRecordName,int overWriteOK);
|
||||
|
||||
long dbVisibleRecord(DBENTRY *pdbentry);
|
||||
long dbInvisibleRecord(DBENTRY *pdbentry);
|
||||
int dbIsVisibleRecord(DBENTRY *pdbentry);
|
||||
|
||||
long dbFindField(DBENTRY *pdbentry,char *pfieldName);
|
||||
int dbFoundField(DBENTRY *pdbentry);
|
||||
char *dbGetString(DBENTRY *pdbentry);
|
||||
|
||||
@@ -13,7 +13,7 @@ static char *menuString = "menu";
|
||||
%token tokenINCLUDE tokenPATH tokenADDPATH
|
||||
%token tokenMENU tokenCHOICE tokenRECORDTYPE tokenFIELD
|
||||
%token tokenDEVICE tokenDRIVER tokenBREAKTABLE
|
||||
%token tokenRECORD
|
||||
%token tokenRECORD tokenGRECORD
|
||||
%token <Str> tokenSTRING
|
||||
|
||||
%union
|
||||
@@ -34,6 +34,7 @@ database_item: include
|
||||
| driver
|
||||
| tokenBREAKTABLE break_head break_body
|
||||
| tokenRECORD record_head record_body
|
||||
| tokenGRECORD grecord_head record_body
|
||||
;
|
||||
|
||||
include: tokenINCLUDE tokenSTRING
|
||||
@@ -157,10 +158,16 @@ break_item: tokenSTRING
|
||||
};
|
||||
|
||||
|
||||
grecord_head: '(' tokenSTRING ',' tokenSTRING ')'
|
||||
{
|
||||
if(dbStaticDebug>2) printf("grecord_head %s %s\n",$2,$4);
|
||||
dbRecordHead($2,$4,1);
|
||||
};
|
||||
|
||||
record_head: '(' tokenSTRING ',' tokenSTRING ')'
|
||||
{
|
||||
if(dbStaticDebug>2) printf("record_head %s %s\n",$2,$4);
|
||||
dbRecordHead($2,$4);
|
||||
dbRecordHead($2,$4,0);
|
||||
};
|
||||
|
||||
record_body: /*Null*/
|
||||
|
||||
Reference in New Issue
Block a user