Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ygorelik/ydk-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Aug 4, 2021
2 parents 65c9cd9 + 5299b11 commit 1dd1503
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
34 changes: 20 additions & 14 deletions sdk/cpp/core/src/path/data_node.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// YANG Development Kit
// Copyright 2016 Cisco Systems. All rights reserved
// YANG Development Kit
// Copyright 2016-2019 Cisco Systems. All rights reserved
//
////////////////////////////////////////////////////////////////
// -------------------------------------------------------------
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
Expand All @@ -23,7 +23,7 @@
// All modifications in original under CiscoDevNet domain
// introduced since October 2019 are copyrighted.
// All rights reserved under Apache License, Version 2.0.
////////////////////////////////////////////////////////////////
// -------------------------------------------------------------

#include "path_private.hpp"

Expand Down Expand Up @@ -66,9 +66,9 @@ ydk::path::DataNode::create_datanode(const std::string& path)
ydk::path::DataNodeImpl::DataNodeImpl(DataNode* parent, lyd_node* node, const std::shared_ptr<RepositoryPtr> & repo): m_parent{parent}, m_node{node}, m_priv_repo{repo}
{
//add the children
if(m_node && m_node->child && !(m_node->schema->nodetype == LYS_LEAF ||
m_node->schema->nodetype == LYS_LEAFLIST ||
m_node->schema->nodetype == LYS_ANYXML))
if (m_node &&
!(m_node->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYXML)) &&
m_node->child)
{
lyd_node *iter = nullptr;
LY_TREE_FOR(m_node->child, iter) {
Expand Down Expand Up @@ -145,7 +145,13 @@ ydk::path::DataNodeImpl::create_datanode(const std::string& path, const std::str
}
}
populate_new_schemas_from_path(path);
populate_new_schemas_from_path(v);

// Do not populate new schemas from URL value
if ( !(v.length() > strlen("http://") && v.substr(0, strlen("http://")) == "http://") &&
!(v.length() > strlen("https://") && v.substr(0, strlen("https://")) == "https://") )
{
populate_new_schemas_from_path(v);
}

return create_helper(path, v);
}
Expand Down Expand Up @@ -241,7 +247,7 @@ ydk::path::DataNodeImpl::create_helper(const std::string& path, const std::strin
if (i != segments.size() - 1)
{
YLOG_DEBUG("Creating new data path '{}' in '{}'", child_segment, cn->schema->name);
cn = lyd_new_path(cn, nullptr, child_segment.c_str(), nullptr, LYD_ANYDATA_SXML, 0);
cn = lyd_new_path(cn, nullptr, child_segment.c_str(), nullptr, LYD_ANYDATA_CONSTSTRING, 0);
}
else
{
Expand Down Expand Up @@ -311,8 +317,8 @@ ydk::path::DataNodeImpl::set_value(const std::string& value)
}
else
{
YLOG_ERROR("Trying to set value {} for a non leaf non anyxml node.", value);
throw(YInvalidArgumentError{"Cannot set value for this Data Node"});
YLOG_ERROR("Trying to set value '{}' for a non leaf, anyxml, anydata node.", value);
throw(YInvalidArgumentError{"Cannot set value for Data Node"});
}
}

Expand Down Expand Up @@ -379,9 +385,9 @@ ydk::path::DataNodeImpl::get_children() const
std::vector<std::shared_ptr<DataNode>> ret{};
//the ordering should be determined by the lyd_node
lyd_node *iter;
if(m_node && m_node->child && !(m_node->schema->nodetype == LYS_LEAF ||
m_node->schema->nodetype == LYS_LEAFLIST ||
m_node->schema->nodetype == LYS_ANYXML))
if (m_node &&
!(m_node->schema->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_ANYXML)) &&
m_node->child)
{
LY_TREE_FOR(m_node->child, iter){
auto p = child_map.find(iter);
Expand Down
10 changes: 6 additions & 4 deletions test/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,12 @@ function init_go_env {
go_version=$(echo `go version` | awk '{ print $3 }' | cut -d 'o' -f 2)
print_msg "Current Go version is $go_version"

go get github.com/stretchr/testify
cd $GOPATH/src/github.com/stretchr/testify
git checkout tags/v1.6.1
cd -
if [ ! -d $GOPATH/src/github.com/stretchr/testify ]; then
go get github.com/stretchr/testify
cd $GOPATH/src/github.com/stretchr/testify
git checkout tags/v1.6.1
cd -
fi

export CGO_ENABLED=1
export CGO_LDFLAGS_ALLOW="-fprofile-arcs|-ftest-coverage|--coverage"
Expand Down

0 comments on commit 1dd1503

Please sign in to comment.