CMake/Source/cmXCodeObject.h

161 lines
4.6 KiB
C
Raw Normal View History

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2007-07-27 14:55:24 +00:00
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
2007-07-27 14:55:24 +00:00
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
2005-01-24 22:35:54 +00:00
#ifndef cmXCodeObject_h
#define cmXCodeObject_h
2005-01-21 21:25:36 +00:00
#include "cmStandardIncludes.h"
2005-02-03 22:42:55 +00:00
class cmTarget;
2005-01-21 21:25:36 +00:00
class cmXCodeObject
{
public:
enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
2005-01-21 21:25:36 +00:00
enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
2005-02-03 22:42:55 +00:00
PBXSourcesBuildPhase, PBXFrameworksBuildPhase,
PBXNativeTarget, PBXFileReference, PBXBuildFile,
PBXContainerItemProxy, PBXTargetDependency,
PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
PBXApplicationReference, PBXExecutableFileReference,
PBXLibraryReference, PBXToolTarget, PBXLibraryTarget,
2005-09-02 20:29:32 +00:00
PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList,
2006-03-29 20:02:35 +00:00
PBXCopyFilesBuildPhase,
2005-01-21 21:25:36 +00:00
None
};
class StringVec: public std::vector<cmStdString> {};
2005-01-21 21:25:36 +00:00
static const char* PBXTypeNames[];
2005-09-05 13:17:59 +00:00
virtual ~cmXCodeObject();
2005-01-21 21:25:36 +00:00
cmXCodeObject(PBXType ptype, Type type);
2006-03-15 16:38:47 +00:00
Type GetType() { return this->TypeValue;}
2006-03-15 16:02:08 +00:00
PBXType GetIsA() { return this->IsA;}
2005-09-02 20:29:32 +00:00
void SetString(const char* s);
2005-02-08 22:12:38 +00:00
const char* GetString()
{
2006-03-15 16:02:08 +00:00
return this->String.c_str();
2005-02-08 22:12:38 +00:00
}
2005-01-21 21:25:36 +00:00
void AddAttribute(const char* name, cmXCodeObject* value)
{
2006-03-15 16:02:08 +00:00
this->ObjectAttributes[name] = value;
2005-01-21 21:25:36 +00:00
}
void SetObject(cmXCodeObject* value)
{
2006-03-15 16:02:08 +00:00
this->Object = value;
2005-01-21 21:25:36 +00:00
}
2005-02-07 22:36:34 +00:00
cmXCodeObject* GetObject()
{
2006-03-15 16:02:08 +00:00
return this->Object;
2005-02-07 22:36:34 +00:00
}
2005-01-21 21:25:36 +00:00
void AddObject(cmXCodeObject* value)
{
2006-03-15 16:02:08 +00:00
this->List.push_back(value);
2005-01-21 21:25:36 +00:00
}
2006-05-12 18:36:39 +00:00
bool HasObject(cmXCodeObject* o)
{
return !(std::find(this->List.begin(), this->List.end(), o)
== this->List.end());
}
void AddUniqueObject(cmXCodeObject* value)
2006-05-12 18:36:39 +00:00
{
if(std::find(this->List.begin(), this->List.end(), value)
== this->List.end())
{
this->List.push_back(value);
}
}
2005-01-24 22:35:54 +00:00
static void Indent(int level, std::ostream& out);
2005-01-21 21:25:36 +00:00
void Print(std::ostream& out);
2005-09-02 20:29:32 +00:00
virtual void PrintComment(std::ostream&) {};
2006-05-12 18:36:39 +00:00
static void PrintList(std::vector<cmXCodeObject*> const&,
std::ostream& out);
2005-01-21 21:25:36 +00:00
const char* GetId()
{
2006-03-15 16:02:08 +00:00
return this->Id.c_str();
2005-01-21 21:25:36 +00:00
}
2006-03-15 16:38:47 +00:00
cmTarget* GetTarget()
2005-02-03 22:42:55 +00:00
{
2006-03-15 16:38:47 +00:00
return this->Target;
2005-02-03 22:42:55 +00:00
}
2006-03-15 16:38:47 +00:00
void SetTarget(cmTarget* t)
2005-02-03 22:42:55 +00:00
{
2006-03-15 16:38:47 +00:00
this->Target = t;
2005-02-03 22:42:55 +00:00
}
2006-03-15 16:02:08 +00:00
const char* GetComment() {return this->Comment.c_str();}
bool HasComment() { return (this->Comment.size() != 0);}
2005-02-03 22:42:55 +00:00
cmXCodeObject* GetObject(const char* name)
{
2006-03-15 16:02:08 +00:00
if(this->ObjectAttributes.count(name))
2005-02-03 22:42:55 +00:00
{
2006-03-15 16:02:08 +00:00
return this->ObjectAttributes[name];
2005-02-03 22:42:55 +00:00
}
return 0;
}
2005-02-04 22:58:58 +00:00
// serach the attribute list for an object of the specified type
cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
{
2006-03-15 16:02:08 +00:00
for(std::vector<cmXCodeObject*>::iterator i = this->List.begin();
i != this->List.end(); ++i)
2005-02-04 22:58:58 +00:00
{
cmXCodeObject* o = *i;
2006-03-15 16:38:47 +00:00
if(o->IsA == t)
2005-02-04 22:58:58 +00:00
{
return o;
}
}
return 0;
}
cmXCodeObject* GetPBXTargetDependency()
{
2006-03-15 16:38:47 +00:00
return this->PBXTargetDependencyValue;
2005-02-04 22:58:58 +00:00
}
void SetPBXTargetDependency(cmXCodeObject* d)
{
2006-03-15 16:38:47 +00:00
this->PBXTargetDependencyValue = d;
2005-02-04 22:58:58 +00:00
}
2005-02-07 22:36:34 +00:00
void CopyAttributes(cmXCodeObject* );
2005-02-03 22:42:55 +00:00
void AddDependLibrary(const char* configName,
const char* l)
{
if(!configName)
{
configName = "";
}
2006-03-15 16:02:08 +00:00
this->DependLibraries[configName].push_back(l);
}
std::map<cmStdString, StringVec> const& GetDependLibraries()
{
2006-03-15 16:02:08 +00:00
return this->DependLibraries;
}
2006-03-15 16:02:08 +00:00
std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
void SetComment(const char* c) { this->Comment = c;}
2005-09-02 20:29:32 +00:00
protected:
void PrintString(std::ostream& os) const;
2006-03-15 16:38:47 +00:00
cmTarget* Target;
Type TypeValue;
2006-03-15 16:02:08 +00:00
cmStdString Id;
PBXType IsA;
int Version;
cmStdString Comment;
cmStdString String;
cmXCodeObject* Object;
2006-03-15 16:38:47 +00:00
cmXCodeObject* PBXTargetDependencyValue;
2006-03-15 16:02:08 +00:00
std::vector<cmXCodeObject*> List;
std::map<cmStdString, StringVec> DependLibraries;
std::map<cmStdString, cmXCodeObject*> ObjectAttributes;
2005-01-21 21:25:36 +00:00
};
2005-01-24 22:35:54 +00:00
#endif