1
0

cmXCodeObject.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmXCodeObject_h
  11. #define cmXCodeObject_h
  12. #include "cmStandardIncludes.h"
  13. class cmGeneratorTarget;
  14. class cmXCodeObject
  15. {
  16. public:
  17. enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
  18. enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
  19. PBXSourcesBuildPhase, PBXFrameworksBuildPhase,
  20. PBXNativeTarget, PBXFileReference, PBXBuildFile,
  21. PBXContainerItemProxy, PBXTargetDependency,
  22. PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
  23. PBXApplicationReference, PBXExecutableFileReference,
  24. PBXLibraryReference, PBXToolTarget, PBXLibraryTarget,
  25. PBXAggregateTarget,XCBuildConfiguration,XCConfigurationList,
  26. PBXCopyFilesBuildPhase,
  27. None
  28. };
  29. class StringVec: public std::vector<std::string> {};
  30. static const char* PBXTypeNames[];
  31. virtual ~cmXCodeObject();
  32. cmXCodeObject(PBXType ptype, Type type);
  33. Type GetType() { return this->TypeValue;}
  34. PBXType GetIsA() { return this->IsA;}
  35. void SetString(const std::string& s);
  36. const std::string& GetString()
  37. {
  38. return this->String;
  39. }
  40. void AddAttribute(const std::string& name, cmXCodeObject* value)
  41. {
  42. this->ObjectAttributes[name] = value;
  43. }
  44. void SetObject(cmXCodeObject* value)
  45. {
  46. this->Object = value;
  47. }
  48. cmXCodeObject* GetObject()
  49. {
  50. return this->Object;
  51. }
  52. void AddObject(cmXCodeObject* value)
  53. {
  54. this->List.push_back(value);
  55. }
  56. bool HasObject(cmXCodeObject* o)
  57. {
  58. return !(std::find(this->List.begin(), this->List.end(), o)
  59. == this->List.end());
  60. }
  61. void AddUniqueObject(cmXCodeObject* value)
  62. {
  63. if(std::find(this->List.begin(), this->List.end(), value)
  64. == this->List.end())
  65. {
  66. this->List.push_back(value);
  67. }
  68. }
  69. static void Indent(int level, std::ostream& out);
  70. void Print(std::ostream& out);
  71. void PrintAttribute(std::ostream& out, const int level,
  72. const std::string separator, const int factor,
  73. const std::string& name, const cmXCodeObject* object,
  74. const cmXCodeObject* parent);
  75. virtual void PrintComment(std::ostream&) {}
  76. static void PrintList(std::vector<cmXCodeObject*> const&,
  77. std::ostream& out);
  78. const std::string& GetId()
  79. {
  80. return this->Id;
  81. }
  82. void SetId(const std::string& id)
  83. {
  84. this->Id = id;
  85. }
  86. cmGeneratorTarget* GetTarget()
  87. {
  88. return this->Target;
  89. }
  90. void SetTarget(cmGeneratorTarget* t)
  91. {
  92. this->Target = t;
  93. }
  94. const std::string& GetComment() {return this->Comment;}
  95. bool HasComment() { return (!this->Comment.empty());}
  96. cmXCodeObject* GetObject(const char* name)
  97. {
  98. if(this->ObjectAttributes.count(name))
  99. {
  100. return this->ObjectAttributes[name];
  101. }
  102. return 0;
  103. }
  104. // search the attribute list for an object of the specified type
  105. cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
  106. {
  107. for(std::vector<cmXCodeObject*>::iterator i = this->List.begin();
  108. i != this->List.end(); ++i)
  109. {
  110. cmXCodeObject* o = *i;
  111. if(o->IsA == t)
  112. {
  113. return o;
  114. }
  115. }
  116. return 0;
  117. }
  118. void CopyAttributes(cmXCodeObject* );
  119. void AddDependLibrary(const std::string& configName,
  120. const std::string& l)
  121. {
  122. this->DependLibraries[configName].push_back(l);
  123. }
  124. std::map<std::string, StringVec> const& GetDependLibraries()
  125. {
  126. return this->DependLibraries;
  127. }
  128. void AddDependTarget(const std::string& configName,
  129. const std::string& tName)
  130. {
  131. this->DependTargets[configName].push_back(tName);
  132. }
  133. std::map<std::string, StringVec> const& GetDependTargets()
  134. {
  135. return this->DependTargets;
  136. }
  137. std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
  138. void SetComment(const std::string& c) { this->Comment = c;}
  139. static void PrintString(std::ostream& os,std::string String);
  140. protected:
  141. void PrintString(std::ostream& os) const;
  142. cmGeneratorTarget* Target;
  143. Type TypeValue;
  144. std::string Id;
  145. PBXType IsA;
  146. int Version;
  147. std::string Comment;
  148. std::string String;
  149. cmXCodeObject* Object;
  150. std::vector<cmXCodeObject*> List;
  151. std::map<std::string, StringVec> DependLibraries;
  152. std::map<std::string, StringVec> DependTargets;
  153. std::map<std::string, cmXCodeObject*> ObjectAttributes;
  154. };
  155. #endif