Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmVisualStudioSlnData.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmVisualStudioSlnData.h"
13
14 //----------------------------------------------------------------------------
15 const cmSlnProjectEntry*
16 cmSlnData::GetProjectByGUID(const std::string& projectGUID) const
17 {
18   ProjectStorage::const_iterator it(ProjectsByGUID.find(projectGUID));
19   if (it != ProjectsByGUID.end())
20     return &it->second;
21   else
22     return NULL;
23 }
24
25 //----------------------------------------------------------------------------
26 const cmSlnProjectEntry*
27 cmSlnData::GetProjectByName(const std::string& projectName) const
28 {
29   ProjectStringIndex::const_iterator it(ProjectNameIndex.find(projectName));
30   if (it != ProjectNameIndex.end())
31     return &it->second->second;
32   else
33     return NULL;
34 }
35
36 //----------------------------------------------------------------------------
37 std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const
38 {
39   ProjectStringIndex::const_iterator it(this->ProjectNameIndex.begin()),
40                                      itEnd(this->ProjectNameIndex.end());
41   std::vector<cmSlnProjectEntry> result;
42   for (; it != itEnd; ++it)
43     result.push_back(it->second->second);
44   return result;
45 }
46
47 //----------------------------------------------------------------------------
48 cmSlnProjectEntry* cmSlnData::AddProject(
49   const std::string& projectGUID,
50   const std::string& projectName,
51   const std::string& projectRelativePath)
52 {
53   ProjectStorage::iterator it(ProjectsByGUID.find(projectGUID));
54   if (it != ProjectsByGUID.end())
55     return NULL;
56   it = ProjectsByGUID.insert(
57     ProjectStorage::value_type(
58       projectGUID,
59       cmSlnProjectEntry(projectGUID, projectName, projectRelativePath))).first;
60   ProjectNameIndex[projectName] = it;
61   return &it->second;
62 }