Aさん
Revision | c86beced2c79b62e36b9c1629a7699c9df4be7c8 (tree) |
---|---|
Zeit | 2011-01-18 02:04:57 |
Autor | beru <berupon@gmai...> |
Commiter | beru |
plan changed, idea to new implementation
@@ -1,8 +1,104 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | -// http://bsonspec.org/#/specification | |
3 | +// BSON like format, BSAN version 1 beta | |
4 | 4 | |
5 | -namespace BSON { | |
5 | +/* | |
6 | + | |
7 | +// optional mark ? | |
8 | + | |
9 | +type bool_t : uint8_t { | |
10 | + false = 0, | |
11 | + true = 1, | |
12 | +} | |
13 | + | |
14 | +// byte sequence | |
15 | +type binary<N>_t { | |
16 | + uint<N>_t count | |
17 | + uint8_t[count] data | |
18 | +} | |
19 | + | |
20 | +type var_t { | |
21 | + eValueType type | |
22 | + value_t value | |
23 | +} | |
24 | + | |
25 | +// variable array | |
26 | +type var_array_t { | |
27 | + uint32_t count | |
28 | + var_t[count] values | |
29 | +} | |
30 | + | |
31 | +type var_keyval_t { | |
32 | + binary8_t key | |
33 | + var_t value | |
34 | +} | |
35 | + | |
36 | +// variable map | |
37 | +type var_map_t { | |
38 | + uint32_t count | |
39 | + var_keyval_t[count] pairs | |
40 | +} | |
41 | + | |
42 | +// same type values array | |
43 | +type typed_array_t { | |
44 | + uint32_t count | |
45 | + value_t[count] values | |
46 | +} | |
47 | + | |
48 | +type typed_keyval_t { | |
49 | + binary8_t key | |
50 | + value_t value | |
51 | +} | |
52 | + | |
53 | +// same type values map | |
54 | +type typed_map_t { | |
55 | + uint32_t count | |
56 | + typed_keyval_t[count] pairs | |
57 | +} | |
58 | + | |
59 | +enum eValueType : uint8_t { | |
60 | + null_t = 0, | |
61 | + | |
62 | + int8_t = 1, | |
63 | + int16_t = 2, | |
64 | + int32_t = 3, | |
65 | + int64_t = 4, | |
66 | + | |
67 | + uint8_t = 5, | |
68 | + uint16_t = 6, | |
69 | + uint32_t = 7, | |
70 | + uint64_t = 8, | |
71 | + | |
72 | + float16_t = 9, | |
73 | + float32_t = 10, | |
74 | + float64_t = 11, | |
75 | + | |
76 | + bool_t = 12, | |
77 | + | |
78 | + binary8_t = 13, | |
79 | + binary16_t = 14, | |
80 | + binary32_t = 15, | |
81 | + | |
82 | + var_array_t = 16, | |
83 | + var_map_t = 17, | |
84 | + | |
85 | + typed_array_t = 50 + value_t, | |
86 | + typed_map_t = 100 + value_t, | |
87 | + | |
88 | +} | |
89 | + | |
90 | +type document_t { | |
91 | + int8_t[4] signature = "BSAN" | |
92 | + uint32_t version = 1 | |
93 | + var_map_t map | |
94 | +} | |
95 | + | |
96 | + | |
97 | +*/ | |
98 | + | |
99 | + | |
100 | + | |
101 | +namespace CSON { | |
6 | 102 | |
7 | 103 | enum ElementType { |
8 | 104 | ElementType_Double = 0x01, |
@@ -48,7 +144,7 @@ struct IReader { | ||
48 | 144 | const char* ReadElementDataPtr() const; |
49 | 145 | |
50 | 146 | void ReadElement_Double(double& val) const; |
51 | - void ReadElement_String(char* str, uint32_t& strLen) const; | |
147 | + void ReadElement_String(uint32_t& strLen, char*& str, ) const; | |
52 | 148 | void ReadElement_Binary(uint32_t& nBytes, BinarySubType& subType, char* data) const; |
53 | 149 | void ReadElement_Boolean(bool& val); |
54 | 150 | void ReadElement_Regex(char* pattern, char* option); |