summaryrefslogtreecommitdiffstats
path: root/Source/cmXCodeObject.h
blob: 61cda1632f6fa2ac5e57e962948d44b5b81f5f92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef cmXCodeObject_h
#define cmXCodeObject_h

#include "cmStandardIncludes.h"
class cmTarget;

class cmXCodeObject
{
public:
  enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT };
  enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase, 
                 PBXSourcesBuildPhase, PBXFrameworksBuildPhase, 
                 PBXNativeTarget, PBXFileReference, PBXBuildFile, 
                 PBXContainerItemProxy, PBXTargetDependency,
                 PBXShellScriptBuildPhase, PBXResourcesBuildPhase,
                 PBXApplicationReference, PBXExecutableFileReference, 
                 PBXLibraryReference, PBXToolTarget, PBXLibraryTarget, 
                 PBXAggregateTarget,
                 None
  };
  static const char* PBXTypeNames[];
  ~cmXCodeObject();
  cmXCodeObject(PBXType ptype, Type type);
  void SetString(const char* s)
    {
      m_String = "\"";
      m_String += s;
      m_String += "\"";
    }
  
  void AddAttribute(const char* name, cmXCodeObject* value)
    {
      m_ObjectAttributes[name] = value;
    }
  
  void SetObject(cmXCodeObject* value)
    {
      m_Object = value;
    }
  void AddObject(cmXCodeObject* value)
    {
      m_List.push_back(value);
    }
  static void Indent(int level, std::ostream& out);
  void Print(std::ostream& out);
  static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out);
  const char* GetId()
    {
      return m_Id.c_str();
    }
  cmTarget* GetcmTarget()
    {
      return m_cmTarget;
    }
  void SetcmTarget(cmTarget* t)
    {
      m_cmTarget = t;
    }
  cmXCodeObject* GetObject(const char* name)
    {
      if(m_ObjectAttributes.count(name))
        {
        return m_ObjectAttributes[name];
        }
      return 0;
    }
  // serach the attribute list for an object of the specified type
  cmXCodeObject* GetObject(cmXCodeObject::PBXType t)
    {
      for(std::vector<cmXCodeObject*>::iterator i = m_List.begin();
          i != m_List.end(); ++i)
        {
        cmXCodeObject* o = *i;
        if(o->m_IsA == t)
          {
          return o;
          }
        }
      return 0;
    }
  
  cmXCodeObject* GetPBXTargetDependency()
    {
      return m_PBXTargetDependency;
    }
  void SetPBXTargetDependency(cmXCodeObject* d)
    {
      m_PBXTargetDependency = d;
    }
  
private:
  cmTarget* m_cmTarget;
  Type m_Type;
  cmStdString m_Id;
  PBXType m_IsA;
  cmStdString m_String;
  cmXCodeObject* m_Object;
  cmXCodeObject* m_PBXTargetDependency;
  std::vector<cmXCodeObject*> m_List;
  std::map<cmStdString, cmXCodeObject*> m_ObjectAttributes;
};
#endif