本文整理汇总了C++中Tuple::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Tuple::length方法的具体用法?C++ Tuple::length怎么用?C++ Tuple::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tuple
的用法示例。
在下文中一共展示了Tuple::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Insert
int Insert(Tuple &tuple)
{
int i,j;
int offtest;
char *values;
int dp;
int ip;
char *t;
int compi;
float compf;
bool flag;
string comps;
char *target = new char[1];
int comi;
float comf;
values = Convertvalue(tuple);
values[tuple.length()]='1';
values[tuple.length()+1]=0;
string file_name = tuple.table_name + "_table.rec";
int offset = Block_num(file_name)-1;
if(offset<0)
{
Block* newblock = mybuffer.GetBlock(file_name,0,1);
memcpy(newblock->record,values,(tuple.length()+1));
delete[] values;
delete target;
return 0;
}
else
{
Block* Target;
for(i=0;i<tuple.attr_count;i++)
{
if(tuple.attrs[i].attr_key_type==UNIQUE)
{
ip=0;
for(j=0;j<i;j++)
{
ip+=tuple.attrs[j].attr_len;
}
for(offtest = 0;offtest<=offset;offtest++)
{
Target = mybuffer.GetBlock(file_name,offtest,0);
for(dp=0;dp<BlockSize-tuple.length()-1;dp+=tuple.length()+1)
{
memcpy(target,Target->record+dp+tuple.length(),1);
if(*target=='1')
{
if(tuple.attrs[i].attr_type==CHAR)
{
t = new char[tuple.attrs[i].attr_len+1];
memcpy(t,Target->record+dp+ip,tuple.attrs[i].attr_len);
t[tuple.attrs[i].attr_len]='\0';
comps=t;
if(comps==tuple.attr_values[i])
{
flag = true;
break;
}
delete t;
}
if(tuple.attrs[i].attr_type==INT)
{
memcpy(&compi,Target->record+dp+ip,4);
comi=atoi(tuple.attr_values[i].c_str());
if(compi==comi)
{
flag = true;
break;
}
}
if(tuple.attrs[i].attr_type==FLOAT)
{
memcpy(&compf,Target->record+dp+ip,4);
comf=atof(tuple.attr_values[i].c_str());
if(compf==comf)
{
flag = true;
break;
}
}
}
}
if(flag == true)
break;
}
if(flag == true)
break;
}
}
if(flag != true)
{
Target = mybuffer.GetBlock(file_name,offset,0);
for(i=tuple.length();i<BlockSize;i+=tuple.length()+1)
{
if(Target->record[i] == 0)
break;
}
//.........这里部分代码省略.........