Example #1
0
boost::shared_ptr<DataFrame> DataSamples::toDataFrame(double nullValue) const
{
  boost::shared_ptr<DataFrame> result(new DataFrame);
  vector<string> labels = getUniqueLabels();
  result->setFactorLabels(labels);

  vector<double> record;
  record.resize(labels.size());

  for (size_t i = 0; i < size(); i++)
  {
    const Sample& s = get(i);

    MatchType type = MatchType(s.find("class")->second);
    string classLabel = type.toString().toLower().toStdString();

    for (size_t j = 0; j < labels.size(); j++)
    {
      Sample::const_iterator it = get(i).find(QString::fromStdString(labels[j]));
      if (it != get(i).end())
      {
        record[j] = it->second;
      }
      else
      {
        record[j] = nullValue;
      }
    }
    result->addDataVector(classLabel, record);
  }

  return result;
}
// -----------------------------------------------------------------------------
//  CUpnpHttpServerTransactionHandler::GetFileL
//
// -----------------------------------------------------------------------------
//
TInt CUpnpHttpServerTransactionHandler::GetFileL( RFile& aFile,
        const TDesC8& aUri, const TInetAddr& aInetAdress )
    {
    
    CUpnpDeviceDescriptionRequest* request = CUpnpDeviceDescriptionRequest::NewL( aUri, aInetAdress );    
    TInt error = KErrNone;
    
    switch ( MatchType( aUri ) )
        {
        case EDevice:
            error = iDevice.DescritptionProvider().OnDeviceDescription( *request );
            break;        
        case EService:
            error = iDevice.DescritptionProvider().OnServiceDescription( *request );
            break;        
        case EIcon:
            error = iDevice.DescritptionProvider().OnIcon( *request );
            break;        
        default:
            error = -EHttpNotFound;            
            break;
        }
    delete request;
    request = NULL;
    
    if( KErrNone == error )
        {
        if ( KErrNone != iDevice.DescritptionProvider().GetFile( aUri, aFile ) )
            {
            error = -EHttpNotFound;
            }
        }
    else
        {
        error = -EHttpNotFound;
        }
    
    return error;
    }
Example #3
0
void MainVisitor::ProcessUnbarrieredFields(
    CXXRecordDecl* recordDecl, const PushFieldType& pushFieldType)
{
    std::string typeName = recordDecl->getQualifiedNameAsString();
    if (typeName == "Memory::WriteBarrierPtr")
    {
        return;  // Skip WriteBarrierPtr itself
    }

    const auto& sourceMgr = _compilerInstance.getSourceManager();
    DiagnosticsEngine& diagEngine = _context.getDiagnostics();
    const unsigned diagID = diagEngine.getCustomDiagID(
        DiagnosticsEngine::Error,
        "Unbarriered field, see "
        "https://github.com/microsoft/ChakraCore/wiki/Software-Write-Barrier#coding-rules");

    for (auto field : recordDecl->fields())
    {
        const QualType qualType = field->getType();
        string fieldTypeName = qualType.getAsString();
        string fieldName = field->getNameAsString();

        if (StartsWith(fieldTypeName, "WriteBarrierPtr<") || // WriteBarrierPtr fields
            Contains(fieldTypeName, "_no_write_barrier_policy, ")) // FieldNoBarrier
        {
            continue; // skip
        }

        // If an annotated field type is struct/class/union (RecordType), the
        // field type in turn should likely be annoatated.
        if (fieldTypeName.back() != '*'  // not "... *"
            &&
            (
                StartsWith(fieldTypeName, "typename WriteBarrierFieldTypeTraits") ||
                StartsWith(fieldTypeName, "WriteBarrierFieldTypeTraits") ||
                StartsWith(fieldTypeName, "const typename WriteBarrierFieldTypeTraits") ||
                StartsWith(fieldTypeName, "const WriteBarrierFieldTypeTraits") ||
                fieldName.length() == 0  // anonymous union/struct
            ))
        {
            auto originalType = qualType->getUnqualifiedDesugaredType();
            if (auto arrayType = dyn_cast<ArrayType>(originalType))
            {
                originalType = arrayType->getElementType()->getUnqualifiedDesugaredType();
            }

            string originalTypeName = QualType(originalType, 0).getAsString();
            if (isa<RecordType>(originalType) &&
                !StartsWith(originalTypeName, "class Memory::WriteBarrierPtr<"))
            {
                if (pushFieldType(originalType))
                {
                    Log::outs() << "Queue field type: " << originalTypeName
                        << " (" << typeName << "::" << fieldName << ")\n";
                }
            }
        }
        else
        {
            SourceLocation location = field->getLocStart();
            if (this->_fix)
            {
                const char* begin = sourceMgr.getCharacterData(location);
                const char* end = begin;

                if (MatchType(fieldTypeName, begin, &end))
                {
                    _rewriter.ReplaceText(
                        location, end - begin,
                        GetFieldTypeAnnotation(qualType) + string(begin, end) +
                             (*end == ' ' ? ")" : ") "));
                    _fixed = true;
                    continue;
                }

                Log::errs() << "Fail to fix: " << fieldTypeName << " "
                            << fieldName << "\n";
            }

            diagEngine.Report(location, diagID);
        }
    }
}
Example #4
0
void ConstraintWidget::applyConfiguration(void)
{
	try
	{
		Constraint *constr=nullptr;
		unsigned i, col_id, count;
		Column *column=nullptr;
		ObjectTableWidget *aux_col_tab=nullptr;
		vector<ExcludeElement> excl_elems;

		startConfiguration<Constraint>();

		constr=dynamic_cast<Constraint *>(this->object);
		constr->setConstraintType(ConstraintType(constr_type_cmb->currentText()));
    constr->setExpression(expression_txt->toPlainText().toUtf8());

		if(fill_factor_chk->isChecked())
			constr->setFillFactor(fill_factor_sb->value());
		else
			constr->setFillFactor(0);

		constr->setMatchType(MatchType(match_cmb->currentText()));
		constr->setDeferrable(deferrable_chk->isChecked());
		constr->setDeferralType(DeferralType(deferral_cmb->currentText()));
    constr->setActionType(ActionType(on_delete_cmb->currentText()),Constraint::DELETE_ACTION);
    constr->setActionType(ActionType(on_update_cmb->currentText()),Constraint::UPDATE_ACTION);
		constr->setNoInherit(no_inherit_chk->isChecked());

		if(indexing_chk->isChecked())
			constr->setIndexType(IndexingType(indexing_cmb->currentText()));
		else
			constr->setIndexType(BaseType::null);

		if(constr->getConstraintType()==ConstraintType::foreign_key)
			constr->setReferencedTable(dynamic_cast<BaseTable *>(ref_table_sel->getSelectedObject()));

		constr->removeColumns();
		for(col_id=Constraint::SOURCE_COLS; col_id <= Constraint::REFERENCED_COLS; col_id++)
		{
			aux_col_tab=(col_id==Constraint::SOURCE_COLS ? columns_tab : ref_columns_tab);

			count=aux_col_tab->getRowCount();
			for(i=0; i < count; i++)
			{
				column=reinterpret_cast<Column *>(aux_col_tab->getRowData(i).value<void *>());
				constr->addColumn(column, col_id);
			}
		}

		excl_elems_wgt->getElements(excl_elems);
		constr->addExcludeElements(excl_elems);

		//Raises an error if the user try to create a primary key that has columns added by relationship (not supported)
		if(constr->getConstraintType()==ConstraintType::primary_key &&
			 constr->isReferRelationshipAddedColumn())
			throw Exception(ERR_PK_USING_COLS_ADDED_BY_REL,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		BaseObjectWidget::applyConfiguration();

		/* Raises an error if the constraint type requires at least one column to be assinged and
		there is no columns configured on the form */
		if(((constr->getConstraintType()==ConstraintType::foreign_key ||
				 constr->getConstraintType()==ConstraintType::primary_key) &&
				constr->getColumnCount(Constraint::SOURCE_COLS)==0) ||
			 (constr->getConstraintType()==ConstraintType::foreign_key &&
				constr->getColumnCount(Constraint::REFERENCED_COLS)==0))
			throw Exception(ERR_CONSTR_NO_COLUMNS,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		finishConfiguration();

		//For the foreign keys, updates the fk relationships on the model
		if(constr->getConstraintType()==ConstraintType::foreign_key)
			this->model->updateTableFKRelationships(dynamic_cast<Table *>(this->table));
	}
	catch(Exception &e)
	{
		Messagebox msg_box;

		cancelConfiguration();
		msg_box.show(e);
	}
}
Example #5
0
void ConstraintWidget::applyConfiguration(void)
{
	try
	{
		Constraint *constr=NULL;
		unsigned i, col_id, count;
		Column *column=NULL;
		ObjectTableWidget *aux_col_tab=NULL;

		startConfiguration<Constraint>();

		constr=dynamic_cast<Constraint *>(this->object);
		constr->setConstraintType(ConstraintType(constr_type_cmb->currentText()));
		constr->setCheckExpression(check_expr_txt->toPlainText().toUtf8());
		constr->setFillFactor(fill_factor_sb->value());
		constr->setMatchType(MatchType(match_cmb->currentText()));
		constr->setDeferrable(deferrable_chk->isChecked());
		constr->setDeferralType(DeferralType(deferral_cmb->currentText()));
		constr->setActionType(ActionType(on_delete_cmb->currentText()),false);
		constr->setActionType(ActionType(on_update_cmb->currentText()),true);

		if(constr->getConstraintType()==ConstraintType::foreign_key)
			constr->setReferencedTable(ref_table_sel->getSelectedObject());

		constr->removeColumns();
		for(col_id=Constraint::SOURCE_COLS; col_id <= Constraint::REFERENCED_COLS; col_id++)
		{
			aux_col_tab=(col_id==Constraint::SOURCE_COLS ? columns_tab : ref_columns_tab);

			count=aux_col_tab->getRowCount();
			for(i=0; i < count; i++)
			{
				column=reinterpret_cast<Column *>(aux_col_tab->getRowData(i).value<void *>());
				constr->addColumn(column, col_id);
			}
		}

		BaseObjectWidget::applyConfiguration();

		/* Raises an error if the constraint type requires at least one column to be assinged and
		there is no columns configured on the form */
		if(((constr->getConstraintType()==ConstraintType::foreign_key ||
				 constr->getConstraintType()==ConstraintType::primary_key) &&
				constr->getColumnCount(Constraint::SOURCE_COLS)==0) ||
			 (constr->getConstraintType()==ConstraintType::foreign_key &&
				constr->getColumnCount(Constraint::REFERENCED_COLS)==0))
			throw Exception(ERR_CONSTR_NO_COLUMNS,__PRETTY_FUNCTION__,__FILE__,__LINE__);

		finishConfiguration();

		//For the foreign keys, updates the fk relationships on the model
		if(constr->getConstraintType()==ConstraintType::foreign_key)
			this->model->updateTableFKRelationships(this->table);
	}
	catch(Exception &e)
	{
		MessageBox msg_box;

		cancelConfiguration();
		msg_box.show(e);
	}
}