Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmListCommand.h
blobb93fbe110e2c4916c61347f6aab302d75043f681
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmListCommand.h,v $
5 Language: C++
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.14 $
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(REVERSE <list>)\n"
77 " list(SORT <list>)\n"
78 "LENGTH will return a given list's length.\n"
79 "GET will return list of elements specified by indices from the list.\n"
80 "APPEND will append elements to the list.\n"
81 "FIND will return the index of the element specified in the list or -1 "
82 "if it wasn't found.\n"
83 "INSERT will insert elements to the list to the specified location.\n"
84 "REMOVE_AT and REMOVE_ITEM will remove items from the list. The "
85 "difference is that REMOVE_ITEM will remove the given items, while "
86 "REMOVE_AT will remove the items at the given indices.\n"
87 "REVERSE reverses the contents of the list in-place.\n"
88 "SORT sorts the list in-place alphabetically.\n"
89 "NOTES: A list in cmake is a ; separated group of strings. "
90 "To create a list the set command can be used. For example, "
91 "set(var a b c d e) creates a list with a;b;c;d;e, and "
92 "set(var \"a b c d e\") creates a string or a list with one "
93 "item in it.\n"
94 "When specifying index values, if <element index> is 0 or"
95 " greater, it is indexed from the "
96 "beginning of the list, with 0 representing the first list element. "
97 "If <element index> is -1 or lesser, it is indexed from the end of "
98 "the list, with -1 representing the last list element. Be careful "
99 "when counting with negative indices: they do not start from 0. "
100 "-0 is equivalent to 0, the first list element.\n"
104 cmTypeMacro(cmListCommand, cmCommand);
105 protected:
106 bool HandleLengthCommand(std::vector<std::string> const& args);
107 bool HandleGetCommand(std::vector<std::string> const& args);
108 bool HandleAppendCommand(std::vector<std::string> const& args);
109 bool HandleFindCommand(std::vector<std::string> const& args);
110 bool HandleInsertCommand(std::vector<std::string> const& args);
111 bool HandleRemoveAtCommand(std::vector<std::string> const& args);
112 bool HandleRemoveItemCommand(std::vector<std::string> const& args);
113 bool HandleSortCommand(std::vector<std::string> const& args);
114 bool HandleReverseCommand(std::vector<std::string> const& args);
117 bool GetList(std::vector<std::string>& list, const char* var);
118 bool GetListString(std::string& listString, const char* var);
122 #endif