cmXCodeObject.cxx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #include "cmXCodeObject.h"
  2. const char* cmXCodeObject::PBXTypeNames[] = {
  3. "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase",
  4. "PBXSourcesBuildPhase", "PBXFrameworksBuildPhase", "PBXNativeTarget",
  5. "PBXFileReference", "PBXBuildFile", "PBXContainerItemProxy", "PBXTargetDependency",
  6. "PBXShellScriptBuildPhase", "PBXResourcesBuildPhase", "PBXApplicationReference",
  7. "PBXExecutableFileReference", "PBXLibraryReference", "PBXToolTarget", "PBXLibraryTarget",
  8. "None"
  9. };
  10. std::vector<cmXCodeObject*> cmXCodeObject::s_AllObjects;
  11. cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
  12. {
  13. m_IsA = ptype;
  14. cmOStringStream str;
  15. str << (void*)this;
  16. m_Id = str.str();
  17. m_Type = type;
  18. cmXCodeObject::s_AllObjects.push_back(this);
  19. }
  20. void cmXCodeObject::Indent(int level, std::ostream& out)
  21. {
  22. while(level)
  23. {
  24. out << " ";
  25. level--;
  26. }
  27. }
  28. void cmXCodeObject::Print(std::ostream& out)
  29. {
  30. this->Indent(1, out);
  31. out << m_Id << " = {\n";
  32. std::map<cmStdString, cmXCodeObject*>::iterator i;
  33. for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i)
  34. {
  35. cmXCodeObject* object = i->second;
  36. if(object->m_Type == OBJECT_LIST)
  37. {
  38. this->Indent(2, out);
  39. out << i->first << " = {\n";
  40. for(unsigned int k = 0; k < i->second->m_List.size(); k++)
  41. {
  42. this->Indent(3, out);
  43. out << i->second->m_List[k]->m_Id << ",\n";
  44. }
  45. this->Indent(2, out);
  46. out << "};\n";
  47. }
  48. else if(object->m_Type == ATTRIBUTE_GROUP)
  49. {
  50. std::map<cmStdString, cmStdString>::iterator j;
  51. this->Indent(2, out);
  52. out << i->first << " = {\n";
  53. for(j = object->m_StringAttributes.begin(); j != object->m_StringAttributes.end(); ++j)
  54. {
  55. this->Indent(3, out);
  56. out << j->first << " = " << j->second << ";\n";
  57. }
  58. this->Indent(2, out);
  59. out << " }\n";
  60. }
  61. else if(object->m_Type == OBJECT_REF)
  62. {
  63. this->Indent(2, out);
  64. out << i->first << " = " << object->m_Object->m_Id << ";\n";
  65. }
  66. }
  67. this->Indent(2, out);
  68. out << "isa = " << PBXTypeNames[m_IsA] << ";\n";
  69. std::map<cmStdString, cmStdString>::iterator j;
  70. for(j = m_StringAttributes.begin(); j != m_StringAttributes.end(); ++j)
  71. {
  72. this->Indent(2, out);
  73. out << j->first << " = " << j->second << ";\n";
  74. }
  75. this->Indent(1, out);
  76. out << "};\n";
  77. }
  78. void cmXCodeObject::PrintAll(std::ostream& out)
  79. {
  80. out << "objects = {\n";
  81. for(unsigned int i = 0; i < s_AllObjects.size(); ++i)
  82. {
  83. if(s_AllObjects[i]->m_Type == OBJECT)
  84. {
  85. s_AllObjects[i]->Print(out);
  86. }
  87. }
  88. out << "};\n";
  89. }