forked from endless-sky/endless-sky-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataNode.h
50 lines (35 loc) · 1.46 KB
/
DataNode.h
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
/* DataNode.h
Copyright (c) 2014 by Michael Zahniser
Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
#ifndef DATA_NODE_H_
#define DATA_NODE_H_
#include <QString>
#include <list>
#include <string>
#include <vector>
// A DataNode is a single line of a DataFile. It consists of one or more tokens,
// which can be interpreted either as strings or as floating point values, and
// it may also have "children," which may each in turn have their own children.
// The tokens of a node are separated by white space, with quotation marks being
// used to group multiple words into a single token. If the token text contains
// quotation marks, it should be enclosed in backticks instead.
class DataNode {
public:
int Size() const;
const QString &Token(int index) const;
double Value(int index) const;
bool HasChildren() const;
std::list<DataNode>::const_iterator begin() const;
std::list<DataNode>::const_iterator end() const;
private:
std::list<DataNode> children;
std::vector<QString> tokens;
friend class DataFile;
};
#endif