当前位置: 首页>>代码示例>>C++>>正文


C++ FLTableMetaData类代码示例

本文整理汇总了C++中FLTableMetaData的典型用法代码示例。如果您正苦于以下问题:C++ FLTableMetaData类的具体用法?C++ FLTableMetaData怎么用?C++ FLTableMetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FLTableMetaData类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setFromObject

void FLAccessControlTable::setFromObject(QObject *obj)
{
  FLTableMetaData *tm = ::qt_cast<FLTableMetaData *>(obj);
  if (!tm)
    return;

  if (acosPerms_) {
    acosPerms_->clear();
    delete acosPerms_;
  }

  acosPerms_ = new QDict < QString >(31);
  acosPerms_->setAutoDelete(true);

  const FLTableMetaData::FLFieldMetaDataList *fL = tm->fieldList();
  if (!fL)
    return;

  FLFieldMetaData *field;
  QChar permR, permW;
  QDictIterator<FLFieldMetaData> it(*fL);

  while ((field = it.current()) != 0) {
    ++it;
    permR = '-';
    permW = '-';
    if (field->visible())
      permR = 'r';
    if (field->editable())
      permW = 'w';
    acosPerms_->replace(field->name(), new QString(QString(permR) + permW));
  }
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:33,代码来源:FLAccessControlFactory.cpp

示例2: str_ret

QString FLManagerModules::contentStaticDir( const QString & n ) {
  QString str_ret( contentFS( staticDirFiles_ + "/" + n ) );

  if ( !str_ret.isEmpty() ) {

    QString sha( FLUtil::sha1( str_ret ) );
    QString * s = 0;
    if ( dictKeyFiles && ( s = ( *dictKeyFiles )[ n ] ) && *s == sha )
      return QString::null;
    else if ( dictKeyFiles && n.endsWith( ".qs" ) )
      dictKeyFiles->replace( n, new QString( sha ) );

    if ( n.endsWith( ".mtd" ) ) {
      FLTableMetaData * mtd;
      QDomDocument doc( n );
      QDomElement docElem;

      if ( FLUtil::domDocumentSetContent( doc, str_ret ) ) {
        FLManager * mgr = db_->manager();
        docElem = doc.documentElement();
        mtd = mgr->metadata( &docElem, true );

        if ( !mtd || mtd->isQuery() )
          return str_ret;

        if ( !mgr->existsTable( mtd->name() ) )
          mgr->createTable( mtd );
        else if ( db_->canRegenTables() )
          db_->regenTable( mtd->name(), mtd );
      }
    }
  }

  return str_ret;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:35,代码来源:FLManagerModules.cpp

示例3: idx

QSqlIndex SqliteDriver::primaryIndex(const QString &tablename) const
{
  QSqlIndex idx(tablename);
  if (!isOpen() || !dataBase_)
    return idx;
  QDomDocument doc(tablename);
  QDomElement docElem;
  QString stream = db_->managerModules()->contentCached(tablename + ".mtd");
  if (!FLUtil::domDocumentSetContent(doc, stream)) {
#ifdef FL_DEBUG
    qWarning("FLManager : " + QApplication::tr("Error al cargar los metadatos para la tabla %1").arg(tablename));
#endif

    return primaryIndex2(tablename);
  }
  docElem = doc.documentElement();
  FLTableMetaData *mtd = db_->manager()->metadata(&docElem, true);
  if (!mtd)
    return primaryIndex2(tablename);
  idx.append(QSqlField(mtd->primaryKey(), FLFieldMetaData::flDecodeType(mtd->fieldType(mtd->primaryKey()))));
  idx.setName(tablename.lower() + "_pkey");

  delete mtd;
  return idx;
}
开发者ID:gestiweb,项目名称:eneboo,代码行数:25,代码来源:qsqlite.cpp

示例4: formatAssignValue

QString FLManager::formatAssignValue(FLFieldMetaData *fMD, const QVariant &v, const bool upper)
{
  if (!fMD)
    return "1 = 1";

  FLTableMetaData *mtd = fMD->metadata();
  QString fieldName(fMD->name());

  if (mtd && mtd->isQuery()) {
    QString prefixTable(mtd->name());
    FLSqlQuery *qry = query(mtd->query());

    if (qry) {
      QStringList fL(qry->fieldList());

      for (QStringList::Iterator it = fL.begin(); it != fL.end(); ++it) {
        prefixTable = (*it).section('.', 0, 0);
        if ((*it).section('.', 1, 1) == fieldName)
          break;
      }

      qry->deleteLater();
    }

    fieldName.prepend(prefixTable + ".");
  }

  return formatAssignValue(fieldName, fMD->type(), v, upper);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: QVariant

QVariant FLUtil::nextCounter( const QString & name, FLSqlCursor * cursor_ ) {
  if ( !cursor_ )
    return QVariant();

  FLTableMetaData *tMD = cursor_->metadata();

  if ( !tMD )
    return QVariant();

  FLFieldMetaData *field = tMD->field( name );

  if ( !field )
    return QVariant();

  int type = field->type();

  if ( type != QVariant::String && type != QVariant::Double )
    return QVariant();

  unsigned int len = field->length();
  QString cadena;

  FLSqlQuery q( 0, cursor_->db()->connectionName() );
  q.setForwardOnly( true );
  q.setTablesList( tMD->name() );
  q.setSelect( name );
  q.setFrom( tMD->name() );
  q.setWhere( "LENGTH(" + name + ")=" + QString::number( len ) );
  q.setOrderBy( name + " DESC" );

  if ( !q.exec() )
    return QVariant();

  double maxRange = pow( 10, len );
  double numero = maxRange;

  while ( numero >= maxRange ) {
    if ( !q.next() ) {
      numero = 1;
      break;
    }
    numero = q.value( 0 ).toDouble();
    numero++;
  }

  if ( type == QVariant::String ) {
    cadena = QString::number( numero, 'f', 0 );
    if ( cadena.length() < len ) {
      QString str;
      str.fill( '0', ( len - cadena.length() ) );
      cadena = str + cadena;
    }
    return QVariant( cadena );
  }

  if ( type == QVariant::Double )
    return QVariant( numero );

  return QVariant();
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:60,代码来源:FLUtil.cpp

示例6: roundFieldValue

QString FLUtil::roundFieldValue(const QVariant &n, const QString &table, const QString &field)
{
  FLTableMetaData *tmd = FLSqlConnections::database()->manager()->metadata(table);
  if (!tmd)
    return 0;
  FLFieldMetaData *fmd = tmd->field(field);
  if (!fmd)
    return 0;
  return buildNumber(n, 'f', fmd->partDecimal());
}
开发者ID:afibanez,项目名称:eneboo,代码行数:10,代码来源:FLUtil.cpp

示例7:

FLTableMetaData::FLFieldMetaDataList * FLSqlQuery::fieldMetaDataList() {
  if ( !d->fieldMetaDataList_ ) {
    d->fieldMetaDataList_ = new FLTableMetaData::FLFieldMetaDataList( 31 );
    d->fieldMetaDataList_->setAutoDelete( true );
    QString table, field;
    for ( QStringList::Iterator it = d->fieldList_.begin(); it != d->fieldList_.end(); ++it ) {
      table = ( *it ).section( '.', 0, 0 );
      field = ( *it ).section( '.', 1, 1 );
      FLTableMetaData * mtd = d->db_->manager()->metadata( table, true );
      d->fieldMetaDataList_->insert( field.lower(), mtd->field( field ) );
    }
  }

  return d->fieldMetaDataList_;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:15,代码来源:FLSqlQuery.cpp

示例8: metadata

FLTableMetaData *FLManager::createTable(const QString &n)
{
  FLTableMetaData *tmd = metadata(n);
#ifndef FL_QUICK_CLIENT
  if (!tmd)
    return 0;
  if (existsTable(tmd->name())) {
    listTables_->append(n);
    return tmd;
  }
  return createTable(tmd);
#else
  return tmd;
#endif
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例9: c

QStringList FLUtil::nombreCampos( const QString & tabla ) {
  QStringList res;

  if ( FLSqlConnections::database()->managerModules()->shaOfFile( tabla + ".mtd" ).isEmpty() )
    return res;

  FLSqlCursor c( tabla );
  FLTableMetaData * tmd = c.metadata();
  if ( !tmd )
    return res;

  res = QStringList::split( ",", tmd->fieldsNames() );
  res.prepend( QString::number( res.size() ) );

  return res;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:16,代码来源:FLUtil.cpp

示例10: doc

QSqlRecordInfo SqliteDriver::recordInfo(const QString &tablename) const
{
  QSqlRecordInfo info;
  if (!isOpen() || !dataBase_)
    return info;
  QDomDocument doc(tablename);
  QDomElement docElem;
  QString stream = db_->managerModules()->contentCached(tablename + ".mtd");
  if (!FLUtil::domDocumentSetContent(doc, stream)) {
#ifdef FL_DEBUG
    qWarning("FLManager : " + QApplication::tr("Error al cargar los metadatos para la tabla %1").arg(tablename));
#endif

    return recordInfo2(tablename);
  }
  docElem = doc.documentElement();
  FLTableMetaData *mtd = db_->manager()->metadata(&docElem, true);
  if (!mtd)
    return recordInfo2(tablename);
  FLTableMetaData::FLFieldMetaDataList *fl = mtd->fieldList();
  if (!fl) {
    delete mtd;
    return recordInfo2(tablename);
  }
  if (fl->isEmpty()) {
    delete mtd;
    return recordInfo2(tablename);
  }

  QStringList fieldsNames = QStringList::split(",", mtd->fieldsNames());
  for (QStringList::Iterator it = fieldsNames.begin(); it != fieldsNames.end(); ++it) {
    FLFieldMetaData *field = mtd->field((*it));
    info.append(QSqlFieldInfo(field->name(), FLFieldMetaData::flDecodeType(field->type())));
  }

  delete mtd;
  return info;
}
开发者ID:gestiweb,项目名称:eneboo,代码行数:38,代码来源:qsqlite.cpp

示例11: setSelect

void FLSqlQuery::setSelect( const QString & s ) {
  d->select_ = s.stripWhiteSpace();
  d->select_ = d->select_.simplifyWhiteSpace();

  QStringList fieldListAux;
  fieldListAux = QStringList::split( ',', s );
  for ( QStringList::Iterator it = fieldListAux.begin(); it != fieldListAux.end(); ++it )
    ( *it ) = ( *it ).stripWhiteSpace();

  QString table, field;
  d->fieldList_.clear();
  for ( QStringList::Iterator it = fieldListAux.begin(); it != fieldListAux.end(); ++it ) {
    table = ( *it ).section( '.', 0, 0 );
    field = ( *it ).section( '.', 1, 1 );
    if ( field == "*" ) {
      FLTableMetaData * mtd = d->db_->manager()->metadata( table, true );
      if ( mtd )
        d->fieldList_ += QStringList::split( ',', mtd->fieldList( true ) );
    } else
      d->fieldList_.append( *it );
  }

  d->select_ = d->fieldList_.join( "," );
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:24,代码来源:FLSqlQuery.cpp

示例12: if

void FLAccessControlTable::processObject(QObject *obj)
{
  if (!obj || obj->aqWasDeleted())
    return;
  FLTableMetaData *tm = ::qt_cast<FLTableMetaData *>(obj);
  if (!tm)
    return;

  int maskPerm = 0;
  bool hasAcos = (acosPerms_ && !acosPerms_->isEmpty());

  if (!perm_.isEmpty()) {
    if (perm_.left(1) == "r")
      maskPerm |= 2;
    if (perm_.right(1) == "w")
      maskPerm |= 1;
  } else if (hasAcos)
    maskPerm = 8;
  else
    return;

  QString fieldPerm;
  QString *fieldPermPtr;
  int maskFieldPerm = 0;

  const FLTableMetaData::FLFieldMetaDataList *fL = tm->fieldList();
  if (!fL)
    return ;

  FLFieldMetaData *field;
  QDictIterator<FLFieldMetaData> it(*fL);

  while ((field = it.current()) != 0) {
    maskFieldPerm = maskPerm;
    ++it;

    if (hasAcos && (fieldPermPtr = (*acosPerms_)[ field->name()])) {
      fieldPerm = *fieldPermPtr;
      maskFieldPerm = 0;

      if (fieldPerm.left(1) == "r")
        maskFieldPerm |= 2;
      if (fieldPerm.right(1) == "w")
        maskFieldPerm |= 1;
    }

    switch (maskFieldPerm) {
      case 0:
        field->setVisible(false);
        field->setEditable(false);
        break;
      case 1:
        field->setVisible(false);
        field->setEditable(true);
        break;
      case 2:
        field->setVisible(true);
        field->setEditable(false);
        break;
      case 3:
        field->setVisible(true);
        field->setEditable(true);
        break;
    }
  }
}
开发者ID:Miguel-J,项目名称:eneboo-core,代码行数:66,代码来源:FLAccessControlFactory.cpp

示例13: doc

FLTableMetaData *FLManager::metadata(const QString &n, bool quick)
{
  if (n.isEmpty() || !db_->dbAux())
    return 0;

  FLTableMetaData *ret = 0;
  QDomDocument doc(n);
  QDomElement docElem;

  QString key;
  QString *dictKey = 0;
  QString stream = db_->managerModules()->contentCached(n + QString::fromLatin1(".mtd"), &key);
  bool newTable = false;
  bool notSysTable = n.left(3) != "sys" && !isSystemTable(n);

  if (!notSysTable)
    dictKey = new QString(n);

#ifndef FL_QUICK_CLIENT
  if (!quick) {
    if (db_->canRegenTables() && notSysTable) {
      QSqlRecord *buffer = 0;
      QString key2;
      delete dictKey;
      dictKey = dictKeyMetaData_->find(n);
      if (dictKey)
        key2 = *dictKey;
      if (key2.isEmpty()) {
        QSqlCursor c("flmetadata", true, db_->dbAux());
        c.setForwardOnly(true);
        c.setFilter(QString::fromLatin1("tabla='") + n + QString::fromLatin1("'"));
        c.select();
        if (c.next()) {
          c.primeDelete();
          c.del();
        }
        buffer = c.primeInsert();
        buffer->setValue("tabla", n);
        if (key.isEmpty()) {
          buffer->setValue("xml", stream);
          dictKey = new QString(stream);
          dictKeyMetaData_->replace(n, dictKey);
        } else {
          buffer->setValue("xml", key);
          dictKey = new QString(key);
          dictKeyMetaData_->replace(n, dictKey);
        }
        newTable = true;
        c.insert();
      } else {
        if (key != key2) {
          QString s;
          if (key2.left(255).find("<!DOCTYPE TMD>", 0, true) == -1)
            AQ_DISKCACHE_FIND(key2, s);
          else
            s = key2;
          bool mustAlter;
          if (key.isEmpty())
            mustAlter = !checkMetaData(s, stream);
          else
            mustAlter = (key != key2);
          if (mustAlter) {
            if (alterTable(s, stream, key2)) {
              QSqlCursor c("flmetadata", true, db_->dbAux());
              c.setForwardOnly(true);
              c.setFilter(QString::fromLatin1("tabla='") + n + QString::fromLatin1("'"));
              c.select();
              c.next();
              buffer = c.primeUpdate();
              if (key.isEmpty()) {
                buffer->setValue("xml", stream);
                dictKey = new QString(stream);
                dictKeyMetaData_->replace(n, dictKey);
              } else {
                buffer->setValue("xml", key);
                dictKey = new QString(key);
                dictKeyMetaData_->replace(n, dictKey);
              }
              c.update();
            }
          }
        }
      }
    }
  } else {
    if (key.isEmpty())
      dictKey = new QString(n);
    else
      dictKey = new QString(key);
  }
#else
  if (key.isEmpty())
    dictKey = new QString(n);
  else
    dictKey = new QString(key);
#endif //FL_QUICK_CLIENT
  if (dictKey) {
    if (cacheMetaData_ && notSysTable) {
      ret = cacheMetaData_->find(*dictKey);
    } else if (cacheMetaDataSys_ && !notSysTable) {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例14: while

FLTableMetaData *FLManager::metadata(QDomElement *mtd, bool quick)
{
  if (!mtd)
    return 0;

  QString name, a, q;
  bool v = true, ed = true, cw = true, dl = false;

  QDomNode no = mtd->firstChild();

  while (!no.isNull()) {
    QDomElement e = no.toElement();
    if (!e.isNull()) {
      if (e.tagName() == "field") {
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "name") {
        name = e.text();
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "query") {
        q = e.text();
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "alias") {
        a = e.text().mid(30, e.text().length() - 32);
        a = FLUtil::translate("MetaData", a);
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "visible") {
        v = (e.text() == "true");
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "editable") {
        ed = (e.text() == "true");
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "concurWarn") {
        cw = (e.text() == "true");
        no = no.nextSibling();
        continue;
      }
      if (e.tagName() == "detectLocks") {
        dl = (e.text() == "true");
        no = no.nextSibling();
        continue;
      }
    }
    no = no.nextSibling();
  }

  FLTableMetaData *tmd = new FLTableMetaData(name, a, q);
  FLCompoundKey *cK = 0;
  QStringList assocs;

  tmd->setConcurWarn(cw);
  tmd->setDetectLocks(dl);
  no = mtd->firstChild();

  while (!no.isNull()) {
    QDomElement e = no.toElement();
    if (!e.isNull()) {
      if (e.tagName() == "field") {
        FLFieldMetaData *f = metadataField(&e, v, ed);
        if (!tmd)
          tmd = new FLTableMetaData(name, a, q);
        tmd->addFieldMD(f);
        if (f->isCompoundKey()) {
          if (!cK)
            cK = new FLCompoundKey();
          cK->addFieldMD(f);
        }
        if (!f->associatedFieldName().isEmpty()) {
          assocs.append(f->associatedFieldName());
          assocs.append(f->associatedFieldFilterTo());
          assocs.append(f->name());
        }
        no = no.nextSibling();
        continue;
      }
    }
    no = no.nextSibling();
  }

  tmd->setCompoundKey(cK);
  QString aWith, aBy;

  for (QStringList::Iterator it = assocs.begin(); it != assocs.end(); ++it) {
    aWith = (*it);
    ++it;
    aBy = (*it);
    ++it;
    tmd->field((*it))->setAssociatedField(tmd->field(aWith), aBy);
  }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的FLTableMetaData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。