Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmListCommand.h
blobdd37f77cd9883bf6a9b86fb0855498847fbc85a8
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmListCommand.h,v $
5 Language: C++
6 Date: $Date: 2008-03-12 21:02:10 $
7 Version: $Revision: 1.15 $
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 #ifndef cmListCommand_h
18 #define cmListCommand_h
20 #include "cmCommand.h"
22 /** \class cmListCommand
23 * \brief Common list operations
26 class cmListCommand : public cmCommand
28 public:
29 /**
30 * This is a virtual constructor for the command.
32 virtual cmCommand* Clone()
34 return new cmListCommand;
37 /**
38 * This is called when the command is first encountered in
39 * the CMakeLists.txt file.
41 virtual bool InitialPass(std::vector<std::string> const& args,
42 cmExecutionStatus &status);
44 /**
45 * This determines if the command is invoked when in script mode.
47 virtual bool IsScriptable() { return true; }
49 /**
50 * The name of the command as specified in CMakeList.txt.
52 virtual const char* GetName() { return "list";}
54 /**
55 * Succinct documentation.
57 virtual const char* GetTerseDocumentation()
59 return "List operations.";
62 /**
63 * More documentation.
65 virtual const char* GetFullDocumentation()
67 return
68 " list(LENGTH <list> <output variable>)\n"
69 " list(GET <list> <element index> [<element index> ...] "
70 "<output variable>)\n"
71 " list(APPEND <list> <element> [<element> ...])\n"
72 " list(FIND <list> <value> <output variable>)\n"
73 " list(INSERT <list> <element_index> <element> [<element> ...])\n"
74 " list(REMOVE_ITEM <list> <value> [<value> ...])\n"
75 " list(REMOVE_AT <list> <index> [<index> ...])\n"
76 " list(REMOVE_DUPLICATES <list>)\n"
77 " list(REVERSE <list>)\n"
78 " list(SORT <list>)\n"
79 "LENGTH will return a given list's length.\n"
80 "GET will return list of elements specified by indices from the list.\n"
81 "APPEND will append elements to the list.\n"
82 "FIND will return the index of the element specified in the list or -1 "
83 "if it wasn't found.\n"
84 "INSERT will insert elements to the list to the specified location.\n"
85 "REMOVE_AT and REMOVE_ITEM will remove items from the list. The "
86 "difference is that REMOVE_ITEM will remove the given items, while "
87 "REMOVE_AT will remove the items at the given indices.\n"
88 "REMOVE_DUPLICATES will remove duplicated items in the list.\n"
89 "REVERSE reverses the contents of the list in-place.\n"
90 "SORT sorts the list in-place alphabetically.\n"
91 "NOTES: A list in cmake is a ; separated group of strings. "
92 "To create a list the set command can be used. For example, "
93 "set(var a b c d e) creates a list with a;b;c;d;e, and "
94 "set(var \"a b c d e\") creates a string or a list with one "
95 "item in it.\n"
96 "When specifying index values, if <element index> is 0 or"
97 " greater, it is indexed from the "
98 "beginning of the list, with 0 representing the first list element. "
99 "If <element index> is -1 or lesser, it is indexed from the end of "
100 "the list, with -1 representing the last list element. Be careful "
101 "when counting with negative indices: they do not start from 0. "
102 "-0 is equivalent to 0, the first list element.\n"
106 cmTypeMacro(cmListCommand, cmCommand);
107 protected:
108 bool HandleLengthCommand(std::vector<std::string> const& args);
109 bool HandleGetCommand(std::vector<std::string> const& args);
110 bool HandleAppendCommand(std::vector<std::string> const& args);
111 bool HandleFindCommand(std::vector<std::string> const& args);
112 bool HandleInsertCommand(std::vector<std::string> const& args);
113 bool HandleRemoveAtCommand(std::vector<std::string> const& args);
114 bool HandleRemoveItemCommand(std::vector<std::string> const& args);
115 bool HandleRemoveDuplicatesCommand(std::vector<std::string> const& args);
116 bool HandleSortCommand(std::vector<std::string> const& args);
117 bool HandleReverseCommand(std::vector<std::string> const& args);
120 bool GetList(std::vector<std::string>& list, const char* var);
121 bool GetListString(std::string& listString, const char* var);
125 #endif