You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
returning optional<DataNode> from newPath methods #12
Is it neccessary to return optional<DataNode> from newPath methods? Is there any case where the returned node is NULL but the underlying lyd_new_path returns LY_SUCCESS? Also, we always check for std::nullopt in {DataNode,Context}::newPath and throw logic_error if that happens so it seems that we actually might want newPath to return just DataNode.
Also, we always check for std::nullopt in {DataNode,Context}::newPath
Not 100% true, we only check for std::nullopt in Context::newPath. DataNode::newPath returns std::nullopt if the CreationOptions::Update flag is used and no new nodes were created.
The documentation explains the return value, but doesn't mention the flag:
* @return Returns the first created node. If no nodes were created, returns std::nullopt.
I agree, that the return value doc for DataNode::newPath should mention the flag. As for Context::newPath, AFAIK, it can't return no new nodes. But I'm not sure, maybe it doesn't if you're creating a non-presence container with the Update flag? I don't know, I'd have to test.
Activity
syyyr commentedon Jul 26, 2023
Not 100% true, we only check for
std::nulloptinContext::newPath.DataNode::newPathreturnsstd::nulloptif theCreationOptions::Updateflag is used and no new nodes were created.The documentation explains the return value, but doesn't mention the flag:
I agree, that the return value doc for
DataNode::newPathshould mention the flag. As forContext::newPath, AFAIK, it can't return no new nodes. But I'm not sure, maybe it doesn't if you're creating a non-presence container with theUpdateflag? I don't know, I'd have to test.CI: temporary pin of libyang to 3.0.18