Skip to content

Commit 724abf3

Browse files
author
thk123
committed
Add documentation explaining the structured data
1 parent 23480cb commit 724abf3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/util/structured_data.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,46 @@ struct structured_data_entryt
4343
std::map<labelt, structured_data_entryt> children;
4444
};
4545

46+
/// A way of representing nested key/value data. Used for logging on any
47+
/// message handler.
48+
/// Usage:
49+
/// ```
50+
/// structured_datat data{
51+
/// {{labelt{{"my", "data"}},
52+
/// structured_data_entryt::entry(
53+
/// {{labelt{{"my", "number"}},
54+
/// structured_data_entryt::data_node(json_numbert("10"))},
55+
/// {labelt{{"my", "string"}},
56+
/// structured_data_entryt::data_node(json_stringt("hi"))}})}}};
57+
/// message() << data << eom;
58+
/// ```
59+
/// Then if the output dependending on the UI of the message handler, you'll
60+
/// get appropriately formatted data:
61+
///
62+
/// XML:
63+
/// ```xml
64+
/// <my-data>
65+
/// <my-number>10</my-number>
66+
/// <my-string>hi</my-string>
67+
/// </my-data>
68+
/// ```
69+
///
70+
/// JSON:
71+
/// ```json
72+
/// {
73+
/// "myData": {
74+
/// "myNumber": 10
75+
/// "myString": "hi"
76+
/// }
77+
/// }
78+
/// ```
79+
///
80+
/// Plain:
81+
/// ```
82+
/// My data:
83+
/// My number: 10
84+
/// My string: hi
85+
/// ```
4686
class structured_datat
4787
{
4888
public:

0 commit comments

Comments
 (0)