summaryrefslogtreecommitdiffstats
path: root/Source/cmListCommand.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-08-22 14:16:46 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-08-22 14:16:46 (GMT)
commitc9eaf72567b13cd587e9d5d1d1b0ad17e43a274f (patch)
tree9c952d0c8bb8135997e44fcfbeff644e81e8417f /Source/cmListCommand.cxx
parent6f7bb4d826863ba9f0996a12854ed2ff61915b13 (diff)
downloadCMake-c9eaf72567b13cd587e9d5d1d1b0ad17e43a274f.zip
CMake-c9eaf72567b13cd587e9d5d1d1b0ad17e43a274f.tar.gz
CMake-c9eaf72567b13cd587e9d5d1d1b0ad17e43a274f.tar.bz2
BUG: Add missing API
Diffstat (limited to 'Source/cmListCommand.cxx')
-rw-r--r--Source/cmListCommand.cxx78
1 files changed, 78 insertions, 0 deletions
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index bc43ecb..017b703 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -54,6 +54,14 @@ bool cmListCommand::InitialPass(std::vector<std::string> const& args)
{
return this->HandleRemoveItemCommand(args);
}
+ if(subCommand == "SORT")
+ {
+ return this->HandleSortCommand(args);
+ }
+ if(subCommand == "REVERSE")
+ {
+ return this->HandleReverseCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
this->SetError(e.c_str());
@@ -303,6 +311,76 @@ bool cmListCommand
}
//----------------------------------------------------------------------------
+bool cmListCommand
+::HandleReverseCommand(std::vector<std::string> const& args)
+{
+ if(args.size() < 2)
+ {
+ this->SetError("sub-command REVERSE requires a list as an argument.");
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ {
+ this->SetError("sub-command REVERSE requires list to be present.");
+ return false;
+ }
+
+ std::string value;
+ std::vector<std::string>::reverse_iterator it;
+ for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it )
+ {
+ if (value.size())
+ {
+ value += ";";
+ }
+ value += it->c_str();
+ }
+
+ this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmListCommand
+::HandleSortCommand(std::vector<std::string> const& args)
+{
+ if(args.size() < 2)
+ {
+ this->SetError("sub-command SORT requires a list as an argument.");
+ return false;
+ }
+
+ const std::string& listName = args[1];
+ // expand the variable
+ std::vector<std::string> varArgsExpanded;
+ if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ {
+ this->SetError("sub-command SORT requires list to be present.");
+ return false;
+ }
+
+ std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
+
+ std::string value;
+ std::vector<std::string>::iterator it;
+ for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
+ {
+ if (value.size())
+ {
+ value += ";";
+ }
+ value += it->c_str();
+ }
+
+ this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmListCommand::HandleRemoveAtCommand(
std::vector<std::string> const& args)
{