-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml_nodes.h
More file actions
210 lines (171 loc) · 5.22 KB
/
Copy pathxml_nodes.h
File metadata and controls
210 lines (171 loc) · 5.22 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* File: xml_nodes.h
* Author: Arthur Lisek-Koper
* e-mail: arthur_lisekkoper@student.uml.edu
*
* Created on October 22, 2014, 9:00 AM
* Last modified on October 23, 2014.
*
* This code is a node within a tree containing data from an xml document.
*/
#ifndef XML_NODES_H
#define XML_NODES_H
#include <string>
#include <fstream>
#include "Attribute.h"
using namespace std;
/**
* class xml_node is a data container for class xml_data.
*/
class xml_node {
private:
///name of xml tag.
string str_name;
///The content of an element.
string content;
///Line number of the xml tag.
int num_line;
///Number of children this object currently has.
int size_child;
///Number of attributes this object holds.
int size_attr;
///The current level of the object within the tree.
unsigned int level;
///Pointer to the parent of this object. If object is the root element,
/// then the object points to itself.
xml_node* parent;
///Pointers to the list of all children this object currently has.
list<xml_node*> list_child;
///Pointers to the list of all attributes attached to this object, if any.
list<Attribute*> list_attr;
public:
///Default constructor created by Netbeans.
xml_node();
/**
* Constructor which assigns the given name and which line the element was
* found.
*
* @param name - Name of the found element within the xml document.
* @param line - Which line within the xml document was the element found.
*/
xml_node(string name, int line);
/**
* Constructor which assigns the given name, which line the element was
* found, and the parent object if the node is part of a tree structure.
*
* @param name - Name of the found element within the xml document.
* @param line - Which line within the xml document was the element found.
* @param father - Pointer to the parent object of this node within a tree.
*/
xml_node(string name, int line, xml_node* father);
///Default copy constructor created by Netbeans.
xml_node(const xml_node& orig);
///Default destructor created by Netbeans.
virtual ~xml_node();
/**
* Print out all private member variables.
*/
void toString();
/**
* Print out member variables in JSON format.
*
* @param JSON_file - file location where JSON data will be stored.
*/
void toJSON( ofstream* JSON_file );
/**
* Prints out onto the display a number of spaces in each new line
* while converting xml data to a JSON file.
*
* @param loc_file - location of the JSON file to be edited.
*
* @param INDENT_FACTOR - how many spaces each indent should be.
*
* @see toJSON
*/
void print_spaces( ofstream* loc_file, int INDENT_FACTOR = 2 );
/**
* Push the passed attribute information into a list of 'Attribute' objects.
*
* @param attr_name - string containing the name of the attribute.
* @param attr_value - string containing the value of the attribute.
* @return - EXIT_SUCCESS or EXIT_FAILURE;
*/
int push_attr(string attr_name, string attr_value);
/**
* Push an xml_node as a child to this object.
*
* @param child - the xml_node* to be pushed.
*/
void push_child(xml_node* child);
/**
* Setter function for 'num_line'
* @param new content of 'num_line' to be set.
*/
void setNum_line(int num_line);
/**
* Getter function for 'num_line'
* @return the content of 'num_line'.
*/
int getNum_line() const;
/**
* Setter function for 'str_name'
* @param new content of 'str_name' to be set.
*/
void setStr_name(string str_name);
/**
* Getter function for 'str_name'
* @return the content of 'str_name'.
*/
string getStr_name() const;
/**
* Setter function for 'size_attr'
* @param new content of 'size_attr' to be set.
*/
void setSize_attr(int size_attr);
/**
* Getter function for 'size_attr'
* @return the content of 'size_attr'.
*/
int getSize_attr() const;
/**
* Setter function for 'parent'
* @param new content of 'parent' to be set.
*/
void setParent(xml_node* parent);
/**
* Getter function for 'parent'
* @return the content of 'parent'.
*/
xml_node* getParent() const;
/**
* Setter function for 'size_child'
* @param new content of 'size_child' to be set.
*/
void setSize_child(int size_child);
/**
* Getter function for 'size_child'
* @return the content of 'size_child'.
*/
int getSize_child() const;
/**
* Setter function for 'content'
* @param new content of 'content' to be set.
*/
void setContent(string content);
/**
* Getter function for 'content'
* @return the content of 'content'.
*/
string getContent() const;
/**
* Setter function for 'level'
* @param new content of 'level' to be set.
*/
void setLevel(unsigned int level);
/**
* Getter function for 'level'
* @return the content of 'level'.
*/
unsigned int getLevel() const;
};
#endif /* XML_NODES_H */