Пример #1
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());
}
Пример #2
0
Файл: Path.cpp Проект: GG31/vle
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;
}
Пример #3
0
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;
		}
	}
}
Пример #4
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();
}
Пример #5
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;
 }
Пример #6
0
  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;
  }
Пример #7
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);
    }
  }
}
Пример #8
0
PathList findResourceDirs(const fs::path& executable) {
	fs::path mapcrafter_dir = findExecutableMapcrafterDir(executable);
	PathList resources = {
		mapcrafter_dir.parent_path() / "share" / "mapcrafter",
		mapcrafter_dir / "data",
	};
	fs::path home = findHomeDir();
	if (!home.empty())
		resources.insert(resources.begin(), home / ".mapcrafter");

	for (PathList::iterator it = resources.begin(); it != resources.end(); ) {
		if (!fs::is_directory(*it))
			resources.erase(it);
		else
			++it;
	}
	return resources;
}
Пример #9
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;
}
Пример #10
0
PathList findLoggingConfigFiles(const fs::path& executable) {
	fs::path mapcrafter_dir = findExecutableMapcrafterDir(findExecutablePath());
	PathList configs = {
		mapcrafter_dir.parent_path().parent_path() / "etc" / "mapcrafter" / "logging.conf",
		mapcrafter_dir / "logging.conf",
	};

	fs::path home = findHomeDir();
	if (!home.empty())
		configs.insert(configs.begin(), home / ".mapcrafter" / "logging.conf");

	for (PathList::iterator it = configs.begin(); it != configs.end(); ) {
		if (!fs::is_regular_file(*it))
			configs.erase(it);
		else
			++it;
	}
	return configs;
}
Пример #11
0
// calculates the edit distance between two words and tracks the differences
int edit_distance (Word first, Word second, PathList& paths) {
  int first_length = first.size() + 1;
  int second_length = second.size() + 1;
  Word::iterator it1 = first.begin();
  Word::iterator it2 = second.begin();
  int distance_matrix [first_length][second_length];
  PathList path_matrix [first_length][second_length];
  wstring charstring[2];
  bool match;
  distance_matrix[0][0] = 0;
  PathList newvector;
  newvector.push_back(L"");
  path_matrix[0][0] = newvector;
  // fill in the top and left edges of the matrix (i.e. one string is empty)
  for (int i=1; i != first_length; i++) {
    path_matrix[i][0] = path_matrix[i-1][0];
    distance_matrix[i][0] = i;
    charstring[0] = *(it1++);
    charstring[1] = NULL_CHAR;
    add_to_vector (path_matrix[i][0], charstring);
  }
  for (int j=1; j != second_length; j++) {
    path_matrix[0][j] = path_matrix[0][j-1];
    distance_matrix[0][j] = j;
    charstring[0] = NULL_CHAR;
    charstring[1] = *(it2++);
    add_to_vector (path_matrix[0][j], charstring);
  }
  it1 = first.begin();
  for (int i=1; i != first_length; i++) {
    it2 = second.begin();
    for (int j=1; j != second_length; j++) {
      int deletion = distance_matrix[i-1][j] + 1;
      int insertion = distance_matrix[i][j-1] + 1;
      int substitution = distance_matrix[i-1][j-1];
      match = true;
      if (*it1 != *it2) {
	substitution++;
        match = false;
      }
      int minimum_distance = min(deletion, min(insertion, substitution));
      distance_matrix[i][j] = minimum_distance;
      PathList* currcell = &path_matrix[i][j];
      PathList::iterator it;
      // add the changes to the current cell of the path matrix here
      if (minimum_distance == deletion) {
        PathList delcell = path_matrix[i-1][j];
        charstring[0] = *it1;
        charstring[1] = NULL_CHAR;
        add_to_vector (delcell, charstring);
	for (it=delcell.begin(); it != delcell.end(); it++)
	  currcell->push_back (*it);
      }
      if (minimum_distance == insertion) {
        PathList inscell = path_matrix[i][j-1];
        charstring[0] = NULL_CHAR;
        charstring[1] = *it2;
        add_to_vector (inscell, charstring);
	for (it=inscell.begin(); it != inscell.end(); it++)
	  currcell->push_back (*it);
      }
      if (minimum_distance == substitution) {
        PathList subcell = path_matrix[i-1][j-1];
	// if the letters are identical, no need to track that
        if (!match) {
          charstring[0] = *it1;
          charstring[1] = *it2;
          add_to_vector (subcell, charstring);
        }
	for (it=subcell.begin(); it != subcell.end(); it++)
	  currcell->push_back (*it);
      }
      it2++;
    }
    it1++;
  }
  paths = path_matrix[first_length-1][second_length-1];
  return distance_matrix[first_length-1][second_length-1];
}
/**
 * @brief ShortPathWriter::writeShortPath - Save exist short path in open file
 * @param fp - open file pointer
 * @param pathIt - Iterator on exist short path
 * @param options - some options (PRINT_INDENTS)
 */
void ShortPathWriter::writeShortPath(FILE* fp, RootPathList::iterator pathIt,
                                     cuint options)
{
    unsigned parentId = pathIt->first;
    ShortPathElem* pathElem = pathIt->second->getNodes();
    PathList* pathList = pathElem->getPathList();
    if (pathList == nullptr)
    {
        return;
    }

    unsigned nodeId;
    float weight;
    bool isFirst = true;
    std::deque <PathListItPair> pathStack;
    unsigned currentIndent = 1;

    bool printIndents = options & (unsigned) Option::PRINT_INDENTS;


    pathStack.push_front( PathListItPair(pathList->begin(), pathList->end()) );

    fprintf(fp, "%u(", parentId);
    if (printIndents)
    {
        fputc('\n', fp);
    }
    while (pathStack.size())
    {
        auto pathIt  = pathStack.front().first;
        auto pathEnd = pathStack.front().second;
        if (pathIt == pathEnd)
        {
            pathStack.pop_front();
            --currentIndent;
            if (printIndents)
            {
                for(unsigned i = 0u; i < currentIndent; ++i)
                {
                    fputc('\t', fp);
                }
                fputs(")\n", fp);
            }
            else
            {
                fputc(')', fp);
            }
            continue;
        }
        nodeId = pathIt->first;
        pathElem = pathIt->second;
        pathList = pathElem->getPathList();

        if (printIndents)
        {
            for(unsigned i = 0u; i < currentIndent; ++i)
            {
                fputc('\t', fp);
            }
        }
        else if (!isFirst)
        {
            fputc(' ', fp);
        }
        else {
            isFirst = false;
        }
        weight = pathElem->getWeight();

        fprintf(fp, "%u[%g]", nodeId, weight);

        ++(pathStack.front().first);

        if (pathList && pathList->size())
        {
            fputc('(', fp);
            // Move to next elem

            // go to next child
            pathStack.push_front( PathListItPair(pathList->begin(),
                                                 pathList->end()) );
            isFirst = true;
            ++currentIndent;
        }
        if (printIndents)
        {
            fputc('\n', fp);
        }
    }
}