cmVisualStudioSlnData.cxx 1.49 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4
#include "cmVisualStudioSlnData.h"

5 6
const cmSlnProjectEntry* cmSlnData::GetProjectByGUID(
  const std::string& projectGUID) const
7 8 9 10 11 12 13 14
{
  ProjectStorage::const_iterator it(ProjectsByGUID.find(projectGUID));
  if (it != ProjectsByGUID.end())
    return &it->second;
  else
    return NULL;
}

15 16
const cmSlnProjectEntry* cmSlnData::GetProjectByName(
  const std::string& projectName) const
17 18 19 20 21 22 23 24 25 26 27
{
  ProjectStringIndex::const_iterator it(ProjectNameIndex.find(projectName));
  if (it != ProjectNameIndex.end())
    return &it->second->second;
  else
    return NULL;
}

std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const
{
  ProjectStringIndex::const_iterator it(this->ProjectNameIndex.begin()),
28
    itEnd(this->ProjectNameIndex.end());
29 30 31 32 33 34 35
  std::vector<cmSlnProjectEntry> result;
  for (; it != itEnd; ++it)
    result.push_back(it->second->second);
  return result;
}

cmSlnProjectEntry* cmSlnData::AddProject(
36
  const std::string& projectGUID, const std::string& projectName,
37 38 39 40 41
  const std::string& projectRelativePath)
{
  ProjectStorage::iterator it(ProjectsByGUID.find(projectGUID));
  if (it != ProjectsByGUID.end())
    return NULL;
42 43 44 45 46
  it = ProjectsByGUID
         .insert(ProjectStorage::value_type(
           projectGUID,
           cmSlnProjectEntry(projectGUID, projectName, projectRelativePath)))
         .first;
47 48 49
  ProjectNameIndex[projectName] = it;
  return &it->second;
}