bool GetCreateFileEditPosHistory( clPtr<FS>* Fs, FSPath* Path, sEditorScrollCtx& Ctx )
{
	if ( !g_WcmConfig.editSavePos || !Fs || !Fs->Ptr() || !Path )
	{
		return false;
	}
	
	std::vector<unicode_t> Name = new_unicode_str( (*Fs)->Uri( *Path ).GetUnicode() );
	
	// check if item already exists in the list
	const int Index = g_ViewList.FindByName( Name.data() );
	if ( Index != -1 )
	{
		StrConfig* Cfg = g_ViewList.GetData( Index )->conf.ptr();
		Ctx.m_FirstLine = Cfg->GetIntVal( EDIT_FIRST_LINE );
		Ctx.m_Point.line = Cfg->GetIntVal( EDIT_POINT_LINE );
		Ctx.m_Point.pos = Cfg->GetIntVal( EDIT_POINT_POS );
		return true;
	}
	
	// collect all needed path information
	PathList::Data Data;
	if ( PathListFSToData( Data, Fs, Path ) )
	{
		AddFileEditToHistory( Index, Data, 0, 0, 0 );
	}
	
	return false;
}
int GetCreateFileViewPosHistory( clPtr<FS>* Fs, FSPath* Path )
{
	if ( !g_WcmConfig.editSavePos || !Fs || !Fs->Ptr() || !Path )
	{
		return -1;
	}
	
	std::vector<unicode_t> Name = new_unicode_str( (*Fs)->Uri( *Path ).GetUnicode() );
	
	// check if item already exists in the list
	const int Index = g_ViewList.FindByName( Name.data() );
	if ( Index != -1 )
	{
		StrConfig* Cfg = g_ViewList.GetData( Index )->conf.ptr();
		return Cfg->GetIntVal( VIEW_POS );
	}
	
	// collect all needed path information
	PathList::Data Data;
	if ( PathListFSToData( Data, Fs, Path ) )
	{
		AddFileViewToHistory( -1, Data, 0 );
	}
	
	return 0;
}
Exemple #3
0
void Conn::printPathList(PathList& paths, Fleet::Ptr _fleet)
{
  
  
 // cout << "\n\nPrinting path list \n\n";
  while(!paths.empty())
	{

    Cost cost(0);
  	Time time(0);
    bool exp = true;
    Path p = paths.front();
		Path::iterator it = p.begin();

    for(; it != p.end(); it++)
		{
		  Segment* seg = *it;
			cost = cost + seg->cost(_fleet);
      time = time + seg->time(_fleet);
			if(!seg->expediteSupport()) exp = false;
		}
    cout << cost.string() << " " << time.string() << " " << (exp?"yes; ":"no; ");
	  Conn::printPath(paths.front());
		cout << "\n";
	  paths.pop();
	}
	
}
Exemple #4
0
bool Path::getChildren(PathList& children) const
{
#if WENDY_SYSTEM_WIN32
  WIN32_FIND_DATA data;
  HANDLE search;

  search = FindFirstFile(path.c_str(), &data);
  if (search == INVALID_HANDLE_VALUE)
    return false;

  do
  {
    children.push_back(operator + (data.cFileName));
  }
  while (FindNextFile(search, &data));

  FindClose(search);
#else
  DIR* stream;
  dirent* entry;

  stream = opendir(path.c_str());
  if (!stream)
    return false;

  while ((entry = readdir(stream)))
    children.push_back(operator + (entry->d_name));

  closedir(stream);
#endif
  return true;
}
void AddFolderToHistory( clPtr<FS>* fs, FSPath* path )
{
	if ( fs && fs->Ptr() && path )
	{
		// collect all needed path information
		PathList::Data data;

		if ( PathListFSToData( data, fs, path ) )
		{
			// check if item already exists in the list
			const int index = g_dataList.FindByName( data.name.data() );

			if ( index != -1 )
			{
				// remove existing item
				g_dataList.Remove( index );
			}

			// add item to the and of the list
			g_dataList.Add( data.name.data(), data.conf );

			// limit number of elements in the list
			while ( g_dataList.GetCount() > MAX_FOLDERS_HISTORY_COUNT )
			{
				g_dataList.Remove( 0 );
			}
		}
	}
}
Exemple #6
0
PathList Path::children() const
{
  PathList children;

#if WENDY_SYSTEM_WIN32
  WIN32_FIND_DATA data;
  HANDLE search;

  search = FindFirstFile(m_string.c_str(), &data);
  if (search == INVALID_HANDLE_VALUE)
    return PathList();

  do
  {
    children.push_back(operator + (data.cFileName));
  }
  while (FindNextFile(search, &data));

  FindClose(search);
#else
  DIR* stream;
  dirent* entry;

  stream = opendir(m_string.c_str());
  if (!stream)
    return PathList();

  while ((entry = readdir(stream)))
    children.push_back(operator + (entry->d_name));

  closedir(stream);
#endif

  return children;
}
Exemple #7
0
 size_t Path::listDir(PathList &l, bool recurse, unsigned short flags) const {
   EachFunc func;
   details::DirLister dl(l);
   Bind(&dl, &details::DirLister::dirItem, func);
   l.clear();
   each(func, recurse, flags);
   return l.size();
 }
void DataManager::removeGridPath(int x, int y, PathVect* path) {
	PathList* objects = &GET_GRID_ITEM(grid,x,y).paths;
	for (PathList::iterator it = objects->begin(); it != objects->end(); it++) {
		if ((*it).second == path) {
			objects->erase(it);
			break;
		}
	}
}
Exemple #9
0
/* static private */
void
SharedPathsOp::clearEdges(PathList& edges)
{
  for (PathList::const_iterator
        i=edges.begin(), e=edges.end();
        i!=e; ++i)
  {
    delete *i;
  }
  edges.clear();
}
Exemple #10
0
Container::PathList Container::PackageLocations() const
{
    XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});

    PathList output;
    for ( string& str : xpath.Strings(gRootfilePathsXPath) )
    {
        output.emplace_back(std::move(str));
    }

    return output;
}
Exemple #11
0
/* public */
void
SharedPathsOp::getSharedPaths(PathList& forwDir, PathList& backDir)
{
  PathList paths;
  findLinearIntersections(paths);
  for (size_t i=0, n=paths.size(); i<n; ++i)
  {
    LineString* path = paths[i];
    if ( isSameDirection(*path) ) forwDir.push_back(path);
    else backDir.push_back(path);
  }
}
Exemple #12
0
 string find_sys_include(string includeName)
 {
     for(PathList::const_iterator i = includePaths.begin(); i != includePaths.end(); i++)
     {
         string path = *i + includeName;
         std::ifstream test(path.c_str(), std::ifstream::in);
         bool found = test.is_open();
         test.close();
         if(found) return *i;
     }
     return includeName;
 }
  PathName PathName::SearchPathList(const PathList &pathList) const {
    PathName fullFileName;
    
    for (PathList::const_iterator i = pathList.begin(); i != pathList.end(); ++i) {
      
      fullFileName = *i;
      fullFileName.Append(*this);
      if (fullFileName.IsFile())
	return fullFileName;
    }
    return fullFileName;
  }
Exemple #14
0
// helps fill in the path matrix (see below)
void add_to_vector (PathList& previous_vector, wstring* to_add) {
  wstring string_rep = represent_path (to_add, 2);
  if (previous_vector.size() == 0) {
    previous_vector.push_back (string_rep);
  }
  else {
    PathList::iterator it;
    // if there is more than one possible path, add to all of them
    for (it=previous_vector.begin(); it != previous_vector.end(); it++) {
      it->append (string_rep);
    }
  }
}
Exemple #15
0
void Path::fillBinaryPackagesList(std::vector<std::string>& pkglist)
{
    std::string header = "Packages from: ";
    header += path().getBinaryPackagesDir();
    pkglist.clear();
    pkglist.push_back(header);
    PathList pkgs = path().getBinaryPackages();
    std::sort(pkgs.begin(), pkgs.end());
    PathList::const_iterator itb = pkgs.begin();
    PathList::const_iterator ite = pkgs.end();
    for (; itb!=ite; itb++){
        pkglist.push_back(*itb);
    }
    return;
}
Exemple #16
0
void SaveViewHistory()
{
	std::vector<std::string> List;
	g_ViewList.GetStrings( List );

	SaveStringList( ViewHistorySection, List );
}
Exemple #17
0
void LoadViewHistory()
{
	std::vector<std::string> List;
	LoadStringList( ViewHistorySection, List );

	g_ViewList.SetStrings( List );
}
void LoadFoldersHistory()
{
	std::vector<std::string> list;
	LoadStringList( foldersHistorySection, list );

	g_dataList.SetStrings( list );
}
void SaveFoldersHistory()
{
	std::vector<std::string> list;
	g_dataList.GetStrings( list );

	SaveStringList( foldersHistorySection, list );
}
Exemple #20
0
/* private */
void
SharedPathsOp::findLinearIntersections(PathList& to)
{
  using geos::operation::overlay::OverlayOp;

  // TODO: optionally use the tolerance,
  //       snapping _g2 over _g1 ?

  std::auto_ptr<Geometry> full ( OverlayOp::overlayOp(
    &_g1, &_g2, OverlayOp::opINTERSECTION) );

  // NOTE: intersection of equal lines yelds splitted lines, 
  //       should we sew them back ?

  for (size_t i=0, n=full->getNumGeometries(); i<n; ++i)
  {
    const Geometry* sub = full->getGeometryN(i);
    const LineString* path = dynamic_cast<const LineString*>(sub);
    if ( path ) { 
      // NOTE: we're making a copy here, wouldn't be needed
      //       for a simple predicate
      to.push_back(_gf.createLineString(*path).release());
    }
  }
}
Exemple #21
0
void AddFileToHistory( const int CurrIndex, const PathList::Data& Data )
{
	if ( CurrIndex != -1 )
	{
		// remove existing item
		g_ViewList.Remove( CurrIndex );
	}

	// add item to the end of the list
	g_ViewList.Add( Data.name.data(), Data.conf );

	// limit number of elements in the list
	while ( g_ViewList.GetCount() > MAX_VIEW_HISTORY_COUNT )
	{
		g_ViewList.Remove( 0 );
	}
}
Exemple #22
0
void ModuleSettings::SetAutoLoadPaths(const PathList& paths)
{
  PathList normalizedPaths;
  normalizedPaths.resize(paths.size());
  std::transform(paths.begin(), paths.end(), normalizedPaths.begin(), RemoveTrailingPathSeparator);

  US_UNUSED(ModuleSettingsPrivate::Lock(moduleSettingsPrivate()));
  moduleSettingsPrivate()->autoLoadPaths.clear();
  moduleSettingsPrivate()->autoLoadPaths.insert(normalizedPaths.begin(), normalizedPaths.end());
}
// ----------------------------------------------------------------------------------
// Actual A* algorithm: return number of steps in the creation of the path or -1 ----
// ----------------------------------------------------------------------------------
int j1PathFinding::CreatePath(const iPoint& origin, const iPoint& destination)
{
	int ret = 0;
	// TODO 1: if origin or destination are not walkable, return -1
	if (IsWalkable(origin) == true && IsWalkable(destination) == true)
	{
		// TODO 2: Create three lists: open, close
		// Add the origin tile to open
		// Iterate while we have tile in the open list

		PathList open;
		PathList closed;

		PathNode origin_tile;
		origin_tile.pos = origin;
		open.list.add(origin_tile);
		while (open.Find(origin) != NULL)
		{
			// TODO 3: Move the lowest score cell from open list to the closed list
			p2List_item<PathNode>* open_lowestScore = open.GetNodeLowestScore();
			closed.list.add(open_lowestScore->data);
			open.list.del(open_lowestScore);
		
		// TODO 4: If we just added the destination, we are done!
		// Backtrack to create the final path
		// Use the Pathnode::parent and Flip() the path when you are finish
			if (open.Find(destination) != NULL)
			{
				
			}
			
		// TODO 5: Fill a list of all adjancent nodes

		// TODO 6: Iterate adjancent nodes:
		// ignore nodes in the closed list
		// If it is NOT found, calculate its F and add it to the open list
		// If it is already in the open list, check if it is a better path (compare G)
		// If it is a better path, Update the parent
		}
	}
	else
		ret = -1;

	return ret;
}
IResultPtr PerforceDepotView::move(const char* srcFile, const char* dstFile, ChangeListId changeListId)
{
	std::stringstream command;
	PathList paths;
	paths.emplace_back(srcFile);
	paths.emplace_back(dstFile);
	getLatest(paths);
	checkout(paths, changeListId);
	if (changeListId != kDefaultChangelist)
	{
		command << "move -c " << changeListId << " -f " << EscapePaths(paths);
	}
	else
	{
		command << "move -f " << EscapePaths(paths);
	}
	return RunCommand(command.str());
}
Exemple #25
0
Container::PathList Container::PackageLocations() const
{
#if EPUB_COMPILER_SUPPORTS(CXX_INITIALIZER_LISTS)
    XPathWrangler xpath(_ocf, {{"ocf", "urn:oasis:names:tc:opendocument:xmlns:container"}});
#else
    XPathWrangler::NamespaceList __ns;
    __ns["ocf"] = OCFNamespaceURI;
    XPathWrangler xpath(_ocf, __ns);
#endif
    
    PathList output;
    for ( string& str : xpath.Strings(gRootfilePathsXPath) )
    {
        output.emplace_back(std::move(str));
    }
    
    return output;
}
Exemple #26
0
void UpdateFileViewPosHistory( const unicode_t* Name, const int Pos )
{
	if ( !g_WcmConfig.editSavePos )
	{
		return;
	}
	
	// check if item already exists in the list
	const int Index = g_ViewList.FindByName( Name );
	if ( Index != -1 )
	{
		// copy current data
		PathList::Data Data = *g_ViewList.GetData( Index );

		// update data in the history list
		AddFileViewToHistory( Index, Data, Pos );
	}
}
Exemple #27
0
void UpdateFileEditPosHistory( const unicode_t* Name, const sEditorScrollCtx& Ctx )
{
	if ( !g_WcmConfig.editSavePos )
	{
		return;
	}
	
	// check if item already exists in the list
	const int Index = g_ViewList.FindByName( Name );
	if ( Index != -1 )
	{
		// copy current data
		PathList::Data Data = *g_ViewList.GetData( Index );

		// update data in the history list
		AddFileEditToHistory( Index, Data, Ctx.m_FirstLine, Ctx.m_Point.line, Ctx.m_Point.pos );
	}
}
Exemple #28
0
// subroutine for adding a pair of words to our storage dictionary (see below)
int calculate_pair (TownWords& first_dict, TownWords& second_dict, PathMatches* distance_dict, ChangeMap2& word_matches, wstring first_word, wstring second_word) {
  Word first_split;
  Word second_split;
  wstring curr_char;
  for (int i=1; i <= first_word.length(); i+=2) {
    curr_char += first_word[i-1];
    if (first_word[i] == BD) {
      first_split.push_back(curr_char);
      curr_char.clear();
    }
  }
  first_split.push_back(curr_char);
  curr_char.clear();
  for (int j=1; j <= second_word.length(); j+=2) {
    curr_char += second_word[j-1];
    if (second_word[j] == BD) {
      second_split.push_back(curr_char);
      curr_char.clear();
    }
  }
  second_split.push_back(curr_char);
  curr_char.clear();
  PathList paths;
  PathList::iterator it1;
  int distance = edit_distance(first_split, second_split, paths);
  //word_matches[first_word][second_word] = paths;
  // adding everything takes up too much memory, unfortunately
  if (true/*first_dict.count(second_word) == 0 && second_dict.count(first_word) == 0*/) {
    if (distance <= MAX_DIST) {
      for (it1=paths.begin(); it1 != paths.end(); it1++) {
	if (distance_dict[distance].count(*it1) == 0) {
	  WordPairs newmap;
	  distance_dict[distance][*it1] = newmap;
	}
	if (distance_dict[distance][*it1].count(first_word) == 0) {
	  SecondWords newvector;
	  distance_dict[distance][*it1][first_word] = newvector;
	}
	distance_dict[distance][*it1][first_word].push_back(second_word);
      }
    }
  }
  return distance;
}
void
BuildingGrowth::Init()
{
    if (_tess) {
        return;
    }

    const Plane* ground = _sketch->GroundPlane();
    glm::vec2 offset(0, 0);
    const float width = 8;
    const float depth = 4;

    CoplanarPath* rect =
        _sketch->AddRectangle(width, depth, ground->Eqn, offset);

    float height = 4;
    PathList walls;
    _sketch->PushPath(rect, height, &walls);
    _sketch->PushPath(rect, -1, &walls);
    CoplanarPath* roof = rect;
    CoplanarPath* wall;

    wall = dynamic_cast<CoplanarPath*>(walls[1]);
    rect = _sketch->AddInscribedRectangle(1, 1.5, wall, vec2(0, 0));
    _sketch->PushPath(rect, -0.5);

    wall = dynamic_cast<CoplanarPath*>(walls[2]);

    sketch::PathList cylinders;

    for (float y = -3.25; y < 3.26; y += 1.0) {
        CoplanarPath* circle = _sketch->AddInscribedPolygon(0.3, wall, vec2(0, y), 48);
        cylinders.push_back(circle);
    }

    _sketch->PushPaths(cylinders, 3);
    PathList inners;
    FOR_EACH(circle, cylinders) {
        CoplanarPath* outer = dynamic_cast<CoplanarPath*>(*circle);
        CoplanarPath* inner = _sketch->AddInscribedPolygon(0.15, outer, vec2(0, 0), 8);
        inners.push_back(inner);
    }
	FoldersHistoryDlg( NCDialogParent* parent, PathList& dataList )
	 : PathListDlg( parent, m_historyWin, _LT( "Folders History" ), 0 )
	 , m_historyWin( this, dataList )
	 , m_lo( 10, 10 )
	{
		m_ListWin.Show();
		m_ListWin.Enable();

		m_lo.AddWin( &m_ListWin, 0, 0, 9, 0 );
		m_lo.SetLineGrowth( 9 );
		AddLayout( &m_lo );

		SetPosition();
		m_ListWin.SetFocus();

		if ( dataList.GetCount() > 0 )
		{
			// select the last item and make it visible
			m_ListWin.MoveCurrent( dataList.GetCount() - 1 );
		}
	}