Skip to content

Commit de81a03

Browse files
committed
Update documentation
Change-Id: I0173404d4d7720444488fe9fd8fc4346105604fb
1 parent 01b3949 commit de81a03

15 files changed

+418
-71
lines changed

Diff for: Doxyfile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ INPUT = @doxy_main_page@ @PROJECT_SOURCE_DIR@ @PROJECT_BINARY_DIR@
55
FILE_PATTERNS = *.hpp *.cpp *.md *.cmake
66
RECURSIVE = YES
77
EXTRACT_ANON_NSPACES = YES
8-
USE_MDFILE_AS_MAINPAGE = index.md
8+
USE_MDFILE_AS_MAINPAGE = README.md

Diff for: include/libyang-cpp/ChildInstantiables.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ class ChildInstanstiablesIterator {
3838
};
3939

4040
/**
41-
* A collection that iterates over children of a node that can be instantiated, i.e. they can have a DataNode.
41+
* @brief A collection that iterates over children of a schema node that can be instantiated, i.e. they can have a DataNode.
42+
*
43+
* Check out Module::childInstanstiables and SchemaNode::childInstanstiables for usage.
4244
*/
4345
class ChildInstanstiables {
4446
public:

Diff for: include/libyang-cpp/Collection.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ class Iterator {
8383
void unregisterThis();
8484
};
8585

86+
/**
87+
* @brief A collection of SchemaNode or DataNode supporting multiple iteration types.
88+
*
89+
* For more info on iteration types, see these methods:
90+
* - DataNode::childrenDfs
91+
* - DataNode::siblings
92+
* - SchemaNode::siblings
93+
* - SchemaNode::childrenDfs
94+
*/
8695
template <typename NodeType, IterationType ITER_TYPE>
8796
class Collection {
8897
public:
@@ -118,6 +127,11 @@ class Collection {
118127
void throwIfInvalid() const;
119128
};
120129

130+
/**
131+
* @brief A collection for iterating over metadata of a DataNode.
132+
*
133+
* For more information, check DataNode::meta.
134+
*/
121135
class MetaCollection : public Collection<Meta, IterationType::Meta> {
122136
public:
123137
Iterator<Meta, IterationType::Meta> erase(Iterator<Meta, IterationType::Meta> what);

Diff for: include/libyang-cpp/Context.hpp

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
struct ly_ctx;
2222

23+
/**
24+
* @brief The libyang-cpp namespace.
25+
*/
2326
namespace libyang {
2427
class Context;
2528

@@ -28,6 +31,11 @@ using ContextDeleter = std::function<void(ly_ctx*)>;
2831
Context createUnmanagedContext(ly_ctx* ctx, ContextDeleter);
2932
ly_ctx* retrieveContext(Context ctx);
3033

34+
/**
35+
* @brief A structure containing a module as a string and its format.
36+
*
37+
* Used as the return value for module retrieval callback.
38+
*/
3139
struct ModuleInfo {
3240
std::string data;
3341
SchemaFormat format;
@@ -41,6 +49,11 @@ using ModuleCallback = std::optional<ModuleInfo>(const char* modName,
4149
const char* submodName,
4250
const char* submodRev);
4351

52+
/**
53+
* @brief Contains detailed libyang error.
54+
*
55+
* Wraps `ly_err_item`.
56+
*/
4457
struct ErrorInfo {
4558
bool operator==(const ErrorInfo& other) const = default;
4659
std::optional<std::string> appTag;

Diff for: include/libyang-cpp/DataNode.hpp

+31-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ void validateAll(std::optional<libyang::DataNode>& node, const std::optional<Val
5656

5757
/**
5858
* @brief Class representing a node in a libyang tree.
59+
*
60+
* Wraps `lyd_node`.
5961
*/
6062
class DataNode {
6163
public:
@@ -147,6 +149,11 @@ class DataNode {
147149
std::shared_ptr<internal_refcount> m_refs;
148150
};
149151

152+
/**
153+
* @brief Represents a piece of metadata associated with a node.
154+
*
155+
* Represents a `lyd_meta` struct (but does not wrap it).
156+
*/
150157
class Meta {
151158
public:
152159
std::string name() const;
@@ -165,6 +172,8 @@ class Meta {
165172

166173
/**
167174
* @brief Class representing a term node - leaf or leaf-list.
175+
*
176+
* Wraps `lyd_node_term`.
168177
*/
169178
class DataNodeTerm : public DataNode {
170179
public:
@@ -178,11 +187,23 @@ class DataNodeTerm : public DataNode {
178187
using DataNode::DataNode;
179188
};
180189

190+
/**
191+
* @brief Contains a (possibly module-qualified) name of an opaque node.
192+
*
193+
* This is generic container of a prefix/module string and a name string.
194+
*
195+
* Wraps `ly_opaq_name`.
196+
*/
181197
struct OpaqueName {
182198
std::optional<std::string_view> prefix;
183199
std::string_view name;
184200
};
185201

202+
/**
203+
* @brief Class representing an opaque node.
204+
*
205+
* Wraps `lyd_node_opaq`.
206+
*/
186207
class DataNodeOpaque : public DataNode {
187208
public:
188209
OpaqueName name() const;
@@ -205,21 +226,28 @@ class DataNodeAny : public DataNode {
205226
using DataNode::DataNode;
206227
};
207228

229+
/**
230+
* @brief Represents a YANG operation data tree.
231+
*
232+
* Used as the return value of `DataNode::parseOp` and Context::parseOp.
233+
*/
208234
struct ParsedOp {
209235
std::optional<libyang::DataNode> tree;
210236
std::optional<libyang::DataNode> op;
211237
};
212238

213239
/**
214-
* This struct represents the return value for newPath2.
240+
* @brief This struct represents the return value for newPath2.
215241
*/
216242
struct CreatedNodes {
217243
/**
218-
* Contains the first created parent. Will be the same as `createdNode` if only one was created.
244+
* @brief Contains the first created parent.
245+
*
246+
* Will be the same as `createdNode` if only one node was created.
219247
*/
220248
std::optional<DataNode> createdParent;
221249
/**
222-
* Contains the node specified by `path` from the original newPath2 call.
250+
* @brief Contains the node specified by `path` from the original newPath2 call.
223251
*/
224252
std::optional<DataNode> createdNode;
225253
};

Diff for: include/libyang-cpp/Module.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class ChildInstanstiables;
2525
class Identity;
2626
class SchemaNode;
2727

28+
/**
29+
* @brief Represents a feature of a module.
30+
*
31+
* Wraps `lysp_feature`.
32+
*/
2833
class Feature {
2934
public:
3035
std::string_view name() const;

Diff for: include/libyang-cpp/SchemaNode.hpp

+38
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class Iterator;
4141

4242
/**
4343
* @brief Class representing a schema definition of a node.
44+
*
45+
* Wraps `lysc_node`.
4446
*/
4547
class SchemaNode {
4648
public:
@@ -51,6 +53,9 @@ class SchemaNode {
5153
Status status() const;
5254
Config config() const;
5355
NodeType nodeType() const;
56+
// It is possible to cast SchemaNode to another type via the following methods. The types are children classes of
57+
// SchemaNode. No problems with slicing can occur, because these types are value-based and aren't constructible
58+
// drectly by the user.
5459
// TODO: turn these into a templated `as<>` method.
5560
Container asContainer() const;
5661
Leaf asLeaf() const;
@@ -78,6 +83,9 @@ class SchemaNode {
7883
SchemaNode(const lysc_node* node, std::nullptr_t);
7984
};
8085

86+
/**
87+
* @brief Class representing a schema definition of a `container` node.
88+
*/
8189
class Container : public SchemaNode {
8290
public:
8391
bool isPresence() const;
@@ -87,6 +95,11 @@ class Container : public SchemaNode {
8795
using SchemaNode::SchemaNode;
8896
};
8997

98+
/**
99+
* @brief Class representing a schema definition of a `leaf` node.
100+
*
101+
* Wraps `lysc_node_leaf`.
102+
*/
90103
class Leaf : public SchemaNode {
91104
public:
92105
bool isKey() const;
@@ -99,6 +112,11 @@ class Leaf : public SchemaNode {
99112
using SchemaNode::SchemaNode;
100113
};
101114

115+
/**
116+
* @brief Class representing a schema definition of a `leaflist` node.
117+
*
118+
* Wraps `lysc_node_leaflist`.
119+
*/
102120
class LeafList : public SchemaNode {
103121
public:
104122
Type valueType() const;
@@ -109,6 +127,11 @@ class LeafList : public SchemaNode {
109127
using SchemaNode::SchemaNode;
110128
};
111129

130+
/**
131+
* @brief Class representing a schema definition of a `list` node.
132+
*
133+
* Wraps `lysc_node_list`.
134+
*/
112135
class List : public SchemaNode {
113136
public:
114137
std::vector<Leaf> keys() const;
@@ -118,6 +141,11 @@ class List : public SchemaNode {
118141
using SchemaNode::SchemaNode;
119142
};
120143

144+
/**
145+
* @brief Class representing a schema definition of an `input` node of an RPC/action node.
146+
*
147+
* Wraps `lysc_node_action_inout`.
148+
*/
121149
class ActionRpcInput : public SchemaNode {
122150
public:
123151
friend ActionRpc;
@@ -126,6 +154,11 @@ class ActionRpcInput : public SchemaNode {
126154
using SchemaNode::SchemaNode;
127155
};
128156

157+
/**
158+
* @brief Class representing a schema definition of an `output` node of an RPC/action node.
159+
*
160+
* Wraps `lysc_node_action_inout`.
161+
*/
129162
class ActionRpcOutput : public SchemaNode {
130163
public:
131164
friend ActionRpc;
@@ -134,6 +167,11 @@ class ActionRpcOutput : public SchemaNode {
134167
using SchemaNode::SchemaNode;
135168
};
136169

170+
/**
171+
* @brief Class representing a schema definition of a `action` or `rpc` node.
172+
*
173+
* Wraps `lysc_node_action`.
174+
*/
137175
class ActionRpc : public SchemaNode {
138176
public:
139177
ActionRpcInput input() const;

Diff for: include/libyang-cpp/Set.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class SetIterator {
6060
const Set<NodeType>* m_set;
6161
};
6262

63+
/**
64+
* @brief An array-like collection of nodes.
65+
*/
6366
template <typename NodeType>
6467
class Set {
6568
public:

Diff for: include/libyang-cpp/Type.hpp

+46-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ namespace libyang {
2323
class Leaf;
2424
class LeafList;
2525
class Module;
26+
/**
27+
* @brief Contains representations of `leaf` schema data types.
28+
*
29+
* TODO: add examples/tutorials on how to work datatypes in libyang-cpp
30+
*/
2631
namespace types {
2732
class Bits;
2833
class Enumeration;
@@ -31,7 +36,9 @@ class LeafRef;
3136
class Union;
3237
}
3338
/**
34-
* @brief Contains information about leaf's type.
39+
* @brief Contains information about a leaf's type.
40+
*
41+
* Wraps `lysc_type`.
3542
*/
3643
class Type {
3744
public:
@@ -62,6 +69,11 @@ class Type {
6269
Type(const lysc_type* type, const lysp_type* typeParsed, std::shared_ptr<ly_ctx> ctx);
6370
};
6471

72+
/**
73+
* @brief Contains information about an identity.
74+
*
75+
* Wraps `lysc_ident`.
76+
*/
6577
class Identity {
6678
public:
6779
friend types::IdentityRef;
@@ -77,10 +89,20 @@ class Identity {
7789
};
7890

7991
namespace types {
92+
/**
93+
* @brief Contains information about the `enumeration` leaf type.
94+
*
95+
* Wraps `lysc_type_enum`.
96+
*/
8097
class Enumeration : public Type {
8198
public:
8299
friend Type;
83100

101+
/**
102+
* @brief Contains information about an enum from an `enumeration` leaf type.
103+
*
104+
* Wraps `lysc_type_bitenum_item`.
105+
*/
84106
struct Enum {
85107
auto operator<=>(const Enum& other) const = default;
86108
std::string name;
@@ -93,6 +115,11 @@ class Enumeration : public Type {
93115
using Type::Type;
94116
};
95117

118+
/**
119+
* @brief Contains information about the `identityref` leaf type.
120+
*
121+
* Wraps `lysc_type_identityref`.
122+
*/
96123
class IdentityRef : public Type {
97124
public:
98125
friend Type;
@@ -103,6 +130,9 @@ class IdentityRef : public Type {
103130
using Type::Type;
104131
};
105132

133+
/**
134+
* @brief Contains information about the `leafref` leaf type.
135+
*/
106136
class LeafRef : public Type {
107137
public:
108138
friend Type;
@@ -114,8 +144,18 @@ class LeafRef : public Type {
114144
using Type::Type;
115145
};
116146

147+
/**
148+
* @brief Contains information about the `bits` leaf type.
149+
*
150+
* Wraps `lysc_type_bits`.
151+
*/
117152
class Bits : public Type {
118153
public:
154+
/**
155+
* @brief Contains information about a specific bit from a `bits` leaf type.
156+
*
157+
* Wraps `lysc_type_bitenum_item`.
158+
*/
119159
struct Bit {
120160
auto operator<=>(const Bit& other) const = default;
121161
std::string name;
@@ -130,6 +170,11 @@ class Bits : public Type {
130170
using Type::Type;
131171
};
132172

173+
/**
174+
* @brief Contains information about the `union` leaf type.
175+
*
176+
* Wraps `lysc_type_union`.
177+
*/
133178
class Union : public Type {
134179
public:
135180
std::vector<Type> types() const;

0 commit comments

Comments
 (0)