Replace remaining uses of BOOST_THROW_EXCEPTION with NDN_THROW
Minor formatting improvements in examples/README.md
Change-Id: Ib8f605074b9ee07c8dea2e9ea2bf04892251d945
diff --git a/PSync/detail/bloom-filter.cpp b/PSync/detail/bloom-filter.cpp
index 9067a03..f700f16 100644
--- a/PSync/detail/bloom-filter.cpp
+++ b/PSync/detail/bloom-filter.cpp
@@ -46,6 +46,7 @@
#include "PSync/detail/bloom-filter.hpp"
#include "PSync/detail/util.hpp"
+#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/logger.hpp>
#include <algorithm>
@@ -162,12 +163,12 @@
BloomFilter::BloomFilter(unsigned int projected_element_count,
double false_positive_probability,
const ndn::name::Component& bfName)
- : BloomFilter(projected_element_count, false_positive_probability)
+ : BloomFilter(projected_element_count, false_positive_probability)
{
std::vector<BloomFilter::cell_type> table(bfName.value_begin(), bfName.value_end());
if (table.size() != raw_table_size_) {
- BOOST_THROW_EXCEPTION(Error("Received BloomFilter cannot be decoded!"));
+ NDN_THROW(Error("Received BloomFilter cannot be decoded!"));
}
bit_table_ = table;
}
diff --git a/PSync/detail/bloom-filter.hpp b/PSync/detail/bloom-filter.hpp
index adbfc88..f7e3726 100644
--- a/PSync/detail/bloom-filter.hpp
+++ b/PSync/detail/bloom-filter.hpp
@@ -43,8 +43,8 @@
* SOFTWARE.
*/
-#ifndef PSYNC_BLOOM_FILTER_HPP
-#define PSYNC_BLOOM_FILTER_HPP
+#ifndef PSYNC_DETAIL_BLOOM_FILTER_HPP
+#define PSYNC_DETAIL_BLOOM_FILTER_HPP
#include <ndn-cxx/name.hpp>
@@ -177,4 +177,4 @@
} // namespace psync
-#endif // PSYNC_BLOOM_FILTER_HPP
+#endif // PSYNC_DETAIL_BLOOM_FILTER_HPP
diff --git a/PSync/detail/iblt.cpp b/PSync/detail/iblt.cpp
index 61e8211..dcc2931 100644
--- a/PSync/detail/iblt.cpp
+++ b/PSync/detail/iblt.cpp
@@ -45,6 +45,8 @@
#include "PSync/detail/iblt.hpp"
+#include <ndn-cxx/util/exception.hpp>
+
namespace psync {
namespace be = boost::endian;
diff --git a/PSync/detail/iblt.hpp b/PSync/detail/iblt.hpp
index f3278b3..3b7ad88 100644
--- a/PSync/detail/iblt.hpp
+++ b/PSync/detail/iblt.hpp
@@ -43,8 +43,8 @@
* SOFTWARE.
*/
-#ifndef PSYNC_IBLT_HPP
-#define PSYNC_IBLT_HPP
+#ifndef PSYNC_DETAIL_IBLT_HPP
+#define PSYNC_DETAIL_IBLT_HPP
#include "PSync/detail/util.hpp"
@@ -52,8 +52,8 @@
#include <inttypes.h>
#include <set>
-#include <vector>
#include <string>
+#include <vector>
namespace psync {
@@ -179,4 +179,4 @@
} // namespace psync
-#endif // PSYNC_IBLT_HPP
+#endif // PSYNC_DETAIL_IBLT_HPP
diff --git a/PSync/detail/state.cpp b/PSync/detail/state.cpp
index 66173bd..beabda9 100644
--- a/PSync/detail/state.cpp
+++ b/PSync/detail/state.cpp
@@ -19,6 +19,7 @@
#include "PSync/detail/state.hpp"
+#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/ostream-joiner.hpp>
namespace psync {
@@ -73,10 +74,9 @@
void
State::wireDecode(const ndn::Block& wire)
{
- auto blockType = wire.type();
- if (blockType != tlv::PSyncContent) {
- BOOST_THROW_EXCEPTION(ndn::tlv::Error("Expected PSyncContent Block, but Block is of type: #" +
- ndn::to_string(blockType)));
+ if (wire.type() != tlv::PSyncContent) {
+ NDN_THROW(ndn::tlv::Error("Expected PSyncContent element, but TLV has type " +
+ ndn::to_string(wire.type())));
}
m_content.clear();
@@ -89,8 +89,8 @@
m_content.emplace_back(*it);
}
else {
- BOOST_THROW_EXCEPTION(ndn::tlv::Error("Expected Name Block, but Block is of type: #" +
- ndn::to_string(it->type())));
+ NDN_THROW(ndn::tlv::Error("Expected Name element, but TLV has type " +
+ ndn::to_string(it->type())));
}
}
}
diff --git a/PSync/detail/state.hpp b/PSync/detail/state.hpp
index 8a40331..38e6508 100644
--- a/PSync/detail/state.hpp
+++ b/PSync/detail/state.hpp
@@ -17,8 +17,8 @@
* PSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PSYNC_STATE_HPP
-#define PSYNC_STATE_HPP
+#ifndef PSYNC_DETAIL_STATE_HPP
+#define PSYNC_DETAIL_STATE_HPP
#include <ndn-cxx/name.hpp>
@@ -82,4 +82,4 @@
} // namespace psync
-#endif // PSYNC_STATE_HPP
\ No newline at end of file
+#endif // PSYNC_DETAIL_STATE_HPP
diff --git a/PSync/detail/util.hpp b/PSync/detail/util.hpp
index 2c10567..68b9ba8 100644
--- a/PSync/detail/util.hpp
+++ b/PSync/detail/util.hpp
@@ -21,8 +21,8 @@
* https://github.com/aappleby/smhasher/blob/master/src/murmurHash3.cpp
*/
-#ifndef PSYNC_UTIL_HPP
-#define PSYNC_UTIL_HPP
+#ifndef PSYNC_DETAIL_UTIL_HPP
+#define PSYNC_DETAIL_UTIL_HPP
#include "PSync/detail/config.hpp"
@@ -84,4 +84,4 @@
} // namespace psync
-#endif // PSYNC_UTIL_HPP
+#endif // PSYNC_DETAIL_UTIL_HPP
diff --git a/PSync/producer-base.cpp b/PSync/producer-base.cpp
index d33e6d8..4c2204d 100644
--- a/PSync/producer-base.cpp
+++ b/PSync/producer-base.cpp
@@ -19,12 +19,14 @@
#include "PSync/producer-base.hpp"
+#include <ndn-cxx/util/exception.hpp>
#include <ndn-cxx/util/logger.hpp>
+
#include <boost/algorithm/string.hpp>
#include <cstring>
-#include <limits>
#include <functional>
+#include <limits>
namespace psync {
@@ -39,7 +41,7 @@
CompressionScheme contentCompression)
: m_iblt(expectedNumEntries, ibltCompression)
, m_expectedNumEntries(expectedNumEntries)
- , m_threshold(expectedNumEntries/2)
+ , m_threshold(expectedNumEntries / 2)
, m_face(face)
, m_scheduler(m_face.getIoService())
, m_syncPrefix(syncPrefix)
@@ -140,8 +142,8 @@
void
ProducerBase::onRegisterFailed(const ndn::Name& prefix, const std::string& msg) const
{
- NDN_LOG_ERROR("ProduerBase::onRegisterFailed " << prefix << " " << msg);
- BOOST_THROW_EXCEPTION(Error(msg));
+ NDN_LOG_ERROR("ProducerBase::onRegisterFailed(" << prefix << "): " << msg);
+ NDN_THROW(Error(msg));
}
-} // namespace psync
\ No newline at end of file
+} // namespace psync
diff --git a/examples/README.md b/examples/README.md
index bdce503..64f34a7 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,24 +1,25 @@
-PSync examples
-==============
+# PSync examples
-By default, examples in `examples/` folder are not built. To enable them, use
+By default, the examples in this folder are not built. To enable them, use the
`--with-examples` configure option. For example:
- ./waf configure --with-examples
- ./waf
+```bash
+./waf configure --with-examples
+./waf
+```
-Example binary can be found under `build/examples`:
+The example binaries can be found in `build/examples`:
-- Full sync : `psync-full-sync`
-- Partial sync : `psync-producer` and `psync-consumer`
+- Full sync: `psync-full-sync`
+- Partial sync: `psync-producer` and `psync-consumer`
If the library is installed to the system using `./waf install` then the examples
are also installed and can be executed directly.
-## Partial Sync Example
+## Partial Sync example
Partial sync example of PSync has two parts: producer and consumer.
-These can be run on a machine after starting NFD:
+These can be run on a machine after starting NFD.
### Producer
@@ -28,7 +29,8 @@
export NDN_LOG=examples.PartialSyncProducerApp=INFO
```
-- Start the producer that will listen on /sync and publish 1 update for /a-0 ... /a-9 each.
+- Start the producer that will listen on `/sync` and publish 1 update for
+`/a-0` ... `/a-9` each.
```bash
psync-producer /sync /a 10 1
@@ -57,7 +59,7 @@
export NDN_LOG=examples.PartialSyncConsumerApp=INFO
```
-- Run the consumer to subscribe to 5 random prefixes from the publisher on /sync
+- Run the consumer to subscribe to 5 random prefixes from the publisher on `/sync`
```bash
psync-consumer /sync 5
@@ -79,9 +81,9 @@
1546280489.349793 INFO: [examples.PartialSyncConsumerApp] Update: /a-9/1
```
-## Full Sync Example
+## Full Sync example
-To demonstrate full sync mode of PSync, ``psync-full-sync``
+To demonstrate full sync mode of PSync, `psync-full-sync`
can be run on a machine after starting NFD:
- Enable the logs for full sync:
@@ -90,8 +92,8 @@
export NDN_LOG=examples.FullSyncApp=INFO
```
-- Run the full sync example with sync prefix /sync, user prefix /a,
-and publish three updates for each user prefix: /a-0 and /a-1. This will simulate node a.
+- Run the full sync example with sync prefix `/sync`, user prefix `/a`,
+and publish three updates for each user prefix: `/a-0` and `/a-1`. This will simulate node a.
```bash
psync-full-sync /sync /a 2 3
@@ -138,4 +140,4 @@
1546282804.033214 INFO: [examples.FullSyncApp] Publish: /b-1/3
1546282845.274680 INFO: [examples.FullSyncApp] Update /a-1/3
1546282855.101780 INFO: [examples.FullSyncApp] Publish: /b-0/3
-```
\ No newline at end of file
+```