本文整理汇总了C++中Row::AddVal方法的典型用法代码示例。如果您正苦于以下问题:C++ Row::AddVal方法的具体用法?C++ Row::AddVal怎么用?C++ Row::AddVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Row
的用法示例。
在下文中一共展示了Row::AddVal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _CmdIROW
int UserClient::_CmdIROW( OmniPacket *packet )
{
int errCode = ERROR_OK;
char ret[BUFLEN];
char param[NODELEN];
PARSE_TAG_INIT( packet->mHeader );
PARSE_TAG_NEXT( packet->mHeader, param );
gLog.log("Insert Row timeout %s", param );
Row row;
char *buf = packet->mBody;
char *next;
char colname[BUFLEN];
char colvalue[BUFLEN];
if( mTable == NULL )
{
errCode = ERROR_NOT_SELECT_TABLE;
sprintf( ret, "IROW %lu %d 0\r\n", packet->mTrid, errCode );
WritePacket( ret, strlen(ret) );
return errCode;
}
while( true )
{
bzero( ret, BUFLEN );
next = strstr( buf, "\r\n" );
if( next == NULL )
break;
if( (next-buf) >= BUFLEN )
break;
if( (next-buf) < 0 )
break;
sscanf( buf, "%s %s", colname, colvalue );
gLog.log("[%s] [%s]", colname, colvalue );
row.AddVal( colname, colvalue );
buf = next+2;
}
mTable->AddRow( &row, atoi(param) );
Table::Dump();
sprintf( ret, "IROW %lu %d 0\r\n", packet->mTrid, errCode );
WritePacket( ret, strlen(ret) );
return errCode;
}
示例2: test_std
int test_std()
{
Table *tab1, *tab2;
ColumnInfo colinfo;
Row row;
// create table1
colinfo.Clear();
colinfo.AddColumn("col1",1,1);
colinfo.AddColumn("col2",2,2);
colinfo.AddColumn("col3",4,5);
tab1 = Table::CreateTable("table1", &colinfo);
colinfo.Clear();
row.AddVal("col1", "1");
row.AddVal("col2", "12");
row.AddVal("col3", "432");
tab1->AddRow( &row );
row.Clear();
row.AddVal("col1", "2");
row.AddVal("col2", "23");
row.AddVal("col3", "234");
tab1->AddRow( &row );
// create table2
colinfo.AddColumn("col2-1",1,2);
colinfo.AddColumn("col2-2",4,5);
tab2 = Table::CreateTable("table2", &colinfo);
colinfo.Clear();
row.Clear();
row.AddVal("col2-1", "1");
row.AddVal("col2-2", "45");
tab2->AddRow( &row );
row.Clear();
row.AddVal("col2-1", "2");
row.AddVal("col2-2", "56");
tab2->AddRow( &row );
Table::Dump();
// get row
assert( !strcmp(tab1->GetRow( "1", "col1" ), "1" ) );
assert( !strcmp(tab1->GetRow( "1", "col2" ), "12" ) );
assert( !strcmp(tab1->GetRow( "1", "col3" ), "432" ) );
assert( !strcmp(tab1->GetRow( "2", "col2" ), "23" ) );
assert( !strcmp(tab1->GetRow( "2", "col3" ), "234" ) );
assert( !strcmp(tab2->GetRow( "1", "col2-2" ), "45" ) );
assert( !strcmp(tab2->GetRow( "2", "col2-2" ), "56" ) );
// update row
tab1->UpdateRow( "1", "col3", "456" );
assert( !strcmp(tab1->GetRow( "1", "col3" ), "456" ) );
// del row
tab1->DelRow( "2" );
Table::Dump();
Table::DeleteTable("table1");
Table::DeleteTable("table2");
return 0;
}