cmXCodeObject.cxx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. //----------------------------------------------------------------------------
  11. cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
  12. {
  13. m_IsA = ptype;
  14. cmOStringStream str;
  15. str << (void*)this;
  16. str << (void*)this;
  17. str << (void*)this;
  18. m_Id = str.str();
  19. m_Type = type;
  20. if(m_Type == OBJECT)
  21. {
  22. this->AddAttribute("isa", 0);
  23. }
  24. }
  25. //----------------------------------------------------------------------------
  26. void cmXCodeObject::Indent(int level, std::ostream& out)
  27. {
  28. while(level)
  29. {
  30. out << " ";
  31. level--;
  32. }
  33. }
  34. //----------------------------------------------------------------------------
  35. void cmXCodeObject::Print(std::ostream& out)
  36. {
  37. cmXCodeObject::Indent(2, out);
  38. out << m_Id << " = {\n";
  39. std::map<cmStdString, cmXCodeObject*>::iterator i;
  40. for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i)
  41. {
  42. cmXCodeObject* object = i->second;
  43. cmXCodeObject::Indent(3, out);
  44. if(i->first == "isa")
  45. {
  46. out << i->first << " = " << PBXTypeNames[m_IsA] << ";\n";
  47. }
  48. else if(object->m_Type == OBJECT_LIST)
  49. {
  50. out << i->first << " = {\n";
  51. for(unsigned int k = 0; k < i->second->m_List.size(); k++)
  52. {
  53. cmXCodeObject::Indent(4, out);
  54. out << i->second->m_List[k]->m_Id << ",\n";
  55. }
  56. cmXCodeObject::Indent(3, out);
  57. out << "};\n";
  58. }
  59. else if(object->m_Type == ATTRIBUTE_GROUP)
  60. {
  61. std::map<cmStdString, cmXCodeObject*>::iterator j;
  62. out << i->first << " = {\n";
  63. for(j = object->m_ObjectAttributes.begin(); j != object->m_ObjectAttributes.end(); ++j)
  64. {
  65. cmXCodeObject::Indent(4, out);
  66. out << j->first << " = " << j->second->m_String << ";\n";
  67. }
  68. cmXCodeObject::Indent(3, out);
  69. out << "};\n";
  70. }
  71. else if(object->m_Type == OBJECT_REF)
  72. {
  73. out << i->first << " = " << object->m_Object->m_Id << ";\n";
  74. }
  75. else if(object->m_Type == STRING)
  76. {
  77. out << i->first << " = " << object->m_String << ";\n";
  78. }
  79. else
  80. {
  81. out << "what is this?? " << i->first << "\n";
  82. }
  83. }
  84. cmXCodeObject::Indent(2, out);
  85. out << "};\n";
  86. }
  87. //----------------------------------------------------------------------------
  88. void cmXCodeObject::PrintList(std::vector<cmXCodeObject*> const& objs,
  89. std::ostream& out)
  90. {
  91. cmXCodeObject::Indent(1, out);
  92. out << "objects = {\n";
  93. for(unsigned int i = 0; i < objs.size(); ++i)
  94. {
  95. if(objs[i]->m_Type == OBJECT)
  96. {
  97. objs[i]->Print(out);
  98. }
  99. }
  100. cmXCodeObject::Indent(1, out);
  101. out << "};\n";
  102. }