name-component: rename fromEscapedString() to fromUri()
Consistent with toUri()
Change-Id: Ia8ca75be9068b06840e2847f0128ffc7a4cd57af
diff --git a/ndn-cxx/name-component.cpp b/ndn-cxx/name-component.cpp
index 9092271..bc9d688 100644
--- a/ndn-cxx/name-component.cpp
+++ b/ndn-cxx/name-component.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -136,7 +136,7 @@
}
Component
-Component::fromEscapedString(std::string_view input)
+Component::fromUri(std::string_view input)
{
size_t equalPos = input.find('=');
if (equalPos == std::string_view::npos) {
diff --git a/ndn-cxx/name-component.hpp b/ndn-cxx/name-component.hpp
index 23128e7..50ffc6e 100644
--- a/ndn-cxx/name-component.hpp
+++ b/ndn-cxx/name-component.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -204,30 +204,38 @@
public: // encoding and URI
/**
- * @brief Fast encoding or block size estimation
+ * @brief Prepend wire encoding to @p encoder.
*/
template<encoding::Tag TAG>
size_t
wireEncode(EncodingImpl<TAG>& encoder) const;
/**
- * @brief Encode to a wire format
+ * @brief Encode to TLV wire format.
*/
const Block&
wireEncode() const;
/**
- * @brief Decode from the wire format
+ * @brief Decode from TLV wire format.
*/
void
wireDecode(const Block& wire);
/**
- * @brief Decode NameComponent from a URI component.
- * @throw Error URI component does not represent a valid NameComponent.
+ * @brief Construct a NameComponent from its string representation in NDN URI format.
+ * @throw Error The input string does not represent a valid NameComponent in NDN URI format.
+ * @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#ndn-uri-scheme
*/
static Component
- fromEscapedString(std::string_view input);
+ fromUri(std::string_view input);
+
+ [[deprecated("use fromUri")]]
+ static Component
+ fromEscapedString(std::string_view input)
+ {
+ return Component::fromUri(input);
+ }
/**
* @brief Write `*this` to the output stream, escaping characters according to the NDN URI format.
@@ -237,7 +245,7 @@
toUri(std::ostream& os, UriFormat format = UriFormat::DEFAULT) const;
/**
- * @brief Convert `*this` by escaping characters according to the NDN URI format.
+ * @brief Convert `*this` to a string by escaping characters according to the NDN URI format.
* @sa https://docs.named-data.net/NDN-packet-spec/0.3/name.html#ndn-uri-scheme
*/
std::string
diff --git a/ndn-cxx/name.cpp b/ndn-cxx/name.cpp
index 240edc5..76b86e8 100644
--- a/ndn-cxx/name.cpp
+++ b/ndn-cxx/name.cpp
@@ -78,7 +78,7 @@
// Unescape the components.
while (!uri.empty()) {
auto component = uri.substr(0, uri.find('/'));
- append(Component::fromEscapedString(component));
+ append(Component::fromUri(component));
if (component.size() + 1 >= uri.size()) {
// We reached the end of the string.
return;
diff --git a/tests/unit/interest.t.cpp b/tests/unit/interest.t.cpp
index c67bd0e..4c540b7 100644
--- a/tests/unit/interest.t.cpp
+++ b/tests/unit/interest.t.cpp
@@ -679,9 +679,8 @@
interest = makeInterest(data->getFullName());
BOOST_CHECK_EQUAL(interest->matchesData(*data), true);
- setNameComponent(*interest, -1,
- name::Component::fromEscapedString("sha256digest=00000000000000000000000000"
- "00000000000000000000000000000000000000"));
+ setNameComponent(*interest, -1, name::Component::fromUri("sha256digest=00000000000000000000000000"
+ "00000000000000000000000000000000000000"));
BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // violates implicit digest
}
diff --git a/tests/unit/meta-info.t.cpp b/tests/unit/meta-info.t.cpp
index bd5aee4..f375607 100644
--- a/tests/unit/meta-info.t.cpp
+++ b/tests/unit/meta-info.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -69,7 +69,7 @@
BOOST_CHECK_EQUAL(a.getType(), tlv::ContentType_Blob);
BOOST_CHECK_EQUAL(a.getFreshnessPeriod(), 0_ms);
BOOST_REQUIRE(a.getFinalBlock().has_value());
- BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component::fromEscapedString("221=A"));
+ BOOST_CHECK_EQUAL(*a.getFinalBlock(), name::Component::fromUri("221=A"));
BOOST_CHECK_NE(a.wireEncode(), b.wireEncode());
b.setType(a.getType());
diff --git a/tests/unit/name-component.t.cpp b/tests/unit/name-component.t.cpp
index 840bccd..cc38cf2 100644
--- a/tests/unit/name-component.t.cpp
+++ b/tests/unit/name-component.t.cpp
@@ -63,45 +63,46 @@
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "8=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "ndn-cxx");
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), "ndn-cxx");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("ndn-cxx"), comp);
- BOOST_CHECK_EQUAL(Component::fromEscapedString("8=ndn-cxx"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("ndn-cxx"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("8=ndn-cxx"sv), comp);
comp.wireDecode("0800"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "...");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("..."), comp);
- BOOST_CHECK_EQUAL(Component::fromEscapedString("8=..."), comp);
- BOOST_CHECK_EQUAL(Component::fromEscapedString(".%2E."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("..."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("8=..."sv), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri(".%2E."sv), comp);
comp.wireDecode("0801 2E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "....");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("...."), comp);
- BOOST_CHECK_EQUAL(Component::fromEscapedString("%2E..%2E"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("...."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("%2E..%2E"sv), comp);
comp.wireDecode("0803 2E412E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), ".A.");
- BOOST_CHECK_EQUAL(Component::fromEscapedString(".A."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri(".A."sv), comp);
comp.wireDecode("0807 666F6F25626172"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "foo%25bar");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("foo%25bar"), comp);
- BOOST_CHECK_EQUAL(Component::fromEscapedString("8=foo%25bar"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("foo%25bar"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("8=foo%25bar"sv), comp);
comp.wireDecode("0804 2D2E5F7E"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "-._~");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("-._~"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("-._~"sv), comp);
comp.wireDecode("0803 393D41"_block);
BOOST_CHECK_EQUAL(comp.toUri(), "9%3DA");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("9%3DA"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("9%3DA"sv), comp);
comp = Component(":/?#[]@");
BOOST_CHECK_EQUAL(comp.toUri(), "%3A%2F%3F%23%5B%5D%40");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("%3A%2F%3F%23%5B%5D%40"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("%3A%2F%3F%23%5B%5D%40"sv), comp);
- BOOST_CHECK_THROW(Component::fromEscapedString(""), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("."), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString(".."), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("8="), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri(""), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri(""sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("."sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri(".."sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("8="sv), Component::Error);
}
static void
@@ -119,21 +120,21 @@
BOOST_CHECK_EQUAL(comp.type(), type);
BOOST_CHECK_EQUAL(comp.toUri(), uriPrefix + hexLower);
- BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), to_string(type) + "=" + hexPctCanonical);
+ BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), std::to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), uriPrefix + hexLower);
- BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), to_string(type) + "=" + hexPctCanonical);
+ BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), std::to_string(type) + "=" + hexPctCanonical);
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), uriPrefix + hexLower);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), uriPrefix + hexLower);
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(uriPrefix + hexLower));
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(uriPrefix + hexUpper));
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=" + hexPct));
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=" + hexPctCanonical));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(uriPrefix + hexLower));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(uriPrefix + hexUpper));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=" + hexPct));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=" + hexPctCanonical));
CHECK_COMP_ERR(comp.wireDecode(Block(type, fromHex("A791806951F25C4D"))), "TLV-LENGTH must be 32");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix), "TLV-LENGTH must be 32");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "a791806951f25c4d"), "TLV-LENGTH must be 32");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "foo"), "invalid hex encoding");
- CHECK_COMP_ERR(Component::fromEscapedString(boost::to_upper_copy(uriPrefix) + hexLower), "Unknown TLV-TYPE");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix), "TLV-LENGTH must be 32");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "a791806951f25c4d"), "TLV-LENGTH must be 32");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "foo"), "invalid hex encoding");
+ CHECK_COMP_ERR(Component::fromUri(boost::to_upper_copy(uriPrefix) + hexLower), "Unknown TLV-TYPE");
}
BOOST_AUTO_TEST_CASE(ImplicitDigest)
@@ -154,32 +155,32 @@
BOOST_CHECK_EQUAL(comp.isNumber(), true);
const auto compUri = uriPrefix + "42";
BOOST_CHECK_EQUAL(comp.toUri(), compUri);
- BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), to_string(type) + "=%2A");
+ BOOST_CHECK_EQUAL(comp.toUri(UriFormat::CANONICAL), std::to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), compUri);
- BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), to_string(type) + "=%2A");
+ BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), std::to_string(type) + "=%2A");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), compUri);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp), compUri);
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(compUri));
- BOOST_CHECK_EQUAL(comp, Component::fromEscapedString(to_string(type) + "=%2A"));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(compUri));
+ BOOST_CHECK_EQUAL(comp, Component::fromUri(std::to_string(type) + "=%2A"));
BOOST_CHECK_EQUAL(comp, Component::fromNumber(42, type));
const Component comp2(type, fromHex("010203")); // TLV-VALUE is *not* a NonNegativeInteger
BOOST_CHECK_EQUAL(comp2.type(), type);
BOOST_CHECK_EQUAL(comp2.isNumber(), false);
- const auto comp2Uri = to_string(type) + "=%01%02%03";
+ const auto comp2Uri = std::to_string(type) + "=%01%02%03";
BOOST_CHECK_EQUAL(comp2.toUri(), comp2Uri);
BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(comp2), comp2Uri);
- BOOST_CHECK_EQUAL(comp2, Component::fromEscapedString(comp2Uri));
+ BOOST_CHECK_EQUAL(comp2, Component::fromUri(comp2Uri));
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "foo"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "00"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "-1"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "9.3"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + " 84"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "0xAF"), "invalid format");
- CHECK_COMP_ERR(Component::fromEscapedString(uriPrefix + "18446744073709551616"), "out of range");
- CHECK_COMP_ERR(Component::fromEscapedString(boost::to_upper_copy(uriPrefix) + "42"), "Unknown TLV-TYPE");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "foo"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "00"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "-1"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "9.3"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + " 84"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "0xAF"), "invalid format");
+ CHECK_COMP_ERR(Component::fromUri(uriPrefix + "18446744073709551616"), "out of range");
+ CHECK_COMP_ERR(Component::fromUri(boost::to_upper_copy(uriPrefix) + "42"), "Unknown TLV-TYPE");
}
BOOST_AUTO_TEST_CASE(Segment)
@@ -217,17 +218,17 @@
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), "32=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "32=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "32=ndn-cxx");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("32=ndn-cxx"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("32=ndn-cxx"sv), comp);
comp.wireDecode("2000"_block);
BOOST_CHECK_EQUAL(comp.type(), tlv::KeywordNameComponent);
BOOST_CHECK_EQUAL(comp.isKeyword(), true);
BOOST_CHECK_EQUAL(comp.toUri(), "32=...");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("32=..."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("32=..."sv), comp);
- BOOST_CHECK_THROW(Component::fromEscapedString("32="), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("32=."), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("32=.."), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("32="sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("32=."sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("32=.."sv), Component::Error);
}
BOOST_AUTO_TEST_CASE(OtherType)
@@ -239,21 +240,21 @@
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ALTERNATE), "9=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_CANONICAL), "9=ndn-cxx");
BOOST_CHECK_EQUAL(comp.toUri(UriFormat::ENV_OR_ALTERNATE), "9=ndn-cxx");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("9=ndn-cxx"), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("9=ndn-cxx"sv), comp);
comp.wireDecode("FDFFFF00"_block);
BOOST_CHECK_EQUAL(comp.type(), 0xFFFF);
BOOST_CHECK_EQUAL(comp.toUri(), "65535=...");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("65535=..."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("65535=..."sv), comp);
comp.wireDecode("FD576501 2E"_block);
BOOST_CHECK_EQUAL(comp.type(), 0x5765);
BOOST_CHECK_EQUAL(comp.toUri(), "22373=....");
- BOOST_CHECK_EQUAL(Component::fromEscapedString("22373=...."), comp);
+ BOOST_CHECK_EQUAL(Component::fromUri("22373=...."sv), comp);
- BOOST_CHECK_THROW(Component::fromEscapedString("3="), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("3=."), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("3=.."), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("3="sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("3=."sv), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("3=.."sv), Component::Error);
}
BOOST_AUTO_TEST_CASE(InvalidType)
@@ -262,21 +263,21 @@
BOOST_CHECK_THROW(comp.wireDecode(Block{}), Component::Error);
BOOST_CHECK_THROW(comp.wireDecode("FE0001000001 80"_block), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("0=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("65536=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("4294967296=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("-1=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("+=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("0x1=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("Z=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("09=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("0x3=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("+9=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString(" 9=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("9 =A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("9.0=A"), Component::Error);
- BOOST_CHECK_THROW(Component::fromEscapedString("9E0=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("0=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("65536=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("4294967296=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("-1=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("+=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("0x1=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("Z=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("09=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("0x3=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("+9=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri(" 9=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("9 =A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("9.0=A"), Component::Error);
+ BOOST_CHECK_THROW(Component::fromUri("9E0=A"), Component::Error);
}
BOOST_AUTO_TEST_SUITE_END() // Decode
diff --git a/tests/unit/name.t.cpp b/tests/unit/name.t.cpp
index a7fdf7a..f19a2f0 100644
--- a/tests/unit/name.t.cpp
+++ b/tests/unit/name.t.cpp
@@ -369,10 +369,10 @@
BOOST_TEST(number == 11676);
name.appendKeyword({0xab, 0xcd, 0xef});
- BOOST_TEST(name.at(-1) == Component::fromEscapedString("32=%AB%CD%EF"sv));
+ BOOST_TEST(name.at(-1) == Component::fromUri("32=%AB%CD%EF"sv));
name.appendKeyword("test-keyword");
- BOOST_TEST(name.at(-1) == Component::fromEscapedString("32=test-keyword"sv));
+ BOOST_TEST(name.at(-1) == Component::fromUri("32=test-keyword"sv));
}
BOOST_AUTO_TEST_CASE(EraseComponent)
diff --git a/tests/unit/prefix-announcement.t.cpp b/tests/unit/prefix-announcement.t.cpp
index a36f084..18cf581 100644
--- a/tests/unit/prefix-announcement.t.cpp
+++ b/tests/unit/prefix-announcement.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -100,7 +100,7 @@
// Name has no "32=PA" keyword
Data data1 = makePrefixAnnData();
- setNameComponent(data1, -3, name::Component::fromEscapedString("32=not-PA"));
+ setNameComponent(data1, -3, name::Component::fromUri("32=not-PA"));
BOOST_CHECK_EXCEPTION(PrefixAnnouncement{data1}, tlv::Error, [] (const auto& e) {
return e.what() == "Data is not a prefix announcement: wrong name structure"s;
});
diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp
index 4fd91b4..69748b5 100644
--- a/tests/unit/security/key-chain.t.cpp
+++ b/tests/unit/security/key-chain.t.cpp
@@ -647,7 +647,7 @@
BOOST_AUTO_TEST_CASE(Options)
{
MakeCertificateOptions opts;
- opts.issuerId = name::Component::fromEscapedString("ISSUER");
+ opts.issuerId = name::Component::fromUri("ISSUER");
opts.version = 41218268;
opts.freshnessPeriod = 321_s;
opts.validity.emplace(time::fromIsoString("20060702T150405"),
diff --git a/tests/unit/security/pib/impl/key-impl.t.cpp b/tests/unit/security/pib/impl/key-impl.t.cpp
index 940974b..311cfe0 100644
--- a/tests/unit/security/pib/impl/key-impl.t.cpp
+++ b/tests/unit/security/pib/impl/key-impl.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -144,7 +144,7 @@
BOOST_AUTO_TEST_CASE(UnknownKeyType)
{
- Name keyName = security::constructKeyName(id1, name::Component::fromEscapedString("foo"));
+ Name keyName = security::constructKeyName(id1, name::Component::fromUri("foo"));
Buffer invalidKey{0x01, 0x02, 0x03, 0x04};
pibImpl->addKey(id1, keyName, invalidKey);
diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp
index 879ef40..246ef1c 100644
--- a/tests/unit/security/trust-anchor-container.t.cpp
+++ b/tests/unit/security/trust-anchor-container.t.cpp
@@ -172,7 +172,7 @@
auto makeIdentity1Cert = [=] (const std::string& issuerId) {
auto key = identity1.getDefaultKey();
MakeCertificateOptions opts;
- opts.issuerId = name::Component::fromEscapedString(issuerId);
+ opts.issuerId = name::Component::fromUri(issuerId);
return m_keyChain.makeCertificate(key, signingByKey(key), opts);
};
diff --git a/tools/ndnsec/cert-gen.cpp b/tools/ndnsec/cert-gen.cpp
index c382119..e7c49ad 100644
--- a/tools/ndnsec/cert-gen.cpp
+++ b/tools/ndnsec/cert-gen.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -121,7 +121,7 @@
}
}
- auto issuerId = name::Component::fromEscapedString(issuer);
+ auto issuerId = name::Component::fromUri(issuer);
if (issuerId.isImplicitSha256Digest() ||
issuerId.isParametersSha256Digest() ||
issuerId.isKeyword()) {
diff --git a/tools/ndnsec/key-gen.cpp b/tools/ndnsec/key-gen.cpp
index a045cd6..bd3712e 100644
--- a/tools/ndnsec/key-gen.cpp
+++ b/tools/ndnsec/key-gen.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -86,7 +86,7 @@
}
keyIdType = KeyIdType::USER_SPECIFIED;
- userKeyIdComponent = name::Component::fromEscapedString(userKeyId);
+ userKeyIdComponent = name::Component::fromUri(userKeyId);
if (userKeyIdComponent.empty() ||
userKeyIdComponent.isImplicitSha256Digest() ||
userKeyIdComponent.isParametersSha256Digest() ||
diff --git a/tools/ndnsec/sign-req.cpp b/tools/ndnsec/sign-req.cpp
index ca53819..2023ce9 100644
--- a/tools/ndnsec/sign-req.cpp
+++ b/tools/ndnsec/sign-req.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -83,7 +83,7 @@
// Create signing request (similar to self-signed certificate)
security::MakeCertificateOptions opts;
- opts.issuerId = name::Component::fromEscapedString("cert-request");
+ opts.issuerId = name::Component::fromUri("cert-request");
opts.validity = security::ValidityPeriod::makeRelative(-1_s, 10_days);
auto certificate = keyChain.makeCertificate(key, security::signingByKey(key), opts);