本文整理汇总了C++中CDbColSet类的典型用法代码示例。如果您正苦于以下问题:C++ CDbColSet类的具体用法?C++ CDbColSet怎么用?C++ CDbColSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CDbColSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CleanupClosePushL
/**
Creates the user added city database table if it doesn't exist
@return KErrNone if succesful, or one of the DBMS Leave codes
@internalTechnology
*/
TInt CTzLocalizationDbAccessor::CreateUserCityTableL()
{
//Create the columns for the user aded cities table
RArray<TDbCol> cityTableCols;
CleanupClosePushL(cityTableCols);
cityTableCols.AppendL(TDbCol(KUCTableTzId, EDbColUint16));
cityTableCols.AppendL(TDbCol(KUCTableCity, EDbColText));
cityTableCols.AppendL(TDbCol(KUCTableGroup, EDbColUint8));
cityTableCols.AppendL(TDbCol(KUCTableResourceId, EDbColUint32));
// Create the columnset - add the columns
// Columns MUST be added in the same order they appear in TTzCityColumn
CDbColSet* userCityColSet = CDbColSet::NewLC();
TInt numCols = cityTableCols.Count();
for(TInt i = 0; i < numCols; ++i)
{
userCityColSet->AddL(cityTableCols[i]);
}
// Create the User City table
TInt error = iLocalizedTimeZoneDb.CreateTable(KUCTableName,*userCityColSet);
CleanupStack::PopAndDestroy(userCityColSet);
CleanupStack::PopAndDestroy(); //cityTableCols
return error;
}
示例2: name
char* CAppConfig::LoadGameL(midend *aME, const game *aGame) {
TPtrC8 name((const TUint8*)aGame->name);
RDbTable table;
TDbSeekKey seekKey(name);
char *errmsg = "";
User::LeaveIfError(table.Open(iDb, KAutosaveTable, table.EReadOnly));
CleanupClosePushL(table);
User::LeaveIfError(table.SetIndex(KAutosaveIndex));
CDbColSet* colSet = table.ColSetL();
CleanupStack::PushL(colSet);
TInt saveColNo = colSet->ColNo(KAutosaveSaveCol);
if (table.SeekL(seekKey)) {
table.GetL();
RDbColReadStream stream;
stream.OpenLC(table,saveColNo);
errmsg = midend_deserialise(aME, read_game, &stream);
CleanupStack::PopAndDestroy(&stream);
}
CleanupStack::PopAndDestroy(colSet);
CleanupStack::PopAndDestroy(&table);
return errmsg;
}
示例3: InsertCategoryTableL
void InsertCategoryTableL()
{
RDbView view;
TInt err = view.Prepare(TheDatabase, _L("select * from CATEGORY"), view.EInsertOnly);
TEST2(err, KErrNone);
TheRowSet = view;
CDbColSet* colSet = TheRowSet.ColSetL();
const TInt KCategoryIdIdx = colSet->ColNo(KCategoryId);
const TInt KCategoryNameIdx = colSet->ColNo(KCategoryName);
const TInt KGenreIdx = colSet->ColNo(KGenre);
delete colSet;
err = TheDatabase.Begin();
TEST2(err, KErrNone);
for (TInt ii=1;ii<=KCategoryRecordCount;++ii)
{
TheRowSet.InsertL();
TheRowSet.SetColL(KCategoryIdIdx, ii);
TheRowSet.SetColL(KCategoryNameIdx, _L("History"));
TheRowSet.SetColL(KGenreIdx,(ii*500));
TheRowSet.PutL();
}
err = TheDatabase.Commit();
TEST2(err, KErrNone);
//err = TheDatabase.Compact();
//TEST2(err, KErrNone);
TheRowSet.Close();
}
示例4: exprBuilder
void CLogDuplicate::DoRunL()
{
RLogDynBuf expr;
TLogFilterExprBuilder exprBuilder(iDatabase);
exprBuilder.BuildExprLC(expr, *iFilterList, KLogAnd);
TheSql.Format(KLogSqlSelectDuplicateString, iRecentList, &expr.DesC(), iId);
CleanupStack::PopAndDestroy(&expr);
RLogDbView view;
view.PrepareLC(iDatabase.DTIDatabase(), TheSql);
if(view.FirstL())
{
// Begin a transaction
TBool inTransaction = iDatabase.DTIInTransaction();
if(!inTransaction)
{
iDatabase.DTIBeginWithRollBackProtectionLC();
}
// Get column ids
static TDbColNo idColNo = 0;
static TDbColNo duplicateColNo = 0;
if(idColNo == 0)
{
CDbColSet* cs = view.ColSetL();
idColNo = cs->ColNo(KLogFieldIdString);
duplicateColNo = cs->ColNo(KLogFieldEventDuplicateString);
delete cs;
}
// Iterate through the events
do
{
// Get current event id
view.GetL();
const TLogId id = view.ColInt32(idColNo);
// Set the latest recent?
if(iId < 0)
{
iId = id;
}
// Make the change
view.UpdateL();
iId == id ? view.SetColNullL(duplicateColNo) : view.SetColL(duplicateColNo, iId);
view.PutL();
// This is a "hidden" change. It may affect the contents of a view, but the actual event hasn't changed
iDatabase.DTIChangeInterface().DCISubmitChangedEventContextL(ELogChangeTypeEventChangedHidden, id);
}
while(view.NextL());
// Commit changes
if(!inTransaction)
{
iDatabase.DTICommitAndCancelRollbackProtectionL();
}
}
CleanupStack::PopAndDestroy(&view);
}
示例5: seekKey
void CAppConfig::GetConfigL(const TDesC &aKey, const TConfig &aConfig) {
RDbTable table;
TDbSeekKey seekKey(aKey);
User::LeaveIfError(table.Open(iDb, KConfigTable, table.EReadOnly));
CleanupClosePushL(table);
User::LeaveIfError(table.SetIndex(KConfigIndex));
CDbColSet* colSet = table.ColSetL();
CleanupStack::PushL(colSet);
TInt valueColNo = colSet->ColNo(KConfigValueCol);
if (table.SeekL(seekKey)) {
table.GetL();
TPtrC value = table.ColDes(valueColNo);
switch (aConfig.iType) {
case EConfigBool:
*aConfig.iValue.iBool = value.Compare(KBoolTrue) == 0 ? ETrue : EFalse;
break;
case EConfigInt: {
TLex lex(value);
TInt lvalue;
if (lex.Val(lvalue) == KErrNone) {
*aConfig.iValue.iInt = lvalue;
}
break;
}
case EConfigText:
if (aConfig.iValue.iText->MaxLength() > value.Length()) {
aConfig.iValue.iText->Copy(value.Left(aConfig.iValue.iText->MaxLength()));
} else {
aConfig.iValue.iText->Copy(value);
}
break;
case EConfigText8:
if (aConfig.iValue.iText8->MaxLength() > value.Length()) {
aConfig.iValue.iText8->Copy(value.Left(aConfig.iValue.iText8->MaxLength()));
} else {
aConfig.iValue.iText8->Copy(value);
}
break;
}
}
CleanupStack::PopAndDestroy(colSet);
CleanupStack::PopAndDestroy(&table);
}
示例6: AlterEventTblIfNoSimIdL
/**
Alters the "Event" table if the the table does not have "SimId" column.
@return KErrNone, The "alter" operation has completed successfully, system wide or database specific error code otherwise.
@leave KErrNoMemory, an out of memory condition has occurred;
Some other failure codes, not related to the "alter" opertaion.
*/
TInt CLogServDatabaseMarshall::AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet)
{//Compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined
const TDbCol* simIdCol = aEventTblColSet.Col(KLogFieldEventSimId);
TInt err = KErrNone;
if(!simIdCol)
{
TDbCol col(KLogFieldEventSimId, EDbColUint32);
aEventTblColSet.AddL(col);
err = iDatabase.AlterTable(KLogNameEventString, aEventTblColSet);
}
return err;
}
示例7: CreateTestTableL
//Creates a test table
static void CreateTestTableL(RDbNamedDatabase& aDb)
{
CDbColSet* colSet = CDbColSet::NewLC();
for(const TColDef* colDef=KColDefs;colDef->iName;++colDef)
{
TDbCol col(TPtrC(colDef->iName), colDef->iType);
col.iAttributes = colDef->iAttributes;
colSet->AddL(col);
}
TEST2(aDb.CreateTable(KTestTableName, *colSet), KErrNone);
CleanupStack::PopAndDestroy(colSet);
}
示例8: KDSCreateProfilesTable
void CNSmlDSSettings::CreateDatabaseL(const TDesC& aFullName)
{
// 50 is the extra length neede for integer lengths
HBufC* createProfileTable = HBufC::NewLC( KDSCreateProfilesTable().Length() + 50);
TPtr profileTablePtr = createProfileTable->Des();
profileTablePtr.Format(KDSCreateProfilesTable,KNSmlMaxProfileNameLength,KNSmlMaxUsernameLength,KNSmlMaxPasswordLength,KNSmlMaxURLLength,KNSmlMaxServerIdLength,KNSmlMaxHttpAuthUsernameLength,KNSmlMaxHttpAuthPasswordLength, KNSmlDSVisibilityArraySize );
// 25 is the extra length neede for integer lengths
HBufC* createAdaptersTable = HBufC::NewLC( KDSCreateAdaptersTable().Length() + 25);
TPtr adaptersTablePtr = createAdaptersTable->Des();
adaptersTablePtr.Format(KDSCreateAdaptersTable,KNSmlMaxAdapterDisplayNameLength,KNSmlMaxRemoteNameLength, KNSmlMaxLocalNameLength );
User::LeaveIfError( iDatabase.Create( this->iRdbSession, aFullName, KNSmlDBMSSecureSOSServerID ) );
iDatabase.Begin();
iDatabase.Execute( *createProfileTable );
iDatabase.Execute( *createAdaptersTable );
CDbColSet* colSet = CDbColSet::NewLC();
colSet->AddL(TDbCol(KNSmlVersionColumnMajor(), EDbColUint16));
colSet->AddL(TDbCol(KNSmlVersionColumnMinor(), EDbColUint16));
User::LeaveIfError(iDatabase.CreateTable(KNSmlTableVersion(), *colSet));
CleanupStack::PopAndDestroy( ); //colset
RDbTable table;
User::LeaveIfError(table.Open(iDatabase, KNSmlTableVersion()));
CleanupClosePushL(table);
colSet = table.ColSetL();
CleanupStack::PushL(colSet);
table.InsertL();
table.SetColL(colSet->ColNo(KNSmlVersionColumnMajor), KNSmlSettingsCurrentVersionMajor);
table.SetColL(colSet->ColNo(KNSmlVersionColumnMinor), KNSmlSettingsCurrentVersionMinor);
table.PutL();
iDatabase.Commit();
CreateHiddenProfilesL();
TInt keyVal;
TRAPD (err ,ReadRepositoryL(KNsmlDsCustomProfiles, keyVal));
if (err == KErrNone && keyVal)
{
TBool aRestore = EFalse;
CreateXMLProfilesL(aRestore);
}
iDatabase.Close();
CleanupStack::PopAndDestroy( 4 ); // createAdaptersTable, createProfileTable, colSet, table
}
示例9: switch
void CAppConfig::SetConfigL(const TDesC &aKey, const TConfig &aConfig) {
TBuf<KConfigValueMaxLength> value;
switch (aConfig.iType) {
case EConfigBool:
if (*aConfig.iValue.iBool) {
value.Copy(KBoolTrue);
} else {
value.Copy(KBoolFalse);
}
break;
case EConfigInt:
value.Num(*aConfig.iValue.iInt);
break;
case EConfigText:
value.Copy(*aConfig.iValue.iText);
break;
case EConfigText8:
value.Copy(*aConfig.iValue.iText8);
break;
}
RDbTable table;
TDbSeekKey seekKey(aKey);
User::LeaveIfError(table.Open(iDb, KConfigTable, table.EUpdatable));
CleanupClosePushL(table);
User::LeaveIfError(table.SetIndex(KConfigIndex));
CDbColSet* colSet = table.ColSetL();
CleanupStack::PushL(colSet);
TInt keyColNo = colSet->ColNo(KConfigKeyCol);
TInt valueColNo = colSet->ColNo(KConfigValueCol);
if (table.SeekL(seekKey)) {
table.GetL();
table.UpdateL();
table.SetColL(valueColNo, value);
} else {
table.InsertL();
table.SetColL(keyColNo, aKey);
table.SetColL(valueColNo, value);
}
table.PutL();
CleanupStack::PopAndDestroy(colSet);
CleanupStack::PopAndDestroy(&table);
}
示例10: 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);
}
}
示例11: 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];
}
示例12: ExtHintFieldExistsL
TBool ExtHintFieldExistsL(RFs& theFS)
{
TBool theResult;
RDbNamedDatabase theDatabase;
TestNoErrL(theDatabase.Open(theFS, KDatabaseFileName,KCntDbSecureFormat));
CDbColSet* theIdentitiTable = theDatabase.ColSetL(KIdentityTableName);
CleanupStack::PushL(theIdentitiTable);
const TDbCol* theExtHint = theIdentitiTable->Col(KContactExtHintField);
theResult = (theExtHint != NULL); //The field shouldn't exits
CleanupStack::PopAndDestroy(); //theIdentitiTable
theDatabase.Close();
return theResult;
}
示例13: while
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));
}
示例14: MakeColumnAutoIncremetingL
void CLogServDatabaseMarshall::MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn)
{
CDbColSet* newTable = iDatabase.ColSetL(aTable);
CleanupStack::PushL(newTable);
const TDbCol* oldCol = newTable->Col(aColumn);
__ASSERT_DEBUG(oldCol != NULL, Panic(ELogNoSuchColumn));
TDbCol newCol = *oldCol;
newCol.iAttributes |= TDbCol::EAutoIncrement;
newTable->Remove(aColumn);
newTable->AddL(newCol);
User::LeaveIfError(iDatabase.DropTable(aTable));
User::LeaveIfError(iDatabase.CreateTable(aTable, *newTable));
CleanupStack::PopAndDestroy(newTable);
}
示例15: while
//
// build a column set for the table
//
void CDbTableDatabase::CInterface::ColumnsL(CDbColSet& aColSet,const TDesC& aName)
{
TDbCol col;
const HDbColumnSet& set=Database().SchemaL().FindL(aName).Columns();
HDbColumnSet::TIteratorC iter=set.Begin();
const HDbColumnSet::TIteratorC end=set.End();
do
{
iter->AsTDbCol(col);
aColSet.AddL(col);
} while (++iter<end);
}