TomlValue.cs
4.31 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
using System;
namespace UniJSON
{
public enum TomlValueType
{
BareKey, // key
QuotedKey, // "key"
DottedKey, // key.nested
BasicString, // "str"
MultilineBasicString, // """str"""
LiteralString, // 'str'
MultilineLiteralString, // '''str'''
Integer,
Float,
Boolean,
OffsetDatetime,
Array, // [1, 2, 3]
Table, // [table_name]
}
public struct TomlValue : IListTreeItem, IValue<TomlValue>
{
public override string ToString()
{
return m_segment.ToString();
}
public int ParentIndex { get; private set; }
public TomlValueType TomlValueType
{
get;
private set;
}
public ValueNodeType ValueType
{
get
{
switch (TomlValueType)
{
case TomlValueType.Integer: return ValueNodeType.Integer;
case TomlValueType.Float: return ValueNodeType.Number;
case TomlValueType.Boolean: return ValueNodeType.Boolean;
case TomlValueType.BareKey: return ValueNodeType.String;
case TomlValueType.QuotedKey: return ValueNodeType.String;
case TomlValueType.DottedKey: return ValueNodeType.String;
case TomlValueType.BasicString: return ValueNodeType.String;
case TomlValueType.MultilineBasicString: return ValueNodeType.String;
case TomlValueType.LiteralString: return ValueNodeType.String;
case TomlValueType.MultilineLiteralString: return ValueNodeType.String;
case TomlValueType.Table: return ValueNodeType.Object;
case TomlValueType.Array: return ValueNodeType.Array;
}
throw new NotImplementedException();
}
}
Utf8String m_segment;
public ArraySegment<byte> Bytes { get { return m_segment.Bytes; } }
public void SetBytesCount(int count)
{
throw new NotImplementedException();
}
public int ChildCount
{
get
{
throw new NotImplementedException();
}
}
public void SetChildCount(int count)
{
throw new NotImplementedException();
}
public TomlValue(Utf8String segment, TomlValueType valueType, int parentIndex) : this()
{
ParentIndex = parentIndex;
TomlValueType = valueType;
m_segment = segment;
}
public bool GetBoolean()
{
throw new NotImplementedException();
}
public byte GetByte()
{
throw new NotImplementedException();
}
public double GetDouble()
{
throw new NotImplementedException();
}
public short GetInt16()
{
throw new NotImplementedException();
}
public int GetInt32()
{
return m_segment.ToInt32();
}
public long GetInt64()
{
throw new NotImplementedException();
}
public sbyte GetSByte()
{
throw new NotImplementedException();
}
public float GetSingle()
{
throw new NotImplementedException();
}
public string GetString()
{
throw new NotImplementedException();
}
public ushort GetUInt16()
{
throw new NotImplementedException();
}
public uint GetUInt32()
{
throw new NotImplementedException();
}
public ulong GetUInt64()
{
throw new NotImplementedException();
}
public Utf8String GetUtf8String()
{
return m_segment;
}
public U GetValue<U>()
{
throw new NotImplementedException();
}
public TomlValue Key(Utf8String key, int parentIndex)
{
throw new NotImplementedException();
}
public TomlValue New(ArraySegment<byte> bytes, ValueNodeType valueType, int parentIndex)
{
throw new NotImplementedException();
}
}
}