Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmInstallCommandArguments.cxx
blobcbff9372687d8da3181bd4d7bad5fe0a70f31c89
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmInstallCommandArguments.cxx,v $
5 Language: C++
6 <<<<<<< cmInstallCommandArguments.cxx
7 Date: $Date: 2008/02/04 22:03:48 $
8 Version: $Revision: 1.4 $
9 =======
10 Date: $Date: 2008-03-26 22:30:34 $
11 Version: $Revision: 1.5 $
12 >>>>>>> 1.5
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #include "cmInstallCommandArguments.h"
23 #include "cmSystemTools.h"
25 // Table of valid permissions.
26 const char* cmInstallCommandArguments::PermissionsTable[] =
28 "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE",
29 "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE",
30 "WORLD_READ", "WORLD_WRITE", "WORLD_EXECUTE",
31 "SETUID", "SETGID", 0
34 const std::string cmInstallCommandArguments::EmptyString;
36 cmInstallCommandArguments::cmInstallCommandArguments()
37 :Parser()
38 ,ArgumentGroup()
39 ,Destination (&Parser, "DESTINATION" , &ArgumentGroup)
40 ,Component (&Parser, "COMPONENT" , &ArgumentGroup)
41 ,Rename (&Parser, "RENAME" , &ArgumentGroup)
42 ,Permissions (&Parser, "PERMISSIONS" , &ArgumentGroup)
43 ,Configurations(&Parser, "CONFIGURATIONS", &ArgumentGroup)
44 ,Optional (&Parser, "OPTIONAL" , &ArgumentGroup)
45 ,NamelinkOnly (&Parser, "NAMELINK_ONLY" , &ArgumentGroup)
46 ,NamelinkSkip (&Parser, "NAMELINK_SKIP" , &ArgumentGroup)
47 ,GenericArguments(0)
50 const std::string& cmInstallCommandArguments::GetDestination() const
52 if (!this->DestinationString.empty())
54 return this->DestinationString;
56 if (this->GenericArguments!=0)
58 return this->GenericArguments->GetDestination();
60 return this->EmptyString;
63 const std::string& cmInstallCommandArguments::GetComponent() const
65 if (!this->Component.GetString().empty())
67 return this->Component.GetString();
69 if (this->GenericArguments!=0)
71 return this->GenericArguments->GetComponent();
74 static std::string unspecifiedComponent = "Unspecified";
75 return unspecifiedComponent;
78 const std::string& cmInstallCommandArguments::GetRename() const
80 if (!this->Rename.GetString().empty())
82 return this->Rename.GetString();
84 if (this->GenericArguments!=0)
86 return this->GenericArguments->GetRename();
88 return this->EmptyString;
91 const std::string& cmInstallCommandArguments::GetPermissions() const
93 if (!this->PermissionsString.empty())
95 return this->PermissionsString;
97 if (this->GenericArguments!=0)
99 return this->GenericArguments->GetPermissions();
101 return this->EmptyString;
104 bool cmInstallCommandArguments::GetOptional() const
106 if (this->Optional.IsEnabled())
108 return true;
110 if (this->GenericArguments!=0)
112 return this->GenericArguments->GetOptional();
114 return false;
117 bool cmInstallCommandArguments::GetNamelinkOnly() const
119 if (this->NamelinkOnly.IsEnabled())
121 return true;
123 if (this->GenericArguments!=0)
125 return this->GenericArguments->GetNamelinkOnly();
127 return false;
130 bool cmInstallCommandArguments::GetNamelinkSkip() const
132 if (this->NamelinkSkip.IsEnabled())
134 return true;
136 if (this->GenericArguments!=0)
138 return this->GenericArguments->GetNamelinkSkip();
140 return false;
143 const std::vector<std::string>&
144 cmInstallCommandArguments::GetConfigurations() const
146 if (!this->Configurations.GetVector().empty())
148 return this->Configurations.GetVector();
150 if (this->GenericArguments!=0)
152 return this->GenericArguments->GetConfigurations();
154 return this->Configurations.GetVector();
158 bool cmInstallCommandArguments::Finalize()
160 if (!this->CheckPermissions())
162 return false;
164 this->DestinationString = this->Destination.GetString();
165 cmSystemTools::ConvertToUnixSlashes(this->DestinationString);
166 return true;
169 void cmInstallCommandArguments::Parse(const std::vector<std::string>* args,
170 std::vector<std::string>* unconsumedArgs)
172 this->Parser.Parse(args, unconsumedArgs);
176 bool cmInstallCommandArguments::CheckPermissions()
178 this->PermissionsString = "";
179 for(std::vector<std::string>::const_iterator
180 permIt = this->Permissions.GetVector().begin();
181 permIt != this->Permissions.GetVector().end();
182 ++permIt)
184 if (!this->CheckPermissions(*permIt, this->PermissionsString))
186 return false;
189 return true;
192 bool cmInstallCommandArguments::CheckPermissions(
193 const std::string& onePermission, std::string& permissions)
195 // Check the permission against the table.
196 for(const char** valid = cmInstallCommandArguments::PermissionsTable;
197 *valid; ++valid)
199 if(onePermission == *valid)
201 // This is a valid permission.
202 permissions += " ";
203 permissions += onePermission;
204 return true;
207 // This is not a valid permission.
208 return false;