Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmXCodeObject.h
blob5257f19a969a44116035a71950d16515f11eb318
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmXCodeObject.h,v $
5 Language: C++
6 <<<<<<< cmXCodeObject.h
7 Date: $Date: 2007/07/27 14:55:24 $
8 Version: $Revision: 1.18 $
9 =======
10 Date: $Date: 2008-09-02 14:27:15 $
11 Version: $Revision: 1.19 $
12 >>>>>>> 1.19
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 #ifndef cmXCodeObject_h
23 #define cmXCodeObject_h
25 #include "cmStandardIncludes.h"
26 class cmTarget;
28 class cmXCodeObject
30 public:
31 enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
32 enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
33 PBXSourcesBuildPhase, PBXFrameworksBuildPhase,
34 PBXNativeTarget, PBXFileReference, PBXBuildFile,
35 PBXContainerItemProxy, PBXTargetDependency,
36 PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
37 PBXApplicationReference, PBXExecutableFileReference,
38 PBXLibraryReference, PBXToolTarget, PBXLibraryTarget,
39 PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList,
40 PBXCopyFilesBuildPhase,
41 None
43 class StringVec: public std::vector<cmStdString> {};
44 static const char* PBXTypeNames[];
45 virtual ~cmXCodeObject();
46 cmXCodeObject(PBXType ptype, Type type);
47 Type GetType() { return this->TypeValue;}
48 PBXType GetIsA() { return this->IsA;}
50 void SetString(const char* s);
51 const char* GetString()
53 return this->String.c_str();
56 void AddAttribute(const char* name, cmXCodeObject* value)
58 this->ObjectAttributes[name] = value;
61 void SetObject(cmXCodeObject* value)
63 this->Object = value;
65 cmXCodeObject* GetObject()
67 return this->Object;
69 void AddObject(cmXCodeObject* value)
71 this->List.push_back(value);
73 bool HasObject(cmXCodeObject* o)
75 return !(std::find(this->List.begin(), this->List.end(), o)
76 == this->List.end());
78 void AddUniqueObject(cmXCodeObject* value)
80 if(std::find(this->List.begin(), this->List.end(), value)
81 == this->List.end())
83 this->List.push_back(value);
86 static void Indent(int level, std::ostream& out);
87 void Print(std::ostream& out);
88 virtual void PrintComment(std::ostream&) {};
90 static void PrintList(std::vector<cmXCodeObject*> const&,
91 std::ostream& out);
92 const char* GetId()
94 return this->Id.c_str();
96 cmTarget* GetTarget()
98 return this->Target;
100 void SetTarget(cmTarget* t)
102 this->Target = t;
104 const char* GetComment() {return this->Comment.c_str();}
105 bool HasComment() { return (this->Comment.size() != 0);}
106 cmXCodeObject* GetObject(const char* name)
108 if(this->ObjectAttributes.count(name))
110 return this->ObjectAttributes[name];
112 return 0;
114 // serach the attribute list for an object of the specified type
115 cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
117 for(std::vector<cmXCodeObject*>::iterator i = this->List.begin();
118 i != this->List.end(); ++i)
120 cmXCodeObject* o = *i;
121 if(o->IsA == t)
123 return o;
126 return 0;
129 cmXCodeObject* GetPBXTargetDependency()
131 return this->PBXTargetDependencyValue;
133 void SetPBXTargetDependency(cmXCodeObject* d)
135 this->PBXTargetDependencyValue = d;
137 void CopyAttributes(cmXCodeObject* );
139 void AddDependLibrary(const char* configName,
140 const char* l)
142 if(!configName)
144 configName = "";
146 this->DependLibraries[configName].push_back(l);
148 std::map<cmStdString, StringVec> const& GetDependLibraries()
150 return this->DependLibraries;
152 std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
153 void SetComment(const char* c) { this->Comment = c;}
154 protected:
155 void PrintString(std::ostream& os) const;
157 cmTarget* Target;
158 Type TypeValue;
159 cmStdString Id;
160 PBXType IsA;
161 int Version;
162 cmStdString Comment;
163 cmStdString String;
164 cmXCodeObject* Object;
165 cmXCodeObject* PBXTargetDependencyValue;
166 std::vector<cmXCodeObject*> List;
167 std::map<cmStdString, StringVec> DependLibraries;
168 std::map<cmStdString, cmXCodeObject*> ObjectAttributes;
170 #endif