1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmInstallCommandArguments.cxx,v $
6 Date: $Date: 2008-03-26 22:30:34 $
7 Version: $Revision: 1.5 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmInstallCommandArguments.h"
18 #include "cmSystemTools.h"
20 // Table of valid permissions.
21 const char* cmInstallCommandArguments::PermissionsTable
[] =
23 "OWNER_READ", "OWNER_WRITE", "OWNER_EXECUTE",
24 "GROUP_READ", "GROUP_WRITE", "GROUP_EXECUTE",
25 "WORLD_READ", "WORLD_WRITE", "WORLD_EXECUTE",
29 const std::string
cmInstallCommandArguments::EmptyString
;
31 cmInstallCommandArguments::cmInstallCommandArguments()
34 ,Destination (&Parser
, "DESTINATION" , &ArgumentGroup
)
35 ,Component (&Parser
, "COMPONENT" , &ArgumentGroup
)
36 ,Rename (&Parser
, "RENAME" , &ArgumentGroup
)
37 ,Permissions (&Parser
, "PERMISSIONS" , &ArgumentGroup
)
38 ,Configurations(&Parser
, "CONFIGURATIONS", &ArgumentGroup
)
39 ,Optional (&Parser
, "OPTIONAL" , &ArgumentGroup
)
40 ,NamelinkOnly (&Parser
, "NAMELINK_ONLY" , &ArgumentGroup
)
41 ,NamelinkSkip (&Parser
, "NAMELINK_SKIP" , &ArgumentGroup
)
45 const std::string
& cmInstallCommandArguments::GetDestination() const
47 if (!this->DestinationString
.empty())
49 return this->DestinationString
;
51 if (this->GenericArguments
!=0)
53 return this->GenericArguments
->GetDestination();
55 return this->EmptyString
;
58 const std::string
& cmInstallCommandArguments::GetComponent() const
60 if (!this->Component
.GetString().empty())
62 return this->Component
.GetString();
64 if (this->GenericArguments
!=0)
66 return this->GenericArguments
->GetComponent();
69 static std::string unspecifiedComponent
= "Unspecified";
70 return unspecifiedComponent
;
73 const std::string
& cmInstallCommandArguments::GetRename() const
75 if (!this->Rename
.GetString().empty())
77 return this->Rename
.GetString();
79 if (this->GenericArguments
!=0)
81 return this->GenericArguments
->GetRename();
83 return this->EmptyString
;
86 const std::string
& cmInstallCommandArguments::GetPermissions() const
88 if (!this->PermissionsString
.empty())
90 return this->PermissionsString
;
92 if (this->GenericArguments
!=0)
94 return this->GenericArguments
->GetPermissions();
96 return this->EmptyString
;
99 bool cmInstallCommandArguments::GetOptional() const
101 if (this->Optional
.IsEnabled())
105 if (this->GenericArguments
!=0)
107 return this->GenericArguments
->GetOptional();
112 bool cmInstallCommandArguments::GetNamelinkOnly() const
114 if (this->NamelinkOnly
.IsEnabled())
118 if (this->GenericArguments
!=0)
120 return this->GenericArguments
->GetNamelinkOnly();
125 bool cmInstallCommandArguments::GetNamelinkSkip() const
127 if (this->NamelinkSkip
.IsEnabled())
131 if (this->GenericArguments
!=0)
133 return this->GenericArguments
->GetNamelinkSkip();
138 const std::vector
<std::string
>&
139 cmInstallCommandArguments::GetConfigurations() const
141 if (!this->Configurations
.GetVector().empty())
143 return this->Configurations
.GetVector();
145 if (this->GenericArguments
!=0)
147 return this->GenericArguments
->GetConfigurations();
149 return this->Configurations
.GetVector();
153 bool cmInstallCommandArguments::Finalize()
155 if (!this->CheckPermissions())
159 this->DestinationString
= this->Destination
.GetString();
160 cmSystemTools::ConvertToUnixSlashes(this->DestinationString
);
164 void cmInstallCommandArguments::Parse(const std::vector
<std::string
>* args
,
165 std::vector
<std::string
>* unconsumedArgs
)
167 this->Parser
.Parse(args
, unconsumedArgs
);
171 bool cmInstallCommandArguments::CheckPermissions()
173 this->PermissionsString
= "";
174 for(std::vector
<std::string
>::const_iterator
175 permIt
= this->Permissions
.GetVector().begin();
176 permIt
!= this->Permissions
.GetVector().end();
179 if (!this->CheckPermissions(*permIt
, this->PermissionsString
))
187 bool cmInstallCommandArguments::CheckPermissions(
188 const std::string
& onePermission
, std::string
& permissions
)
190 // Check the permission against the table.
191 for(const char** valid
= cmInstallCommandArguments::PermissionsTable
;
194 if(onePermission
== *valid
)
196 // This is a valid permission.
198 permissions
+= onePermission
;
202 // This is not a valid permission.