encoding+lp: declare constexpr and noexcept where possible
Change-Id: Icf708af0b77d62d7d8e75527aaf51c7178e47125
diff --git a/src/encoding/estimator.hpp b/src/encoding/estimator.hpp
index 364f953..11f9e39 100644
--- a/src/encoding/estimator.hpp
+++ b/src/encoding/estimator.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2015 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,7 +22,6 @@
#ifndef NDN_ENCODING_ESTIMATOR_HPP
#define NDN_ENCODING_ESTIMATOR_HPP
-#include "../common.hpp"
#include "block.hpp"
namespace ndn {
@@ -33,129 +32,118 @@
* Interface of this class (mostly) matches interface of Encoder class
* @sa Encoder
*/
-class Estimator
+class Estimator : noncopyable
{
public: // common interface between Encoder and Estimator
/**
- * @brief Create instance of the estimator
- * @param totalReserve not used (for compatibility with the Encoder)
- * @param reserveFromBack not used (for compatibility with the Encoder)
- */
- explicit
- Estimator(size_t totalReserve = 0, size_t reserveFromBack = 0);
-
- Estimator(const Estimator&) = delete;
-
- Estimator&
- operator=(const Estimator&) = delete;
-
- /**
* @brief Prepend a byte
*/
- size_t
- prependByte(uint8_t value);
+ constexpr size_t
+ prependByte(uint8_t) const noexcept
+ {
+ return 1;
+ }
/**
* @brief Append a byte
*/
- size_t
- appendByte(uint8_t value);
+ constexpr size_t
+ appendByte(uint8_t) const noexcept
+ {
+ return 1;
+ }
/**
* @brief Prepend a byte array @p array of length @p length
*/
- size_t
- prependByteArray(const uint8_t* array, size_t length);
+ constexpr size_t
+ prependByteArray(const uint8_t*, size_t length) const noexcept
+ {
+ return length;
+ }
/**
* @brief Append a byte array @p array of length @p length
*/
- size_t
- appendByteArray(const uint8_t* array, size_t length);
+ constexpr size_t
+ appendByteArray(const uint8_t*, size_t length) const noexcept
+ {
+ return length;
+ }
/**
* @brief Prepend range of bytes from the range [@p first, @p last)
*/
template<class Iterator>
size_t
- prependRange(Iterator first, Iterator last);
+ prependRange(Iterator first, Iterator last) const noexcept
+ {
+ return std::distance(first, last);
+ }
/**
* @brief Append range of bytes from the range [@p first, @p last)
*/
template<class Iterator>
size_t
- appendRange(Iterator first, Iterator last);
+ appendRange(Iterator first, Iterator last) const noexcept
+ {
+ return std::distance(first, last);
+ }
/**
* @brief Prepend VarNumber @p varNumber of NDN TLV encoding
* @sa http://named-data.net/doc/ndn-tlv/
*/
size_t
- prependVarNumber(uint64_t varNumber);
+ prependVarNumber(uint64_t varNumber) const noexcept;
/**
* @brief Prepend VarNumber @p varNumber of NDN TLV encoding
* @sa http://named-data.net/doc/ndn-tlv/
*/
size_t
- appendVarNumber(uint64_t varNumber);
+ appendVarNumber(uint64_t varNumber) const noexcept;
/**
* @brief Prepend non-negative integer @p integer of NDN TLV encoding
* @sa http://named-data.net/doc/ndn-tlv/
*/
size_t
- prependNonNegativeInteger(uint64_t integer);
+ prependNonNegativeInteger(uint64_t integer) const noexcept;
/**
* @brief Append non-negative integer @p integer of NDN TLV encoding
* @sa http://named-data.net/doc/ndn-tlv/
*/
size_t
- appendNonNegativeInteger(uint64_t integer);
+ appendNonNegativeInteger(uint64_t integer) const noexcept;
/**
* @brief Prepend TLV block of type @p type and value from buffer @p array of size @p arraySize
*/
size_t
- prependByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize);
+ prependByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize) const noexcept;
/**
* @brief Append TLV block of type @p type and value from buffer @p array of size @p arraySize
*/
size_t
- appendByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize);
+ appendByteArrayBlock(uint32_t type, const uint8_t* array, size_t arraySize) const noexcept;
/**
* @brief Prepend TLV block @p block
*/
size_t
- prependBlock(const Block& block);
+ prependBlock(const Block& block) const;
/**
* @brief Append TLV block @p block
*/
size_t
- appendBlock(const Block& block);
+ appendBlock(const Block& block) const;
};
-
-template<class Iterator>
-inline size_t
-Estimator::prependRange(Iterator first, Iterator last)
-{
- return std::distance(first, last);
-}
-
-
-template<class Iterator>
-inline size_t
-Estimator::appendRange(Iterator first, Iterator last)
-{
- return prependRange(first, last);
-}
-
} // namespace encoding
} // namespace ndn