completed fixes for the aitString and fixed string management
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.4 1996/08/22 21:05:38 jbk
|
||||
// More fixes to make strings and fixed string work better.
|
||||
//
|
||||
// Revision 1.3 1996/08/09 02:28:08 jbk
|
||||
// rewrite of aitString class - more intuitive now, I think
|
||||
//
|
||||
@@ -55,15 +58,17 @@ aitIndex aitString::compact(aitString* array, aitIndex arraySize,
|
||||
// copy the array first
|
||||
pos=sizeof(aitString)*arraySize;
|
||||
if(bufSize<pos) return 0;
|
||||
memcpy(ptr,(char*)array,pos);
|
||||
|
||||
for(i=0;i<arraySize;i++) str[i].init();
|
||||
|
||||
for(i=0;i<arraySize;i++)
|
||||
{
|
||||
if(str[i].string())
|
||||
if((pos+str[i].length())>bufSize) break; // quick exit from loop
|
||||
if(array[i].string())
|
||||
{
|
||||
memcpy(&ptr[pos],str[i].string(),str[i].length()+1); // include NULL
|
||||
str[i].init();
|
||||
str[i]=&ptr[pos];
|
||||
memcpy(&ptr[pos],array[i].string(),array[i].length()+1);
|
||||
str[i].force(&ptr[pos]);
|
||||
str[i].len=array[i].length();
|
||||
pos+=str[i].length()+1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.12 1996/08/22 21:05:43 jbk
|
||||
// More fixes to make strings and fixed string work better.
|
||||
//
|
||||
// Revision 1.11 1996/08/14 12:30:12 jbk
|
||||
// fixes for converting aitString to aitInt8* and back
|
||||
// fixes for managing the units field for the dbr types
|
||||
@@ -900,18 +903,33 @@ static gdd* mapGraphicEnumToGdd(void* v, aitIndex /*count*/)
|
||||
gdd& menu = dd[gddAppTypeIndex_dbr_gr_enum_enums];
|
||||
aitFixedString* str = menu;
|
||||
aitFixedString* f = (aitFixedString*)db->strs;
|
||||
aitIndex sz,i;
|
||||
|
||||
// int i;
|
||||
// old way using aitString menu
|
||||
// for(i=0;i<db->no_str;i++) str[i]=((const char*)&(db->strs[i][0]));
|
||||
|
||||
menu.putRef(f);
|
||||
menu.setBound(0,0,db->no_str);
|
||||
vdd.setStatSevr(db->status,db->severity);
|
||||
if(menu.dataPointer()==NULL || !menu.isAtomic())
|
||||
{
|
||||
// need to copy the menu chunk from dbr to aitFixedString chunk
|
||||
menu.setDimension(1);
|
||||
sz=db->no_str;
|
||||
str=new aitFixedString[db->no_str];
|
||||
menu.putRef(str,new gddDestructor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if((sz=menu.getDataSizeElements())>db->no_str)
|
||||
sz=db->no_str;
|
||||
}
|
||||
|
||||
for(i=0;i<sz;i++) strcpy(str[i].fixed_string,&(db->strs[i][0]));
|
||||
menu.setBound(0,0,sz);
|
||||
|
||||
// should always be a scaler
|
||||
if(vdd.dimension()) vdd.clear();
|
||||
vdd=db->value;
|
||||
vdd.setStatSevr(db->status,db->severity);
|
||||
return dd;
|
||||
}
|
||||
|
||||
@@ -923,18 +941,33 @@ static gdd* mapControlEnumToGdd(void* v, aitIndex /*count*/)
|
||||
gdd& vdd = dd[gddAppTypeIndex_dbr_ctrl_enum_value];
|
||||
aitFixedString* str = menu;
|
||||
aitFixedString* f = (aitFixedString*)db->strs;
|
||||
aitIndex sz,i;
|
||||
|
||||
// int i;
|
||||
// old way using aitString menu
|
||||
// for(i=0;i<db->no_str;i++) str[i]=((const char*)&(db->strs[i][0]));
|
||||
|
||||
menu.putRef(f);
|
||||
menu.setBound(0,0,db->no_str);
|
||||
vdd.setStatSevr(db->status,db->severity);
|
||||
if(menu.dataPointer()==NULL || !menu.isAtomic())
|
||||
{
|
||||
// need to copy the menu chunk from dbr to aitFixedString chunk
|
||||
menu.setDimension(1);
|
||||
sz=db->no_str;
|
||||
str=new aitFixedString[db->no_str];
|
||||
menu.putRef(str,new gddDestructor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if((sz=menu.getDataSizeElements())>db->no_str)
|
||||
sz=db->no_str;
|
||||
}
|
||||
|
||||
for(i=0;i<sz;i++) strcpy(str[i].fixed_string,&(db->strs[i][0]));
|
||||
menu.setBound(0,0,sz);
|
||||
|
||||
// should always be a scaler
|
||||
if(vdd.dimension()) vdd.clear();
|
||||
vdd=db->value;
|
||||
vdd.setStatSevr(db->status,db->severity);
|
||||
return dd;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
// $Id$
|
||||
//
|
||||
// $Log$
|
||||
// Revision 1.9 1996/08/22 21:05:40 jbk
|
||||
// More fixes to make strings and fixed string work better.
|
||||
//
|
||||
// Revision 1.8 1996/08/14 12:30:14 jbk
|
||||
// fixes for converting aitString to aitInt8* and back
|
||||
// fixes for managing the units field for the dbr types
|
||||
@@ -621,7 +624,6 @@ size_t gdd::flattenWithAddress(void* buf, size_t size, aitIndex* total_dd)
|
||||
// not very good way to do it, size info bad
|
||||
aitString* str = (aitString*)dataPointer();
|
||||
aitString::compact(str,getDataSizeElements(),&bnds[i],size);
|
||||
str->forceConstant();
|
||||
}
|
||||
else
|
||||
memcpy(&bnds[i],dataPointer(),getDataSizeBytes());
|
||||
@@ -689,7 +691,6 @@ gddStatus gdd::flattenData(gdd* dd, int tot_dds, void* buf,size_t size)
|
||||
aitString* str = (aitString*)dd[i].dataPointer();
|
||||
sz=aitString::compact(str,
|
||||
dd[i].getDataSizeElements(),ptr,size);
|
||||
str->forceConstant();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user