Skip to content

returning optional<DataNode> from newPath methods #12

Open

Description

@peckato1

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.

Activity

  1. syyyr commented on Jul 26, 2023

    @syyyr
    Contributor

    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.

  2. added a commit that references this issue on Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions