1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmXCodeObject.h,v $
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"
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
,
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
)
60 cmXCodeObject
* GetObject()
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
)
73 void AddUniqueObject(cmXCodeObject
* value
)
75 if(std::find(this->List
.begin(), this->List
.end(), value
)
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&,
89 return this->Id
.c_str();
95 void SetTarget(cmTarget
* 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
];
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
;
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
,
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
;}
150 void PrintString(std::ostream
& os
) const;
159 cmXCodeObject
* Object
;
160 cmXCodeObject
* PBXTargetDependencyValue
;
161 std::vector
<cmXCodeObject
*> List
;
162 std::map
<cmStdString
, StringVec
> DependLibraries
;
163 std::map
<cmStdString
, cmXCodeObject
*> ObjectAttributes
;