Acacia
mac_data_types.h
1 #ifndef LIB_MAC_AXAPI_DATA_TYPES_H_
2 #define LIB_MAC_AXAPI_DATA_TYPES_H_
3 
4 #include <ostream>
5 
6 #include <ApplicationServices/ApplicationServices.h>
7 
8 namespace acacia {
9 
10 class AXAPINode;
11 template <typename T>
12 class ScopedCFTypeRef;
13 
18 enum class ValueType {
19  NOT_PRESENT,
20  UNKNOWN,
21  LIST,
24  BOOLEAN,
25  INT,
26  FLOAT,
27  STRING,
30  URL,
33  NODE,
36  POINT,
39  SIZE,
42  RECT,
45  RANGE,
48  DICTIONARY,
51  DATA,
54  TEXTMARKER,
61 };
62 
63 std::string ValueTypeToString(ValueType value_type);
64 
65 class Point {
66  public:
67  Point() {}
68  Point(const Point&) = default;
69  Point& operator=(const Point&) = default;
70  Point& operator=(Point&) = default;
71 
72  float x() { return x_; }
73  float y() { return y_; }
74 
75  std::string ToString();
76 
77  private:
78  Point(float x, float y) : x_(x), y_(y) {}
79 
80  float x_;
81  float y_;
82 
83  friend class AXAPINode;
84  friend class Rect;
85 };
86 
87 class Size {
88  public:
89  Size() {}
90  Size(const Size&) = default;
91  Size& operator=(const Size&) = default;
92  Size& operator=(Size&) = default;
93 
94  float width() { return width_; }
95  float height() { return height_; }
96 
97  std::string ToString();
98 
99  private:
100  Size(float width, float height) : width_(width), height_(height) {}
101 
102  float width_;
103  float height_;
104 
105  friend class AXAPINode;
106  friend class Rect;
107 };
108 
109 class Rect {
110  public:
111  Rect() {}
112  Rect(const Rect&) = default;
113  Rect& operator=(const Rect&) = default;
114  Rect& operator=(Rect&) = default;
115 
116  Point& origin() { return origin_; }
117  Size& size() { return size_; }
118 
119  std::string ToString();
120 
121  private:
122  Rect(Point origin, Size size) : origin_(origin), size_(size) {}
123  Rect(float x, float y, float width, float height)
124  : origin_(x, y), size_(width, height) {}
125 
126  Point origin_;
127  Size size_;
128 
129  friend class AXAPINode;
130 };
131 
132 class Range {
133  public:
134  Range() {}
135  Range(const Range&) = default;
136  Range& operator=(const Range&) = default;
137  Range& operator=(Range&) = default;
138 
139  int length() { return length_; }
140  int location() { return location_; }
141 
142  std::string ToString();
143 
144  private:
145  Range(int length, int location) : length_(length), location_(location) {}
146  int length_;
147  int location_;
148 
149  friend class AXAPINode;
150 };
151 
152 class Dictionary {
153  public:
154  Dictionary() {}
155  Dictionary(const Dictionary&) = default;
156  Dictionary& operator=(const Dictionary&) = default;
157  Dictionary& operator=(Dictionary&) = default;
158 
159  ~Dictionary();
160 
161  std::vector<std::string> keys();
162  ValueType getValueType(const std::string& key);
163 
164  std::string getStringValue(const std::string& key);
165  AXAPINode getNodeValue(const std::string& node);
166 
167  private:
168  explicit Dictionary(CFDictionaryRef cf_dictionary);
169  explicit Dictionary(ScopedCFTypeRef<CFDictionaryRef> cf_dictionary);
170 
171  CFDictionaryRef cf_dictionary_{NULL};
172 
173  friend class AXAPINode;
174 };
175 
176 } // namespace acacia
177 
178 #endif // LIB_MAC_AXAPI_DATA_TYPES_H_
Definition: axapi_node.h:63
Definition: mac_data_types.h:152
Definition: mac_data_types.h:65
Definition: mac_data_types.h:132
Definition: mac_data_types.h:109
Definition: axapi_node.h:21
Definition: mac_data_types.h:87
ValueType
Definition: mac_data_types.h:18