exceptions: Make Tlv::Error a base class for all packet-processing exceptions
This commit also includes a number of code style fixes.
Change-Id: I44f83915e733b43d5f43b4266902c8262e928d91
Refs: #1528
diff --git a/src/detail/pending-interest.hpp b/src/detail/pending-interest.hpp
index c481acc..c0a35e3 100644
--- a/src/detail/pending-interest.hpp
+++ b/src/detail/pending-interest.hpp
@@ -14,7 +14,8 @@
namespace ndn {
-class PendingInterest {
+class PendingInterest
+{
public:
typedef function<void(const Interest&, Data&)> OnData;
typedef function<void(const Interest&)> OnTimeout;
diff --git a/src/encoding/block.hpp b/src/encoding/block.hpp
index 8079531..6777f77 100644
--- a/src/encoding/block.hpp
+++ b/src/encoding/block.hpp
@@ -30,7 +30,7 @@
typedef element_container::iterator element_iterator;
typedef element_container::const_iterator element_const_iterator;
- /// @brief Error that can be thrown from the block
+ /// @brief Error that can be thrown from Block
class Error : public Tlv::Error
{
public:
@@ -53,7 +53,8 @@
Block(const EncodingBuffer& buffer);
/**
- * @brief A helper version of a constructor to create Block from the raw buffer (type and value-length parsing)
+ * @brief A helper version of a constructor to create Block from the raw buffer (type
+ * and value-length parsing)
*
* This constructor provides ability of implicit conversion from ConstBufferPtr to Block
*/
@@ -70,7 +71,8 @@
bool verifyLength = true);
/**
- * @brief A helper version of a constructor to create Block from the raw buffer (type and value-length parsing)
+ * @brief A helper version of a constructor to create Block from the raw buffer (type
+ * and value-length parsing)
*/
Block(const uint8_t* buffer, size_t maxlength);
diff --git a/src/encoding/cryptopp/asn_ext.hpp b/src/encoding/cryptopp/asn_ext.hpp
index 5d726dc..afd33dc 100644
--- a/src/encoding/cryptopp/asn_ext.hpp
+++ b/src/encoding/cryptopp/asn_ext.hpp
@@ -9,26 +9,11 @@
#ifndef NDN_ASN_EXT_HPP
#define NDN_ASN_EXT_HPP
-#include <stdexcept>
#include "../../common.hpp"
#include "../../security/cryptopp.hpp"
namespace ndn {
-namespace asn {
-
-class Error : public std::runtime_error
-{
-public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
-};
-
-} // namespace asn
-
size_t
DEREncodeGeneralTime(CryptoPP::BufferedTransformation& bt,
const time::system_clock::TimePoint& time);
diff --git a/src/encoding/oid.hpp b/src/encoding/oid.hpp
index e7b1beb..0cd570d 100644
--- a/src/encoding/oid.hpp
+++ b/src/encoding/oid.hpp
@@ -11,11 +11,14 @@
#include "../common.hpp"
-namespace CryptoPP { class BufferedTransformation; }
+namespace CryptoPP {
+class BufferedTransformation;
+}
namespace ndn {
-class OID {
+class OID
+{
public:
OID ()
{
diff --git a/src/exclude.hpp b/src/exclude.hpp
index 9fb5c3a..d086f14 100644
--- a/src/exclude.hpp
+++ b/src/exclude.hpp
@@ -21,12 +21,12 @@
class Exclude
{
public:
- class Error : public std::runtime_error
+ class Error : public Tlv::Error
{
public:
explicit
Error(const std::string& what)
- : std::runtime_error(what)
+ : Tlv::Error(what)
{
}
};
diff --git a/src/face.cpp b/src/face.cpp
index 3e5a4b1..5e9cd3c 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -77,11 +77,11 @@
{
protocol = m_config.getParsedConfiguration().get<std::string>("protocol");
}
- catch (const boost::property_tree::ptree_bad_path& error)
+ catch (boost::property_tree::ptree_bad_path& error)
{
// protocol not specified
}
- catch (const boost::property_tree::ptree_bad_data& error)
+ catch (boost::property_tree::ptree_bad_data& error)
{
throw ConfigFile::Error(error.what());
}
@@ -276,7 +276,7 @@
// break
m_ioService->reset();
}
- catch (const std::exception&)
+ catch (std::exception&)
{
m_ioService->reset();
m_pendingInterestTable.clear();
diff --git a/src/key-locator.hpp b/src/key-locator.hpp
index 14a1b5e..f0700e2 100644
--- a/src/key-locator.hpp
+++ b/src/key-locator.hpp
@@ -13,7 +13,8 @@
namespace ndn {
-class KeyLocator {
+class KeyLocator
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/management/ndnd-face-instance.hpp b/src/management/ndnd-face-instance.hpp
index 530f10d..24f90f9 100644
--- a/src/management/ndnd-face-instance.hpp
+++ b/src/management/ndnd-face-instance.hpp
@@ -17,7 +17,8 @@
/**
* An FaceInstance holds an action and Name prefix and other fields for an forwarding entry.
*/
-class FaceInstance {
+class FaceInstance
+{
public:
FaceInstance(const std::string& action,
int64_t faceId,
diff --git a/src/management/ndnd-forwarding-entry.hpp b/src/management/ndnd-forwarding-entry.hpp
index a084964..e654ff4 100644
--- a/src/management/ndnd-forwarding-entry.hpp
+++ b/src/management/ndnd-forwarding-entry.hpp
@@ -19,7 +19,8 @@
/**
* An ForwardingEntry holds an action and Name prefix and other fields for an forwarding entry.
*/
-class ForwardingEntry {
+class ForwardingEntry
+{
public:
ForwardingEntry(const std::string& action,
const Name& prefix,
diff --git a/src/management/ndnd-forwarding-flags.hpp b/src/management/ndnd-forwarding-flags.hpp
index 803dabc..36a565f 100644
--- a/src/management/ndnd-forwarding-flags.hpp
+++ b/src/management/ndnd-forwarding-flags.hpp
@@ -19,7 +19,8 @@
* a registered prefix. We use a separate ForwardingFlags object to retain future compatibility if the daemon forwarding
* bits are changed, amended or deprecated.
*/
-class ForwardingFlags {
+class ForwardingFlags
+{
public:
/**
* Create a new ForwardingFlags with "active" and "childInherit" set and all other flags cleared.
diff --git a/src/management/ndnd-status-response.hpp b/src/management/ndnd-status-response.hpp
index 23597b9..2229a1d 100644
--- a/src/management/ndnd-status-response.hpp
+++ b/src/management/ndnd-status-response.hpp
@@ -13,7 +13,8 @@
namespace ndn {
namespace ndnd {
-class StatusResponse {
+class StatusResponse
+{
public:
StatusResponse()
: code_(0)
diff --git a/src/management/nfd-control-response.hpp b/src/management/nfd-control-response.hpp
index a4a5ae3..3c2a06d 100644
--- a/src/management/nfd-control-response.hpp
+++ b/src/management/nfd-control-response.hpp
@@ -18,7 +18,8 @@
*
* @see http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
*/
-class ControlResponse {
+class ControlResponse
+{
public:
class Error : public Tlv::Error
{
diff --git a/src/management/nrd-prefix-reg-options.hpp b/src/management/nrd-prefix-reg-options.hpp
index ea8ca4d..8f2a0e5 100644
--- a/src/management/nrd-prefix-reg-options.hpp
+++ b/src/management/nrd-prefix-reg-options.hpp
@@ -25,7 +25,8 @@
* @see http://redmine.named-data.net/projects/nrd/wiki/NRD_Prefix_Registration_protocol
* @deprecated use NFD RIB Management
*/
-class PrefixRegOptions {
+class PrefixRegOptions
+{
public:
class Error : public Tlv::Error
{
diff --git a/src/meta-info.hpp b/src/meta-info.hpp
index 4153911..03600cf 100644
--- a/src/meta-info.hpp
+++ b/src/meta-info.hpp
@@ -14,7 +14,8 @@
/**
* An MetaInfo holds the meta info which is signed inside the data packet.
*/
-class MetaInfo {
+class MetaInfo
+{
public:
enum {
TYPE_DEFAULT = 0,
diff --git a/src/name-component.hpp b/src/name-component.hpp
index 5e5cb09..ff13346 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -25,14 +25,14 @@
{
public:
/**
- * @brief Error that can be thrown from the block
+ * @brief Error that can be thrown from name::Component
*/
- class Error : public std::runtime_error
+ class Error : public Block::Error
{
public:
explicit
Error(const std::string& what)
- : std::runtime_error(what)
+ : Block::Error(what)
{
}
};
diff --git a/src/name.hpp b/src/name.hpp
index 03030f0..3a0cc52 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -23,13 +23,18 @@
/**
* A Name holds an array of Name::Component and represents an NDN name.
*/
-class Name : public ptr_lib::enable_shared_from_this<Name> {
+class Name : public ptr_lib::enable_shared_from_this<Name>
+{
public:
- /// @brief Error that can be thrown from the block
- class Error : public name::Component::Error {
+ /// @brief Error that can be thrown from Name
+ class Error : public name::Component::Error
+ {
public:
+ explicit
Error(const std::string& what)
- : name::Component::Error(what) {}
+ : name::Component::Error(what)
+ {
+ }
};
typedef name::Component Component;
diff --git a/src/security/certificate-extension.hpp b/src/security/certificate-extension.hpp
index a1aa5b6..83653ee 100644
--- a/src/security/certificate-extension.hpp
+++ b/src/security/certificate-extension.hpp
@@ -13,7 +13,9 @@
#include "../encoding/buffer.hpp"
#include "../encoding/oid.hpp"
-namespace CryptoPP { class BufferedTransformation; }
+namespace CryptoPP {
+class BufferedTransformation;
+}
namespace ndn {
diff --git a/src/security/certificate-subject-description.hpp b/src/security/certificate-subject-description.hpp
index 7665a3f..e8732f0 100644
--- a/src/security/certificate-subject-description.hpp
+++ b/src/security/certificate-subject-description.hpp
@@ -12,14 +12,17 @@
#include "../common.hpp"
#include "../encoding/oid.hpp"
-namespace CryptoPP { class BufferedTransformation; }
+namespace CryptoPP {
+class BufferedTransformation;
+}
namespace ndn {
/**
* A CertificateSubjectDescription represents the SubjectDescription entry in a Certificate.
*/
-class CertificateSubjectDescription {
+class CertificateSubjectDescription
+{
public:
CertificateSubjectDescription(CryptoPP::BufferedTransformation& in)
{
diff --git a/src/security/certificate.hpp b/src/security/certificate.hpp
index dc96879..157b878 100644
--- a/src/security/certificate.hpp
+++ b/src/security/certificate.hpp
@@ -17,7 +17,8 @@
namespace ndn {
-class Certificate : public Data {
+class Certificate : public Data
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/security/conf/checker.hpp b/src/security/conf/checker.hpp
index 72ae726..6955dfe 100644
--- a/src/security/conf/checker.hpp
+++ b/src/security/conf/checker.hpp
@@ -101,16 +101,16 @@
interestName[INTEREST_SIG_VALUE].blockFromValue());
return check(interest, signature, onValidated, onValidationFailed);
}
- catch (const Tlv::Error& e)
- {
- onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
- return -1;
- }
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
onValidationFailed(interest.shared_from_this(), "Invalid signature");
return -1;
}
+ catch (Tlv::Error& e)
+ {
+ onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
+ return -1;
+ }
}
private:
@@ -147,7 +147,7 @@
return -1;
}
}
- catch (const SignatureSha256WithRsa::Error& e)
+ catch (SignatureSha256WithRsa::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"Cannot decode Sha256WithRsa signature!");
@@ -221,16 +221,16 @@
interestName[INTEREST_SIG_VALUE].blockFromValue());
return check(interest, signature, onValidated, onValidationFailed);
}
- catch (const Tlv::Error& e)
- {
- onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
- return -1;
- }
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
onValidationFailed(interest.shared_from_this(), "Invalid signature");
return -1;
}
+ catch (Tlv::Error& e)
+ {
+ onValidationFailed(interest.shared_from_this(), "Cannot decode signature related TLVs");
+ return -1;
+ }
}
private:
@@ -280,13 +280,13 @@
return -1;
}
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"KeyLocator does not have name!");
return -1;
}
- catch (const SignatureSha256WithRsa::Error& e)
+ catch (SignatureSha256WithRsa::Error& e)
{
onValidationFailed(packet.shared_from_this(),
"Cannot decode signature!");
diff --git a/src/security/conf/filter.hpp b/src/security/conf/filter.hpp
index 7d5b833..4145222 100644
--- a/src/security/conf/filter.hpp
+++ b/src/security/conf/filter.hpp
@@ -207,7 +207,7 @@
{
return shared_ptr<RegexNameFilter>(new RegexNameFilter(regexString));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Wrong filter.regex: " + regexString);
}
diff --git a/src/security/conf/key-locator-checker.hpp b/src/security/conf/key-locator-checker.hpp
index 5785c59..e040d80 100644
--- a/src/security/conf/key-locator-checker.hpp
+++ b/src/security/conf/key-locator-checker.hpp
@@ -107,7 +107,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -141,7 +141,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -182,7 +182,7 @@
failInfo = "KeyLocatorChecker failed!";
return false;
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
failInfo = "KeyLocator does not have name";
return false;
@@ -277,7 +277,7 @@
return shared_ptr<RegexKeyLocatorNameChecker>
(new RegexKeyLocatorNameChecker(regexString));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Invalid checker.key-locator.regex: " + regexString);
}
@@ -344,7 +344,7 @@
kRegex, kExpand,
relation));
}
- catch (const Regex::Error& e)
+ catch (Regex::Error& e)
{
throw Error("Invalid regex for key-locator.hyper-relation");
}
diff --git a/src/security/encryption-manager.hpp b/src/security/encryption-manager.hpp
index a6f319b..f4f43b5 100644
--- a/src/security/encryption-manager.hpp
+++ b/src/security/encryption-manager.hpp
@@ -13,7 +13,8 @@
namespace ndn {
-class EncryptionManager {
+class EncryptionManager
+{
public:
virtual ~EncryptionManager()
{
diff --git a/src/security/public-key.hpp b/src/security/public-key.hpp
index 7774755..4a8f16a 100644
--- a/src/security/public-key.hpp
+++ b/src/security/public-key.hpp
@@ -16,7 +16,8 @@
namespace ndn {
-class PublicKey {
+class PublicKey
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/security/sec-public-info-memory.hpp b/src/security/sec-public-info-memory.hpp
index 2ecdc43..4cbceac 100644
--- a/src/security/sec-public-info-memory.hpp
+++ b/src/security/sec-public-info-memory.hpp
@@ -17,7 +17,8 @@
* @brief SecPublicInfoMemory extends SecPublicInfo and implements its methods to store identity,
* public key and certificate objects in memory.
*/
-class SecPublicInfoMemory : public SecPublicInfo {
+class SecPublicInfoMemory : public SecPublicInfo
+{
public:
class Error : public SecPublicInfo::Error
{
@@ -104,7 +105,8 @@
private:
- class KeyRecord {
+ class KeyRecord
+ {
public:
KeyRecord(KeyType keyType, const PublicKey& key)
: m_keyType(keyType), m_key(key)
diff --git a/src/security/sec-public-info-sqlite3.hpp b/src/security/sec-public-info-sqlite3.hpp
index 6241817..4f5115f 100644
--- a/src/security/sec-public-info-sqlite3.hpp
+++ b/src/security/sec-public-info-sqlite3.hpp
@@ -16,7 +16,8 @@
namespace ndn {
-class SecPublicInfoSqlite3 : public SecPublicInfo {
+class SecPublicInfoSqlite3 : public SecPublicInfo
+{
public:
class Error : public SecPublicInfo::Error
{
diff --git a/src/security/sec-public-info.hpp b/src/security/sec-public-info.hpp
index 99b4f57..ee32d05 100644
--- a/src/security/sec-public-info.hpp
+++ b/src/security/sec-public-info.hpp
@@ -23,7 +23,8 @@
* It specify interfaces related to public information, such as identity, public keys and
* certificates.
*/
-class SecPublicInfo {
+class SecPublicInfo
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/security/sec-tpm-file.cpp b/src/security/sec-tpm-file.cpp
index 5238ca4..ba3cca8 100644
--- a/src/security/sec-tpm-file.cpp
+++ b/src/security/sec-tpm-file.cpp
@@ -25,7 +25,8 @@
namespace ndn {
-class SecTpmFile::Impl {
+class SecTpmFile::Impl
+{
public:
Impl(const string& dir)
{
@@ -123,7 +124,7 @@
throw Error("Unsupported key type!");
}
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
throw Error(e.what());
}
@@ -158,7 +159,7 @@
true,
new Base64Decoder(new FileSink(os)));
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
throw Error(e.what());
}
@@ -191,7 +192,7 @@
new Base64Encoder(new FileSink(keyFileName.c_str())));
return true;
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
@@ -211,7 +212,7 @@
new Base64Encoder(new FileSink(keyFileName.c_str())));
return true;
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
@@ -258,7 +259,7 @@
throw Error("Unsupported digest algorithm!");
}
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
throw Error(e.what());
}
@@ -294,7 +295,7 @@
// return os.buf();
// }
- // catch (const CryptoPP::Exception& e){
+ // catch (CryptoPP::Exception& e){
// throw Error(e.what());
// }
// }
@@ -321,7 +322,7 @@
// // StringSource(data, dataLength, true, new StreamTransformationFilter(decryptor,new FileSink(os)));
// // return os.buf();
- // // }catch (const CryptoPP::Exception& e){
+ // // }catch (CryptoPP::Exception& e){
// // throw Error(e.what());
// // }
// }
@@ -357,7 +358,7 @@
// StringSource(data, dataLength, true, new PK_EncryptorFilter(rng, encryptor, new FileSink(os)));
// return os.buf();
// }
- // catch (const CryptoPP::Exception& e){
+ // catch (CryptoPP::Exception& e){
// throw Error(e.what());
// }
// }
@@ -383,7 +384,7 @@
// // OBufferStream os;
// // StringSource(data, dataLength, true, new StreamTransformationFilter(encryptor, new FileSink(os)));
// // return os.buf();
- // // }catch (const CryptoPP::Exception& e){
+ // // }catch (CryptoPP::Exception& e){
// // throw Error(e.what());
// // }
// }
@@ -420,7 +421,7 @@
// default:
// throw Error("Unsupported symmetric key type!");
// }
- // }catch (const CryptoPP::Exception& e){
+ // }catch (CryptoPP::Exception& e){
// throw Error(e.what());
// }
}
@@ -462,7 +463,7 @@
rng.GenerateBlock(res, size);
return true;
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
diff --git a/src/security/sec-tpm-memory.cpp b/src/security/sec-tpm-memory.cpp
index 3475aa4..393a217 100644
--- a/src/security/sec-tpm-memory.cpp
+++ b/src/security/sec-tpm-memory.cpp
@@ -20,7 +20,8 @@
/**
* RsaPrivateKey is a simple class to hold an RSA private key.
*/
-class SecTpmMemory::RsaPrivateKey {
+class SecTpmMemory::RsaPrivateKey
+{
public:
RsaPrivateKey(const uint8_t* keyDer, size_t keyDerLength)
{
@@ -175,7 +176,7 @@
rng.GenerateBlock(res, size);
return true;
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
diff --git a/src/security/sec-tpm-memory.hpp b/src/security/sec-tpm-memory.hpp
index 61b1c8a..eb1613d 100644
--- a/src/security/sec-tpm-memory.hpp
+++ b/src/security/sec-tpm-memory.hpp
@@ -20,7 +20,8 @@
*
* You should initialize by calling setKeyPairForKeyName.
*/
-class SecTpmMemory : public SecTpm {
+class SecTpmMemory : public SecTpm
+{
public:
class Error : public SecTpm::Error
{
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index d06cefe..fd21439 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -28,12 +28,14 @@
namespace ndn {
-class SecTpmOsx::Impl {
+class SecTpmOsx::Impl
+{
public:
Impl()
: m_passwordSet(false)
, m_inTerminal(false)
- {}
+ {
+ }
/**
* @brief Convert NDN name of a key to internal name of the key.
diff --git a/src/security/sec-tpm-osx.hpp b/src/security/sec-tpm-osx.hpp
index d6637ef..1a5bd1f 100644
--- a/src/security/sec-tpm-osx.hpp
+++ b/src/security/sec-tpm-osx.hpp
@@ -13,7 +13,8 @@
namespace ndn {
-class SecTpmOsx : public SecTpm {
+class SecTpmOsx : public SecTpm
+{
public:
class Error : public SecTpm::Error
{
diff --git a/src/security/sec-tpm.hpp b/src/security/sec-tpm.hpp
index 15f1770..14b5756 100644
--- a/src/security/sec-tpm.hpp
+++ b/src/security/sec-tpm.hpp
@@ -22,7 +22,8 @@
*
* It specifies the interfaces of private/secret key related operations.
*/
-class SecTpm {
+class SecTpm
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/security/signature-sha256-with-rsa.hpp b/src/security/signature-sha256-with-rsa.hpp
index 7e19a1e..f809709 100644
--- a/src/security/signature-sha256-with-rsa.hpp
+++ b/src/security/signature-sha256-with-rsa.hpp
@@ -15,8 +15,19 @@
/**
* Representing of SHA256-with-RSA signature in a data packet.
*/
-class SignatureSha256WithRsa : public Signature {
+class SignatureSha256WithRsa : public Signature
+{
public:
+ class Error : public Signature::Error
+ {
+ public:
+ explicit
+ Error(const std::string& what)
+ : Signature::Error(what)
+ {
+ }
+ };
+
SignatureSha256WithRsa()
{
m_info = Block(Tlv::SignatureInfo);
@@ -30,7 +41,7 @@
: Signature(signature)
{
if (getType() != Signature::Sha256WithRsa)
- throw Signature::Error("Incorrect signature type");
+ throw Error("Incorrect signature type");
m_info.parse();
Block::element_const_iterator i = m_info.find(Tlv::KeyLocator);
diff --git a/src/security/signature-sha256.hpp b/src/security/signature-sha256.hpp
index 8ef37a8..9200ac5 100644
--- a/src/security/signature-sha256.hpp
+++ b/src/security/signature-sha256.hpp
@@ -15,8 +15,19 @@
/**
* Representing of SHA256 signature in a data packet.
*/
-class SignatureSha256 : public Signature {
+class SignatureSha256 : public Signature
+{
public:
+ class Error : public Signature::Error
+ {
+ public:
+ explicit
+ Error(const std::string& what)
+ : Signature::Error(what)
+ {
+ }
+ };
+
SignatureSha256()
{
m_info = Block(Tlv::SignatureInfo);
@@ -29,7 +40,7 @@
: Signature(signature)
{
if (getType() != Signature::Sha256)
- throw Signature::Error("Incorrect signature type");
+ throw Error("Incorrect signature type");
}
};
diff --git a/src/security/validation-request.hpp b/src/security/validation-request.hpp
index 8846636..b525c27 100644
--- a/src/security/validation-request.hpp
+++ b/src/security/validation-request.hpp
@@ -27,7 +27,8 @@
const std::string&)> OnDataValidationFailed;
-class ValidationRequest {
+class ValidationRequest
+{
public:
ValidationRequest(const Interest& interest,
const OnDataValidated& onValidated,
diff --git a/src/security/validator-config.cpp b/src/security/validator-config.cpp
index 77d3354..4b430ce 100644
--- a/src/security/validator-config.cpp
+++ b/src/security/validator-config.cpp
@@ -70,7 +70,7 @@
{
boost::property_tree::read_info(input, tree);
}
- catch (const boost::property_tree::info_parser_error& error)
+ catch (boost::property_tree::info_parser_error& error)
{
std::stringstream msg;
msg << "Failed to parse configuration file";
diff --git a/src/security/validator-null.hpp b/src/security/validator-null.hpp
index f389d4c..1bb6d01 100644
--- a/src/security/validator-null.hpp
+++ b/src/security/validator-null.hpp
@@ -13,7 +13,8 @@
namespace ndn {
-class ValidatorNull : public Validator {
+class ValidatorNull : public Validator
+{
public:
virtual
~ValidatorNull()
diff --git a/src/security/validator-regex.cpp b/src/security/validator-regex.cpp
index 1eea45e..e9558c6 100644
--- a/src/security/validator-regex.cpp
+++ b/src/security/validator-regex.cpp
@@ -152,13 +152,13 @@
return;
}
}
- catch (const SignatureSha256WithRsa::Error& e)
+ catch (SignatureSha256WithRsa::Error& e)
{
return onValidationFailed(data.shared_from_this(),
"Not SignatureSha256WithRsa signature: " +
data.getName().toUri());
}
- catch (const KeyLocator::Error& e)
+ catch (KeyLocator::Error& e)
{
return onValidationFailed(data.shared_from_this(),
"Key Locator is not a name: " +
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 338ef9f..7f97926 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -142,7 +142,7 @@
}
}
}
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
return false;
}
@@ -180,11 +180,11 @@
}
}
}
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
return false;
}
- catch (const Block::Error& e)
+ catch (Block::Error& e)
{
return false;
}
@@ -209,7 +209,7 @@
}
}
}
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
return false;
}
@@ -237,7 +237,7 @@
sig.getValue().value(),
sig.getValue().value_size());
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
@@ -264,7 +264,7 @@
else
return false;
}
- catch (const CryptoPP::Exception& e)
+ catch (CryptoPP::Exception& e)
{
return false;
}
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 43ab01a..38a8db2 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -24,7 +24,8 @@
*
* The Validator class provides the interfaces for packet validation.
*/
-class Validator {
+class Validator
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/signature.hpp b/src/signature.hpp
index 8a20baa..3d3c4c9 100644
--- a/src/signature.hpp
+++ b/src/signature.hpp
@@ -12,14 +12,15 @@
/**
* A Signature is storage for the signature-related information (info and value) in a Data packet.
*/
-class Signature {
+class Signature
+{
public:
- class Error : public std::runtime_error
+ class Error : public Tlv::Error
{
public:
explicit
Error(const std::string& what)
- : std::runtime_error(what)
+ : Tlv::Error(what)
{
}
};
diff --git a/src/transport/tcp-transport.hpp b/src/transport/tcp-transport.hpp
index 6795580..db90ae4 100644
--- a/src/transport/tcp-transport.hpp
+++ b/src/transport/tcp-transport.hpp
@@ -26,11 +26,11 @@
~TcpTransport();
// from Transport
- virtual void
+ virtual void
connect(boost::asio::io_service& ioService,
const ReceiveCallback& receiveCallback);
-
- virtual void
+
+ virtual void
close();
virtual void
@@ -39,10 +39,10 @@
virtual void
resume();
- virtual void
+ virtual void
send(const Block& wire);
- virtual void
+ virtual void
send(const Block& header, const Block& payload);
private:
diff --git a/src/transport/transport.hpp b/src/transport/transport.hpp
index 08740fb..eda9521 100644
--- a/src/transport/transport.hpp
+++ b/src/transport/transport.hpp
@@ -12,7 +12,8 @@
namespace ndn {
-class Transport {
+class Transport
+{
public:
class Error : public std::runtime_error
{
diff --git a/src/transport/unix-transport.cpp b/src/transport/unix-transport.cpp
index ad6db2c..4dc636a 100644
--- a/src/transport/unix-transport.cpp
+++ b/src/transport/unix-transport.cpp
@@ -30,11 +30,11 @@
{
return parsed.get<std::string>("unix_socket");
}
- catch (const boost::property_tree::ptree_bad_path& error)
+ catch (boost::property_tree::ptree_bad_path& error)
{
// unix_socket not present, continue
}
- catch (const boost::property_tree::ptree_bad_data& error)
+ catch (boost::property_tree::ptree_bad_data& error)
{
throw ConfigFile::Error(error.what());
}
diff --git a/src/util/command-interest-validator.hpp b/src/util/command-interest-validator.hpp
index 07e164f..c543549 100644
--- a/src/util/command-interest-validator.hpp
+++ b/src/util/command-interest-validator.hpp
@@ -182,21 +182,21 @@
timestampIt->second = interestTime;
}
}
- catch (const Tlv::Error& e)
- {
- return onValidationFailed(interest.shared_from_this(),
- "Cannot decode signature related TLVs");
- }
- catch (const Signature::Error& e)
+ catch (Signature::Error& e)
{
return onValidationFailed(interest.shared_from_this(),
"No valid signature");
}
- catch (const IdentityCertificate::Error& e)
+ catch (IdentityCertificate::Error& e)
{
return onValidationFailed(interest.shared_from_this(),
"Cannot locate the signing key");
}
+ catch (Tlv::Error& e)
+ {
+ return onValidationFailed(interest.shared_from_this(),
+ "Cannot decode signature related TLVs");
+ }
return onValidated(interest.shared_from_this());
}
diff --git a/src/util/config-file.cpp b/src/util/config-file.cpp
index 031df25..c80ddc6 100644
--- a/src/util/config-file.cpp
+++ b/src/util/config-file.cpp
@@ -108,7 +108,7 @@
{
boost::property_tree::read_ini(m_input, m_config);
}
- catch (const boost::property_tree::ini_parser_error& error)
+ catch (boost::property_tree::ini_parser_error& error)
{
std::stringstream msg;
msg << "Failed to parse configuration file";
@@ -120,4 +120,3 @@
}
}
-
diff --git a/src/util/io.hpp b/src/util/io.hpp
index ff6852b..0bb929b 100644
--- a/src/util/io.hpp
+++ b/src/util/io.hpp
@@ -76,7 +76,7 @@
{
return shared_ptr<T>();
}
- catch (Block::Error& e)
+ catch (Tlv::Error& e)
{
return shared_ptr<T>();
}
@@ -134,7 +134,7 @@
{
throw Error(e.what());
}
- catch (Block::Error& e)
+ catch (Tlv::Error& e)
{
throw Error(e.what());
}
diff --git a/src/util/regex/regex-component-set-matcher.hpp b/src/util/regex/regex-component-set-matcher.hpp
index 5aed58f..b8c9845 100644
--- a/src/util/regex/regex-component-set-matcher.hpp
+++ b/src/util/regex/regex-component-set-matcher.hpp
@@ -15,7 +15,8 @@
namespace ndn {
-class RegexComponentSetMatcher : public RegexMatcher {
+class RegexComponentSetMatcher : public RegexMatcher
+{
public:
/**