本文整理汇总了C++中CDbColSet::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ CDbColSet::Count方法的具体用法?C++ CDbColSet::Count怎么用?C++ CDbColSet::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDbColSet
的用法示例。
在下文中一共展示了CDbColSet::Count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExternalizeL
GLDEF_C void ExternalizeL(const CDbColSet& aColSet,RWriteStream& aStream)
{
TInt cc=aColSet.Count();
aStream.WriteInt32L(cc);
for (TInt ii=0;++ii<=cc;)
aStream<<aColSet[ii];
}
示例2: CheckConfigTableL
void CAppConfig::CheckConfigTableL() {
CDbColSet *colSet = NULL;
TInt error;
TRAP(error, colSet = iDb.ColSetL(KConfigTable));
if (colSet != NULL) {
TBool drop =
colSet->Count() != 2
|| colSet->ColNo(KConfigKeyCol) == KDbNullColNo
|| colSet->ColNo(KConfigValueCol) == KDbNullColNo
;
delete colSet;
if (drop) {
User::LeaveIfError(iDb.DropTable(KConfigTable));
colSet = NULL;
}
}
if (colSet == NULL) {
// Specify columns for config table
TDbCol keyCol(KConfigKeyCol, EDbColText, KConfigKeyMaxLength);
TDbCol valueCol(KConfigValueCol, EDbColText, KConfigValueMaxLength);
keyCol.iAttributes = TDbCol::ENotNull;
valueCol.iAttributes = TDbCol::ENotNull;
// Add the columns to column set
colSet = CDbColSet::NewLC();
colSet->AddL(keyCol);
colSet->AddL(valueCol);
// Create the Books table
User::LeaveIfError(iDb.CreateTable(KConfigTable, *colSet));
CleanupStack::PopAndDestroy(colSet);
}
CDbKey *idx = NULL;
TRAP(error, idx = iDb.KeyL(KConfigIndex, KConfigTable));
if (idx != NULL) {
if (!idx->IsUnique()) {
iDb.DropIndex(KConfigIndex, KConfigTable);
delete idx;
idx = NULL;
} else {
delete idx;
}
}
if (idx == NULL) {
TDbKeyCol keyCol(KConfigKeyCol);
idx = CDbKey::NewLC();
idx->MakeUnique();
idx->AddL(keyCol);
User::LeaveIfError(iDb.CreateIndex(KConfigIndex, KConfigTable, *idx));
CleanupStack::PopAndDestroy(idx);
}
}
示例3: if
void CDbTableDatabase::CAlterTable::ConstructL(const CDbColSet& aNewDef,TInt& aStep)
//
// get all the deleted columns
// check changes to columns still present
// get all the new columns
// construct a new columns set based on the changes
//
{
//
// flag all columns as dropped initially
HDbColumnSet& columns=iDef.Columns();
HDbColumnSet::TIterator iter=columns.Begin();
HDbColumnSet::TIteratorC const end=columns.End();
do
{
iter->iFlags=TDbColumnDef::EDropped;
} while (++iter<end);
//
// look for additions and changes
CDbColSet* change=CDbColSet::NewLC();
CDbColSet* add=CDbColSet::NewLC();
for (TDbColSetIter iterNew(aNewDef);iterNew;++iterNew)
{
const TDbCol& col=*iterNew;
TDbColumnDef* def=columns.ColumnL(iterNew->iName);
if (!def) // a new column
add->AddL(col);
else
{ // see if the definition has changed
if (def->iAttributes!=col.iAttributes)
__LEAVE(KErrArgument); // can't change attributes
TUint8 flag=0;
if (def->iType!=col.iType)
flag=TDbColumnDef::EChangedType;
else if (def->iType>=EDbColText8 && col.iMaxLength!=KDbUndefinedLength && col.iMaxLength!=def->iMaxLength)
flag=TDbColumnDef::EChangedLen;
def->iFlags=flag;
if (flag)
change->AddL(col); // column has changed
}
}
//
// check that all marked columns are not indexed
//
iter=columns.Begin();
do
{
if (iter->iFlags && iDef.IsIndexed(*iter->iName))
__LEAVE(KErrArgument); // can't remove indexed column
} while (++iter<end);
//
iNewSet=HDbColumnSet::NewL(aNewDef.Count());
iDef.AlteredColumnSetL(*iNewSet,*change,*add);
CleanupStack::PopAndDestroy(2); // add, change
Construct(Database().TableAlterL(iDef,*iNewSet,aStep));
}
示例4: InternalizeL
GLDEF_C void InternalizeL(CDbColSet& aColSet,RReadStream& aStream)
{
__ASSERT(aColSet.Count()==0);
TDbCol col;
TPtr name(col.iName.Des());
TInt cc=aStream.ReadInt32L();
while (--cc>=0)
{
aStream>>name;
col.iType=TDbColType(aStream.ReadUint8L());
col.iMaxLength=aStream.ReadInt32L();
col.iAttributes=aStream.ReadUint8L();
aColSet.AddL(col);
}
}
示例5: OutputTableColHeadingsToFileLC
/**
Outputs table header for the tables created in the html file
The header contains the column names
@param aTableIndex table index in the table array
*/
CDesCArray* CDbDbmsDumper::OutputTableColHeadingsToFileLC(TInt aTableIndex)
{
CDesCArraySeg* colNames = new (ELeave) CDesCArraySeg(8);
CleanupStack::PushL(colNames);
CDbColSet* colSet = iDatabase.ColSetL( (*iTableNames)[aTableIndex] );
CleanupStack::PushL(colSet);
const TInt KMaxCols( (colSet->Count() ) );
TInt counter = 0;
iFile.Write(KHdRow);
// cols are from 1, to maxCols. not from 0 to maxCols-1.
for (counter = 1; counter <= KMaxCols; ++counter)
{
iFile.Write(KCell);
iBuffer->Des().Copy( (*colSet)[counter].iName );
colNames->AppendL((*colSet)[counter].iName);
iFile.Write(*iBuffer);
iFile.Write(KCellEnd);
}
iFile.Write(KRowEnd);
CleanupStack::PopAndDestroy(colSet);
return colNames;
}
示例6: CheckAutosaveTableL
void CAppConfig::CheckAutosaveTableL() {
CDbColSet *colSet = NULL;
TInt error;
TRAP(error, colSet = iDb.ColSetL(KAutosaveTable));
if (colSet != NULL) {
TBool drop =
colSet->Count() != 3
|| colSet->ColNo(KAutosaveNameCol) == KDbNullColNo
|| colSet->ColNo(KAutosaveSaveCol) == KDbNullColNo
|| colSet->ColNo(KAutosaveDateCol) == KDbNullColNo
;
delete colSet;
if (drop) {
User::LeaveIfError(iDb.DropTable(KAutosaveTable));
colSet = NULL;
}
}
if (colSet == NULL) {
// Specify columns for config table
TDbCol nameCol(KAutosaveNameCol, EDbColText8, KAutosaveNameMaxLength);
TDbCol saveCol(KAutosaveSaveCol, EDbColLongText8);
TDbCol dateCol(KAutosaveDateCol, EDbColDateTime);
nameCol.iAttributes = TDbCol::ENotNull;
saveCol.iAttributes = TDbCol::ENotNull;
dateCol.iAttributes = TDbCol::ENotNull;
// Add the columns to column set
colSet = CDbColSet::NewLC();
colSet->AddL(nameCol);
colSet->AddL(saveCol);
colSet->AddL(dateCol);
// Create the Books table
TInt _err = iDb.CreateTable(KAutosaveTable, *colSet);
User::LeaveIfError(_err);
CleanupStack::PopAndDestroy(colSet);
}
CDbKey *idx = NULL;
TRAP(error, idx = iDb.KeyL(KAutosaveIndex, KAutosaveTable));
if (idx != NULL) {
if (!idx->IsUnique()) {
iDb.DropIndex(KAutosaveIndex, KAutosaveTable);
delete idx;
idx = NULL;
} else {
delete idx;
}
}
if (idx == NULL) {
TDbKeyCol keyCol(KAutosaveNameCol);
idx = CDbKey::NewLC();
idx->MakeUnique();
idx->AddL(keyCol);
User::LeaveIfError(iDb.CreateIndex(KAutosaveIndex, KAutosaveTable, *idx));
CleanupStack::PopAndDestroy(idx);
}
}
示例7: TblCallTestL
static void TblCallTestL()
{
TheTest.Next(_L("Open()"));
TInt err = TheTbl1.Open(TheDb1, KTableName1);
TEST2(err, KErrNone);
TheTest.Next(_L("ColSetL()"));
CDbColSet* colset = TheTbl1.ColSetL();
TInt cnt = colset->Count();
TInt i;
for(i=0;i<cnt;++i)
{
const TDbCol& dbc = (*colset)[i + 1];
TheTest.Printf(_L("%02d, %S\n"), i + 1, &dbc.iName);
}
delete colset;
TheTest.Next(_L("ColDef()"));
TDbCol dbcol = TheTbl1.ColDef(1);
TheTest.Printf(_L("%S\n"), &dbcol.iName);
TheTest.Next(_L("InsertL()/SetColL()/PutL()"));
TheTbl1.InsertL();
TheTbl1.SetColL(2, 1);
TheTbl1.SetColL(3, 2);
TheTbl1.PutL();
TheTbl1.InsertL();
TheTbl1.SetColL(2, 3);
TheTbl1.SetColL(3, 4);
TheTbl1.PutL();
TheTest.Next(_L("AtRow()/AtBeginning()/AtEnd()"));
(void)TheTbl1.AtRow();
(void)TheTbl1.AtBeginning();
(void)TheTbl1.AtEnd();
TheTest.Next(_L("BeginningL()/EndL()"));
TheTbl1.BeginningL();
TheTbl1.EndL();
TheTest.Next(_L("FirstL()/LastL()/PreviousL()/PreviousL()"));
TBool res = TheTbl1.FirstL();
TEST(res);
TheTbl1.GetL();
TInt32 val1 = TheTbl1.ColInt32(1);
TInt32 val2 = TheTbl1.ColInt32(2);
TInt32 val3 = TheTbl1.ColInt32(3);
TEST(val1 == 0);
TEST(val2 == 1);
TEST(val3 == 2);
res = TheTbl1.LastL();
TEST(res);
TheTbl1.GetL();
val1 = TheTbl1.ColInt32(1);
val2 = TheTbl1.ColInt32(2);
val3 = TheTbl1.ColInt32(3);
TEST(val1 == 1);
TEST(val2 == 3);
TEST(val3 == 4);
res = TheTbl1.PreviousL();
TEST(res);
TheTbl1.GetL();
val1 = TheTbl1.ColInt32(1);
val2 = TheTbl1.ColInt32(2);
val3 = TheTbl1.ColInt32(3);
TEST(val1 == 0);
TEST(val2 == 1);
TEST(val3 == 2);
res = TheTbl1.NextL();
TEST(res);
TheTbl1.GetL();
val1 = TheTbl1.ColInt32(1);
val2 = TheTbl1.ColInt32(2);
val3 = TheTbl1.ColInt32(3);
TEST(val1 == 1);
TEST(val2 == 3);
TEST(val3 == 4);
TheTest.Next(_L("UpdateL()"));
TheTbl1.UpdateL();
TheTbl1.SetColL(2, 33);
TheTbl1.SetColL(3, 44);
TheTbl1.PutL();
TheTest.Next(_L("Cancel()"));
TheTbl1.UpdateL();
TheTbl1.SetColL(2, 36);
TheTbl1.SetColL(3, 47);
TheTbl1.Cancel();
TheTest.Next(_L("DeleteL()"));
TheTbl1.DeleteL();
TheTest.Next(_L("IsColNull()"));
CDbColSet* colset2 = TDBSCUtils::CreateColSetLC(KColumns2);
_LIT(KTempTblName, "TempTbl");
err = TheDb1.CreateTable(KTempTblName, *colset2);
//.........这里部分代码省略.........