コード例 #1
0
ファイル: URLBASE.cpp プロジェクト: kuailexs/symbiandump-mw2
EXPORT_C CUrl* CUrl::AllocL(TComponent aComponent) const
	{
	if (aComponent == EUrlGenericCompare)
		return AllocL();
	else if (aComponent == EUrlNoCredentials)
		{
		TInt usernameStart;
		TInt locationStart;
		TInt scratch;
		Part(EUrlUsername, *iUrlDes, usernameStart, scratch);
		Part(EUrlLocation, *iUrlDes, locationStart, scratch);
		// If there isn't a location and a username, we can just
		// return the current URL.
		if (locationStart == KCUrlInvalidCharPos || 
			usernameStart == KCUrlInvalidCharPos)
			return AllocL();
		// Make a CUrl of the right length and then copy the correct
		// data into it.
		TInt lengthOfReturnedUrl = iUrlDes->Length() - locationStart + 
			usernameStart;
		CUrl* result = CUrl::NewL(iUrlDes->Left(lengthOfReturnedUrl));
		result->iUrlDes->Des().Replace(usernameStart,
									   lengthOfReturnedUrl - usernameStart,
									   iUrlDes->Right(lengthOfReturnedUrl - 
													  usernameStart));
		return result;
		}
	else return CUrl::NewL(Component(aComponent));
	}
コード例 #2
0
ファイル: URLBASE.cpp プロジェクト: kuailexs/symbiandump-mw2
EXPORT_C const TPtrC CUrl::Component(TComponent aType) const
	{
	TInt start = KCUrlInvalidCharPos;
	TInt end = KCUrlInvalidCharPos;

	TComponent type(aType);
	if (aType == EUrlFileName)
		type = EUrlPath;


	Part(type, *iUrlDes, start,end);
	if  (start == KCUrlInvalidCharPos || end == KCUrlInvalidCharPos)
			return KNullDesC();

	TInt length = end - start +1; 
	if (end == (*iUrlDes).Length())
		length--;

	TPtrC component((*iUrlDes).Mid(start, length));

	if (aType == EUrlFileName)
		{
		TInt slashPos = component.LocateReverse('/');
		if (slashPos == KErrNotFound)
			return KNullDesC();
		else
			component.Set(component.Right(component.Length() - (slashPos +1)));
		}

	return component;
	}
コード例 #3
0
void
IrcAbstractChannel::UserSend ()
{
  qDebug () << " User sending " ;
  bool sendout (true);
  if (qmlItem) {
    QVariant userData;
    QMetaObject::invokeMethod (qmlItem, "userData",
        Q_RETURN_ARG (QVariant, userData));
    QString data = userData.toString();
    qDebug () << "   user data " << data;
    if (data.trimmed().length() > 0) {
      QMetaObject::invokeMethod (qmlItem, "clearUserData");
      if (raw) {
        AlmostRaw (data);
      } else if (data == "/part") {
        Part ();
        sendout = false;
      } else if (data.startsWith ("/whois")) {
        data.remove (0, 6);
        Whois (data.trimmed());
        sendout = false;
      }
      if (sendout) {
        emit Outgoing (chanName, data);
      }
      history.append (data);
      history.removeDuplicates ();
      historyIndex = history.size();
    }
  }
}
コード例 #4
0
ファイル: PRSolution.hpp プロジェクト: PPNav/GPSTk
      /// add newly computed solution (must be valid); update counts, APV and apriori.
      /// input parameters are from PRSolution after computing a solution.
      void add(const Vector<double>& Sol, const Matrix<double>& Cov,
               const Vector<double>& PreFitResid, const Matrix<double>& Partials,
               const Matrix<double>& invMeasCov)
         throw(Exception)
      {
         was.add(Sol, Cov);

         // first solution: apriori solution has no clock, so PFR bad
         if(was.getN() == 1) return;

         try {
            Matrix<double> Part(Partials,0,0,Partials.rows(),3);
            Matrix<double> invMC(invMeasCov);
            if(invMC.rows() == 0) {
               invMC=Matrix<double>(Part.rows(),Part.rows());
               ident(invMC);
            }
            Matrix<double> sumInfo(was.getInfo());
            Matrix<double> Ginv(Part*sumInfo*transpose(Part) + invMC);
            Matrix<double> G(inverseSVD(Ginv));
            Vector<double> Gpfr(G*PreFitResid);
            APV += dot(PreFitResid,Gpfr);
            ndata += PreFitResid.size();
            ndof = ndata-sumInfo.rows();
         }
         catch(Exception& e) {
            e.addText("APV failed.");
            GPSTK_RETHROW(e);
         }
      }
コード例 #5
0
ファイル: FaceParts.cpp プロジェクト: Zordey/pioneer
void PartDb::ScanGenderedParts(std::vector<Part> &output, const int species_idx, const int race_idx, const std::string &path, const char *prefix)
{
	const int prefix_len = strlen(prefix);
	for (fs::FileEnumerator files(fs::gameDataFiles, path); !files.Finished(); files.Next()) {
		const std::string &name = files.Current().GetName();
		if (starts_with(name, prefix)) {
			char *end = nullptr;
			int gender_idx = strtol(name.c_str() + prefix_len, &end, 10);
			Uint32 sel;
			// HACK -- attempt to recognise `foo_3.png' style names
			if (strcmp(end, ".png") == 0) {
				sel = _make_selector(species_idx, race_idx, -1);
			} else {
				if (gender_idx < 0 || gender_idx >= MAX_GENDERS) {
					Output("Gender out of range: %s\n", files.Current().GetPath().c_str());
					continue;
				}
				sel = _make_selector(species_idx, race_idx, gender_idx);
			}

			SDLSurfacePtr im = LoadSurfaceFromFile(files.Current().GetPath());
			if (im) {
				output.push_back(Part(sel, im));
			} else {
				Output("Failed to load image %s\n", files.Current().GetPath().c_str());
			}
		}
	}
}
コード例 #6
0
void CCMSDIntegrator::ParseCMSD(std::string filename)
{

	CMSD::CCMSD doc = CMSD::CCMSD::LoadFromFile(filename);
	doc.SaveToFile((::ExeDirectory() + "Test1.xml").c_str(), true);
	//CMSD::CCMSD::DataSection d = doc.DataSection().first();
	CMSD::CwhiteSpaceType root = doc.whiteSpace.first();
	CMSD::CCMSDDocument cmsddocument = doc.CMSDDocument[0];
	CMSD::CDataSectionType2  data  = cmsddocument.DataSection[0];

	for(int i=0; i< data.PartType.count() ; i++)
	{
		Part * apart ( (Part*) Part().CreateSave<Part>());
		apart->Load(data.PartType[i].GetNode());
		//std::vector<IObjectPtr> &someparts ( apart->objects());
		//Part * part2=(Part *) someparts[0].get();
	}
	for(int i=0; i< data.ProcessPlan.count() ; i++)
	{
		ProcessPlan * aplan ( (ProcessPlan *) IObject::CreateSave<ProcessPlan>());
		aplan->Load(data.ProcessPlan[i].GetNode());
	}
	for(int i=0; i< data.Resource.count() ; i++)
	{
		if(Cell::IsResourceCell(data.Resource[i].GetNode()))
		{
			Cell * acell( (Cell *) IObject::CreateSave<Cell>());
			acell->Load(data.Resource[i].GetNode());
		}
		else
		{
			Resource * aresource  ((Resource *) IObject::CreateSave<Resource>());
			aresource->Load(data.Resource[i].GetNode());
		}
	}
	for(int i=0; i< data.Job.count() ; i++)
	{
		Job * ajob  ( IObject::CreateSave<Job>() );
		ajob->Load(data.Job[i].GetNode());
	}
	for(int i=0; i< data.DistributionDefinition.count() ; i++)
	{
		Distribution * astat ( (Distribution *) IObject::CreateSave<Distribution>() );
		astat->LoadDefinition(data.DistributionDefinition[i].GetNode());
	}
	for(int i=0; i< data.Calendar.count() ; i++)
	{
		Calendar *  calendar ( (Calendar *) IObject::CreateSave<Calendar>());
		calendar->Load(data.Calendar[i].GetNode());
	}
	for(int i=0; i< data.Layout.count() ; i++)
	{
		Layout * layout ((Layout *)  IObject::CreateSave<Layout>());
		layout->Load(data.Layout[i].GetNode());
	}
	//CMSD::CInventoryItem inv = data.InventoryItem[0];
	//inv.Location

	int j=0;
}
コード例 #7
0
ファイル: ignore_list.cpp プロジェクト: jingqi/organic
void IgnoreList::push_config(const QString& base, const QString &configfile)
{
    assert(base.isEmpty() || (!Path::is_path_separator(base.at(0).toLatin1()) &&
        !Path::is_path_separator(base.at(base.length() - 1).toLatin1())));

    _parts.push_back(Part());
    Part& part = *_parts.rbegin();
    part.base = base;
    part.base.replace('\\', '/');
    part.config_filename = QFileInfo(configfile).fileName();

    QFile f(configfile);
    if (!f.open(QFile::ReadOnly | QFile::Text))
        return;

    QTextStream is(&f);
    while (!is.atEnd())
    {
        QString l = is.readLine().trimmed();
        if (l.isEmpty() || l.at(0) == '#')
            continue;

        QRegExp reg = process_ignore_item_to_regex(l);
        if (has_path_seperator(l))
            part.path_list.push_back(reg);
        else
            part.name_list.push_back(reg);
    }
}
コード例 #8
0
Part PartController::New(QWidget *caller)
{
    Part part;
    PartForm view(part, caller);
    view.setModal(true);
    return (view.exec() == QDialog::Rejected ? Part() : part);
}
コード例 #9
0
ファイル: gen.cpp プロジェクト: hyln9/nV
void parser::emit(Var x)
{
	if(code_stack.empty())
	{
		m_code.push_back(x);
		return;
	}
	std::pair<Var,size_t> &c = code_stack.top();
	if(VecQ(c.first))
	{
		At(c.first,c.second) = x;
		if(++c.second == Size(c.first))
			code_stack.pop();
	}
	else
	{
		if(c.second == 0)
			Head(c.first) = x;
		else
			Part(c.first,c.second - 1) = x;
		if(c.second == Len(c.first))
			code_stack.pop();
		else
			++c.second;
	}
}
コード例 #10
0
//---------------------------------------------------------
bool CShapes_Buffer::Get_Buffer_Points(CSG_Shape *pPoints, CSG_Shape *pBuffer, double Distance)
{
	CSG_Shapes	Part(SHAPE_TYPE_Polygon);
	CSG_Shape	*pPart	= Part.Add_Shape();

	for(int iPart=0; iPart<pPoints->Get_Part_Count(); iPart++)
	{
		for(int iPoint=0; iPoint<pPoints->Get_Point_Count(iPart); iPoint++)
		{
			if( pBuffer->Get_Part_Count() == 0 )
			{
				Add_Arc(pBuffer, pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360);
			}
			else
			{
				Add_Arc(pPart  , pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360);

				SG_Polygon_Union(pBuffer, pPart);

				pPart->Del_Parts();
			}
		}
	}

	return( true );
}
コード例 #11
0
 Part
 Multipart::release(size_t i)
 {
   if (i >= size())
   {
     return Part(false);
   }
   return (*parts_ptr_)[i]; //copy
 }
コード例 #12
0
bool PartController::Destroy(Part &part, QWidget *caller)
{
    if (Destroy(part.getId(), caller))
    {
        part = Part();
        return true;
    }

    return false;
}
コード例 #13
0
Part PartController::getPart(const int partId)
{
    Part part;
    try { part = Databases::parts().findRecord("id", partId); }
    catch (const std::exception &e)
    {
        showErrorDialog(e.what());
        return Part();
    }
    return part;
}
コード例 #14
0
ファイル: Snake.cpp プロジェクト: Redneloss/ConsoleSnake
void Snake::EatFood(Food& food, int dif)
{
	switch (s_parts.back().GetDirection())
	{
	case LEFT:
		s_parts.push_back(Part(s_parts.back().GetX() + 1, s_parts.back().GetY(), LEFT));
		break;
	case RIGHT:
		s_parts.push_back(Part(s_parts.back().GetX() - 1, s_parts.back().GetY(), RIGHT));
		break;
	case UP:
		s_parts.push_back(Part(s_parts.back().GetX(), s_parts.back().GetY() + 1, UP));
		break;
	case DOWN:
		s_parts.push_back(Part(s_parts.back().GetX(), s_parts.back().GetY() - 1, DOWN));
		break;
	}

	switch (dif)
	{
	case 0:
		score += 150;
		break;
	case 1:
		score += 10;
		break;
	case 2:
		score += 20;
		break;
	case 3:
		score += 30;
		break;
	case 4:
		score += 70;
		break;
	}

	standard_field.AddToMap(food.GetX(), food.GetY(), SNAKE_PART);
}
コード例 #15
0
CCMSDIntegrator::CCMSDIntegrator(void)
:
		resources((std::vector<IObjectPtr>&) Resource().objects()),
		cells((std::vector<IObjectPtr>&) Cell().objects()),
		parts((std::vector<IObjectPtr>&) Part().objects()),
		processplans((std::vector<IObjectPtr>&) ProcessPlan().objects()),
		jobs((std::vector<IObjectPtr>&) Job().objects()),
		distributions((std::vector<IObjectPtr>&) Distribution().objects()),
		calendars((std::vector<IObjectPtr>&) Calendar().objects()),
		layouts((std::vector<IObjectPtr>&) Layout().objects())

{
}
コード例 #16
0
//---------------------------------------------------------
bool CShapes_Buffer::Get_Buffers(CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve)
{
	//-----------------------------------------------------
	double		Distance;
	CSG_Shapes	Part(SHAPE_TYPE_Polygon);
	CSG_Shape	*pPart	= Part.Add_Shape(), *pBuffer;

	Distance	= Parameters("DIST_FIELD")->asDouble() * Scale;
	Scale		= Parameters("DIST_SCALE")->asDouble() * Scale;

	if( !bDissolve )
	{
		pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer")), pShapes);
	}
	else
	{
		pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer")));
		pBuffers->Add_Field(_TL("ID"), SG_DATATYPE_Int);
		pBuffer	= pBuffers->Add_Shape();
	}

	//-----------------------------------------------------
	for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
	{
		CSG_Shape	*pShape	= pShapes->Get_Shape(iShape);

		if( Field < 0 || (Distance = Scale * pShape->asDouble(Field)) > 0.0 )
		{
			if( !bDissolve )
			{
				pBuffer	= pBuffers->Add_Shape(pShape, SHAPE_COPY_ATTR);
			}

			if( pBuffer->Get_Part_Count() == 0 )
			{
				Get_Buffer(pShape, pBuffer, Distance);
			}
			else
			{
				Get_Buffer(pShape, pPart  , Distance);

				SG_Polygon_Union(pBuffer, pPart);

				pPart->Del_Parts();
			}
		}
	}

	//-----------------------------------------------------
	return( pBuffers->is_Valid() );
}
コード例 #17
0
void PartDb::ScanParts(std::vector<Part> &output, const int species_idx, const int race_idx, const std::string &path, const char *prefix) {
	const Uint32 selector = _make_selector(species_idx, race_idx, -1);
	for (fs::FileEnumerator files(fs::gameDataFiles, path); !files.Finished(); files.Next()) {
		const std::string &name = files.Current().GetName();
		if (starts_with(name, prefix)) {
			SDLSurfacePtr im = LoadSurfaceFromFile(files.Current().GetPath());
			if (im) {
				output.push_back(Part(selector, im));
			} else {
				Output("Failed to load image %s\n", files.Current().GetPath().c_str());
			}
		}
	}
}
コード例 #18
0
//---------------------------------------------------------
bool CSG_Network::Add_Shape(CSG_Shape *pShape)
{
	if( !pShape || !pShape->is_Valid() )
	{
		return( false );
	}

	//-----------------------------------------------------
	CSG_Shapes	Part(SHAPE_TYPE_Line);
	CSG_Shape	*pPart	= Part.Add_Shape();

	for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
	{
		if( pShape->Get_Point_Count(iPart) > 1 )
		{
			bool	bAscending	= pShape->Get_Type() != SHAPE_TYPE_Polygon
				|| ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) != ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart);

			CSG_Point	q, p	= pShape->Get_Point(0, iPart, bAscending);

			pPart->Add_Point(p);

			for(int iPoint=1; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
			{
				if( !p.is_Equal(q = pShape->Get_Point(iPoint, iPart, bAscending)) )
				{
					p	= q;

					pPart->Add_Point(p);
				}
			}

			if( pPart->Get_Point_Count(0) > 1 )
			{
				_Add_Line(pPart, pShape->Get_Type());
			}

			pPart->Del_Parts();
		}
	}

	return( true );
}
bool HistoryGroupedMedia::applyGroup(
		const std::vector<not_null<HistoryItem*>> &items) {
	Expects(items.size() <= kMaxDisplayedGroupSize);

	if (items.empty()) {
		return false;
	}
	if (validateGroupParts(items)) {
		return true;
	}

	for (const auto item : items) {
		const auto media = item->media();
		Assert(media != nullptr && media->canBeGrouped());

		_parts.push_back(Part(item));
		_parts.back().content = media->createView(_parent, item);
	};
	return true;
}
コード例 #20
0
ファイル: URLBASE.cpp プロジェクト: kuailexs/symbiandump-mw2
EXPORT_C void CUrl::SetComponentL(TComponent aComponent, const TDesC& aValue)
	{
	TInt start, end;
	// As a crude first step, we always resize the URL descriptor to
	// be longer than it currently is by 4 characters longer than the
	// value. Then at the end, we'll resize it to be the right length.
	// 4 allows :// to be inserted if a scheme is set when none is present
	iUrlDes=iUrlDes->ReAllocL(iUrlDes->Length() + aValue.Length() + 4);

	Part(aComponent, *iUrlDes, start, end);
		
	if (aComponent == EUrlScheme && start == KCUrlInvalidCharPos && end == KCUrlInvalidCharPos)
		{ // We're trying to add a scheme, but there isn't one already. Check if scheme valid
		  // There could already be a // at the start, but there can't be a : at the start
		CheckSchemeValidL(aValue);
		// insert location if required
		TPtr wptr(iUrlDes->Des());
		// insert // at the start
		if(wptr.Find(KUrlLoc)!=0)
			wptr.Insert(0,KUrlLoc);
		// insert scheme and a colon
		wptr.Insert(0,KUrlColon);
		wptr.Insert(0,aValue);
		}
	else if ((aComponent == EUrlUsername || aComponent == EUrlPassword) && 
		(start == KCUrlInvalidCharPos || end == KCUrlInvalidCharPos))
		{
		// We're trying to add a username or password, but there isn't
		// one already, so the surrounding punctuation won't be there.
		if (aComponent == EUrlUsername)
			{
			Part(EUrlAuthority, *iUrlDes, start, end);
			// If there isn't an authority, this is too complex.
			if (start == KCUrlInvalidCharPos)
				User::Leave(KErrNotSupported);

			// We've now found the correct start position. Check if
			// the password exists
			TInt scratch;
			Part(EUrlPassword, *iUrlDes, end, scratch);
			if (end == KCUrlInvalidCharPos)
				{
				// No username or password. This means we need to add the @
				iUrlDes->Des().Insert(start, _L("@"));
				end = start;
				}
			else
				{
				// There is a password, so end currently points after
				// the colon.
				end--;
				}
			}
		else
			{
			// aComponent == EUrlPassword
			TInt scratch;
			Part(EUrlUsername, *iUrlDes, scratch, start);
			if (start == KCUrlInvalidCharPos)
				{
				// No username. We need to find the start of the
				// location, and add :@ after it and insert the
				// password between them.

				
				Part(EUrlLocation, *iUrlDes, start, scratch);
				iUrlDes->Des().Insert(start, _L(":@"));
				}
			else
				{
				// There is a username but no password. Add a colon at
				// the end of it and then add the password afterwards.
				iUrlDes->Des().Insert(++start, KUrlColon);
				}
			start++;
			end = start;
			}
		}
	else if (start == KCUrlInvalidCharPos || end == KCUrlInvalidCharPos)
		{
		// A complex case we can't deal with
		User::Leave(KErrNotSupported);
		}
	else
		{
		// The easy case; end currently points at the last character;
		// we want it to point one after.
		end++;
		}
	if (start != KCUrlInvalidCharPos && end != KCUrlInvalidCharPos)
		{ // this check is necessary to catch the case where
		  // we set a scheme and there wasn't one already
		iUrlDes->Des().Replace(start, end - start, aValue);
		}
	iUrlDes=iUrlDes->ReAllocL(iUrlDes->Length());
	}
コード例 #21
0
ファイル: Snake.cpp プロジェクト: Redneloss/ConsoleSnake
Snake::Snake()
{
	for (int i = 0; i < INIT_SNAKE_LENGTH; i++)
		s_parts.push_back(Part(INIT_SNAKE_LENGTH - i + standard_field.GetLength() / 4, standard_field.GetWidth() / 2, RIGHT));
}