STYLE: Fix typo in GetFilenameLastExtension docs
[cmake.git] / Source / cmXCodeObject.h
blobc4978c868e74ab921fbfc327af6a23a8bb179625
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmXCodeObject.h,v $
5 Language: C++
6 Date: $Date: 2008-09-02 14:27:15 $
7 Version: $Revision: 1.19 $
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 cmXCodeObject_h
18 #define cmXCodeObject_h
20 #include "cmStandardIncludes.h"
21 class cmTarget;
23 class cmXCodeObject
25 public:
26 enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
27 enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
28 PBXSourcesBuildPhase, PBXFrameworksBuildPhase,
29 PBXNativeTarget, PBXFileReference, PBXBuildFile,
30 PBXContainerItemProxy, PBXTargetDependency,
31 PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
32 PBXApplicationReference, PBXExecutableFileReference,
33 PBXLibraryReference, PBXToolTarget, PBXLibraryTarget,
34 PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList,
35 PBXCopyFilesBuildPhase,
36 None
38 class StringVec: public std::vector<cmStdString> {};
39 static const char* PBXTypeNames[];
40 virtual ~cmXCodeObject();
41 cmXCodeObject(PBXType ptype, Type type);
42 Type GetType() { return this->TypeValue;}
43 PBXType GetIsA() { return this->IsA;}
45 void SetString(const char* s);
46 const char* GetString()
48 return this->String.c_str();
51 void AddAttribute(const char* name, cmXCodeObject* value)
53 this->ObjectAttributes[name] = value;
56 void SetObject(cmXCodeObject* value)
58 this->Object = value;
60 cmXCodeObject* GetObject()
62 return this->Object;
64 void AddObject(cmXCodeObject* value)
66 this->List.push_back(value);
68 bool HasObject(cmXCodeObject* o)
70 return !(std::find(this->List.begin(), this->List.end(), o)
71 == this->List.end());
73 void AddUniqueObject(cmXCodeObject* value)
75 if(std::find(this->List.begin(), this->List.end(), value)
76 == this->List.end())
78 this->List.push_back(value);
81 static void Indent(int level, std::ostream& out);
82 void Print(std::ostream& out);
83 virtual void PrintComment(std::ostream&) {};
85 static void PrintList(std::vector<cmXCodeObject*> const&,
86 std::ostream& out);
87 const char* GetId()
89 return this->Id.c_str();
91 cmTarget* GetTarget()
93 return this->Target;
95 void SetTarget(cmTarget* t)
97 this->Target = t;
99 const char* GetComment() {return this->Comment.c_str();}
100 bool HasComment() { return (this->Comment.size() != 0);}
101 cmXCodeObject* GetObject(const char* name)
103 if(this->ObjectAttributes.count(name))
105 return this->ObjectAttributes[name];
107 return 0;
109 // serach the attribute list for an object of the specified type
110 cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
112 for(std::vector<cmXCodeObject*>::iterator i = this->List.begin();
113 i != this->List.end(); ++i)
115 cmXCodeObject* o = *i;
116 if(o->IsA == t)
118 return o;
121 return 0;
124 cmXCodeObject* GetPBXTargetDependency()
126 return this->PBXTargetDependencyValue;
128 void SetPBXTargetDependency(cmXCodeObject* d)
130 this->PBXTargetDependencyValue = d;
132 void CopyAttributes(cmXCodeObject* );
134 void AddDependLibrary(const char* configName,
135 const char* l)
137 if(!configName)
139 configName = "";
141 this->DependLibraries[configName].push_back(l);
143 std::map<cmStdString, StringVec> const& GetDependLibraries()
145 return this->DependLibraries;
147 std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
148 void SetComment(const char* c) { this->Comment = c;}
149 protected:
150 void PrintString(std::ostream& os) const;
152 cmTarget* Target;
153 Type TypeValue;
154 cmStdString Id;
155 PBXType IsA;
156 int Version;
157 cmStdString Comment;
158 cmStdString String;
159 cmXCodeObject* Object;
160 cmXCodeObject* PBXTargetDependencyValue;
161 std::vector<cmXCodeObject*> List;
162 std::map<cmStdString, StringVec> DependLibraries;
163 std::map<cmStdString, cmXCodeObject*> ObjectAttributes;
165 #endif