src: Making use of DEPRECATED macro and updating library code not to use deprecated methods
Change-Id: Ibe17977e7fcbb759a26dbe1cfa3d472598e49bcc
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index 52f9dd3..7913831 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -251,7 +251,10 @@
m_processEventsTimeoutTimer->cancel();
}
}
- onSuccess();
+
+ if (static_cast<bool>(onSuccess)) {
+ onSuccess();
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index d1a762f..c7e7b18 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -124,15 +124,15 @@
* @deprecated Use Block::fromStream instead
*/
explicit
- Block(std::istream& is)
+ DEPRECATED(Block(std::istream& is))
{
*this = Block::fromStream(is);
}
/*
- * @brief A helper version of a constructor to create Block from the stream.
+ * @brief Constructor Block from the stream
*/
- Block
+ static Block
fromStream(std::istream& is);
/**
diff --git a/src/exclude.cpp b/src/exclude.cpp
index 5dd6c5d..d2eed70 100644
--- a/src/exclude.cpp
+++ b/src/exclude.cpp
@@ -91,10 +91,8 @@
Exclude::excludeRange(const name::Component& from, const name::Component& to)
{
if (from >= to) {
- throw Error("Invalid exclude range [" +
- from.toEscapedString() + ", " +
- to.toEscapedString() +
- "] (for single name exclude use Exclude::excludeOne)");
+ throw Error("Invalid exclude range [" + from.toUri() + ", " + to.toUri() + "] "
+ "(for single name exclude use Exclude::excludeOne)");
}
iterator newFrom = m_exclude.lower_bound(from);
@@ -154,7 +152,7 @@
for (Exclude::const_reverse_iterator i = exclude.rbegin(); i != exclude.rend(); i++) {
if (!i->first.empty()) {
if (!empty) os << ",";
- os << i->first.toEscapedString();
+ os << i->first.toUri();
empty = false;
}
if (i->second) {
diff --git a/src/face.cpp b/src/face.cpp
index c2231c6..3fa693a 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -151,14 +151,9 @@
const Interest& tmpl,
const OnData& onData, const OnTimeout& onTimeout/* = OnTimeout()*/)
{
- return expressInterest(Interest(name,
- tmpl.getMinSuffixComponents(),
- tmpl.getMaxSuffixComponents(),
- tmpl.getExclude(),
- tmpl.getChildSelector(),
- tmpl.getMustBeFresh(),
- tmpl.getScope(),
- tmpl.getInterestLifetime()),
+ return expressInterest(Interest(tmpl)
+ .setName(name)
+ .setNonce(0),
onData, onTimeout);
}
diff --git a/src/face.hpp b/src/face.hpp
index 139ff28..ab7bb7e 100644
--- a/src/face.hpp
+++ b/src/face.hpp
@@ -112,8 +112,9 @@
* @throws ConfigFile::Error on configuration file parse failure
* @throws Face::Error on unsupported protocol
*/
+ DEPRECATED(
explicit
- Face(const shared_ptr<boost::asio::io_service>& ioService);
+ Face(const shared_ptr<boost::asio::io_service>& ioService));
/**
* @brief Create a new Face using the default transport (UnixTransport)
@@ -241,11 +242,12 @@
/**
* @deprecated Use the other overload
*/
+ DEPRECATED(
const RegisteredPrefixId*
setInterestFilter(const InterestFilter& interestFilter,
const OnInterest& onInterest,
const RegisterPrefixFailureCallback& onFailure,
- const IdentityCertificate& certificate = IdentityCertificate());
+ const IdentityCertificate& certificate = IdentityCertificate()));
/**
* @brief Set InterestFilter to dispatch incoming matching interest to onInterest
@@ -276,11 +278,12 @@
/**
* @deprecated Use the other overload
*/
+ DEPRECATED(
const RegisteredPrefixId*
setInterestFilter(const InterestFilter& interestFilter,
const OnInterest& onInterest,
const RegisterPrefixFailureCallback& onFailure,
- const Name& identity);
+ const Name& identity));
/**
* @brief Set InterestFilter to dispatch incoming matching interest to onInterest callback
@@ -445,8 +448,9 @@
*
* @deprecated Use getIoService instead
*/
+ DEPRECATED(
shared_ptr<boost::asio::io_service>
- ioService()
+ ioService())
{
return m_ioService;
}
diff --git a/src/interest.hpp b/src/interest.hpp
index c433ae8..ea23392 100644
--- a/src/interest.hpp
+++ b/src/interest.hpp
@@ -128,6 +128,7 @@
*
* Otherwise, Interest::shared_from_this() will throw an exception.
*/
+ DEPRECATED(
Interest(const Name& name,
int minSuffixComponents, int maxSuffixComponents,
const Exclude& exclude,
@@ -135,9 +136,14 @@
bool mustBeFresh,
int scope,
const time::milliseconds& interestLifetime,
- uint32_t nonce = 0)
+ uint32_t nonce = 0))
: m_name(name)
- , m_selectors(minSuffixComponents, maxSuffixComponents, exclude, childSelector, mustBeFresh)
+ , m_selectors(Selectors()
+ .setMinSuffixComponents(minSuffixComponents)
+ .setMaxSuffixComponents(maxSuffixComponents)
+ .setExclude(exclude)
+ .setChildSelector(childSelector)
+ .setMustBeFresh(mustBeFresh))
, m_nonce(nonce)
, m_scope(scope)
, m_interestLifetime(interestLifetime)
diff --git a/src/name-component.hpp b/src/name-component.hpp
index d58e4d6..751c490 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -194,8 +194,12 @@
*
* @param os The output stream to where write the URI escaped version *this
*/
+ DEPRECATED(
void
- toEscapedString(std::ostream& os) const;
+ toEscapedString(std::ostream& os) const)
+ {
+ return toUri(os);
+ }
/**
* @brief Convert *this by escaping characters according to the NDN URI Scheme
@@ -206,12 +210,11 @@
*
* @return The escaped string
*/
+ DEPRECATED(
std::string
- toEscapedString() const
+ toEscapedString() const)
{
- std::ostringstream result;
- toEscapedString(result);
- return result.str();
+ return toUri();
}
/**
@@ -222,10 +225,7 @@
* @param os The output stream to where write the URI escaped version *this
*/
void
- toUri(std::ostream& os) const
- {
- return toEscapedString(os);
- }
+ toUri(std::ostream& os) const;
/**
* @brief Convert *this by escaping characters according to the NDN URI Scheme
@@ -237,7 +237,9 @@
std::string
toUri() const
{
- return toEscapedString();
+ std::ostringstream os;
+ toUri(os);
+ return os.str();
}
/**
@@ -390,7 +392,7 @@
inline std::ostream&
operator<<(std::ostream& os, const Component& component)
{
- component.toEscapedString(os);
+ component.toUri(os);
return os;
}
@@ -468,7 +470,7 @@
inline void
-Component::toEscapedString(std::ostream& result) const
+Component::toUri(std::ostream& result) const
{
const uint8_t* valuePtr = value();
size_t valueSize = value_size();
diff --git a/src/name.hpp b/src/name.hpp
index 11a438d..8c348ac 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -534,7 +534,7 @@
{
for (Name::const_iterator i = name.begin(); i != name.end(); i++) {
os << "/";
- i->toEscapedString(os);
+ i->toUri(os);
}
}
return os;
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index 33e1e71..b3c544a 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -26,7 +26,7 @@
string idString("ID-CERT");
int i = name.size() - 1;
for (; i >= 0; i--) {
- if (name.get(i).toEscapedString() == idString)
+ if (name.get(i).toUri() == idString)
break;
}
@@ -36,7 +36,7 @@
string keyString("KEY");
size_t keyIndex = 0;
for (; keyIndex < name.size(); keyIndex++) {
- if (name.get(keyIndex).toEscapedString() == keyString)
+ if (name.get(keyIndex).toUri() == keyString)
break;
}
@@ -68,7 +68,7 @@
bool foundIdString = false;
size_t idCertComponentIndex = certificateName.size() - 1;
for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
- if (certificateName.get(idCertComponentIndex).toEscapedString() == idString)
+ if (certificateName.get(idCertComponentIndex).toUri() == idString)
{
foundIdString = true;
break;
@@ -83,7 +83,7 @@
bool foundKeyString = false;
size_t keyComponentIndex = 0;
for (; keyComponentIndex < tmpName.size(); keyComponentIndex++) {
- if (tmpName.get(keyComponentIndex).toEscapedString() == keyString)
+ if (tmpName.get(keyComponentIndex).toUri() == keyString)
{
foundKeyString = true;
break;
diff --git a/src/security/key-chain.cpp b/src/security/key-chain.cpp
index 67cdda6..18051c1 100644
--- a/src/security/key-chain.cpp
+++ b/src/security/key-chain.cpp
@@ -116,7 +116,7 @@
if (keyName.size() < 1)
return shared_ptr<IdentityCertificate>();
- std::string keyIdPrefix = keyName.get(-1).toEscapedString().substr(0, 4);
+ std::string keyIdPrefix = keyName.get(-1).toUri().substr(0, 4);
if (keyIdPrefix != "ksk-" && keyIdPrefix != "dsk-")
return shared_ptr<IdentityCertificate>();
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 7f248d5..86256f8 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -233,7 +233,7 @@
if (keyName.empty())
throw Error("Incorrect key name " + keyName.toUri());
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
sqlite3_stmt* statement;
@@ -269,7 +269,7 @@
if (doesPublicKeyExist(keyName))
return;
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
addIdentity(identityName);
@@ -302,7 +302,7 @@
throw Error("SecPublicInfoSqlite3::getPublicKey Empty keyName");
}
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
sqlite3_stmt* statement;
@@ -364,7 +364,7 @@
// if (keyName.empty())
// return;
-// std::string keyId = keyName.get(-1).toEscapedString();
+// std::string keyId = keyName.get(-1).toUri();
// std::string identityName = keyName.getPrefix(-1).toUri();
// sqlite3_stmt* statement;
@@ -421,7 +421,7 @@
if (doesCertificateExist(certificateName))
return;
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identity = keyName.getPrefix(-1);
// Insert the certificate
@@ -585,7 +585,7 @@
if (!doesPublicKeyExist(keyName))
throw Error("Key does not exist:" + keyName.toUri());
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
sqlite3_stmt* statement;
@@ -622,7 +622,7 @@
if (keyName.empty())
throw Error("SecPublicInfoSqlite3::getDefaultCertificateNameForKey wrong key");
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
sqlite3_stmt* statement;
@@ -657,7 +657,7 @@
throw Error("certificate does not exist:" + certificateName.toUri());
Name keyName = IdentityCertificate::certificateNameToPublicKeyName(certificateName);
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
Name identityName = keyName.getPrefix(-1);
sqlite3_stmt* statement;
@@ -812,7 +812,7 @@
Name identity = keyName.getPrefix(-1);
sqlite3_bind_text(stmt, 1, identity.toUri().c_str(), identity.toUri().size (), SQLITE_TRANSIENT);
- std::string baseKeyName = keyName.get(-1).toEscapedString();
+ std::string baseKeyName = keyName.get(-1).toUri();
sqlite3_bind_text(stmt, 2, baseKeyName.c_str(), baseKeyName.size(), SQLITE_TRANSIENT);
while (sqlite3_step(stmt) == SQLITE_ROW)
@@ -842,7 +842,7 @@
return;
string identity = keyName.getPrefix(-1).toUri();
- string keyId = keyName.get(-1).toEscapedString();
+ string keyId = keyName.get(-1).toUri();
sqlite3_stmt* stmt;
sqlite3_prepare_v2(m_database,
diff --git a/src/selectors.hpp b/src/selectors.hpp
index 4503c17..4e90ee7 100644
--- a/src/selectors.hpp
+++ b/src/selectors.hpp
@@ -36,10 +36,11 @@
/** @deprecated Selectors().setX(...).setY(...)
*/
+ DEPRECATED(
Selectors(int minSuffixComponents, int maxSuffixComponents,
const Exclude& exclude,
int childSelector,
- bool mustBeFresh)
+ bool mustBeFresh))
: m_minSuffixComponents(minSuffixComponents)
, m_maxSuffixComponents(maxSuffixComponents)
, m_exclude(exclude)
diff --git a/src/util/regex/regex-component-matcher.hpp b/src/util/regex/regex-component-matcher.hpp
index de0b6c9..fcc0ccc 100644
--- a/src/util/regex/regex-component-matcher.hpp
+++ b/src/util/regex/regex-component-matcher.hpp
@@ -99,7 +99,7 @@
if (m_isExactMatch)
{
boost::smatch subResult;
- std::string targetStr = name.get(offset).toEscapedString();
+ std::string targetStr = name.get(offset).toUri();
if (boost::regex_match(targetStr, subResult, m_componentRegex))
{
for (size_t i = 1; i < m_componentRegex.mark_count(); i++)
diff --git a/src/util/regex/regex-top-matcher.cpp b/src/util/regex/regex-top-matcher.cpp
index 3c95959..43cd169 100644
--- a/src/util/regex/regex-top-matcher.cpp
+++ b/src/util/regex/regex-top-matcher.cpp
@@ -196,7 +196,7 @@
for (Name::const_iterator it = name.begin(); it != name.end(); it++)
{
regexStr.append("<");
- regexStr.append(convertSpecialChar(it->toEscapedString()));
+ regexStr.append(convertSpecialChar(it->toUri()));
regexStr.append(">");
}