From: g0dil Date: Thu, 20 Nov 2008 21:33:08 +0000 (+0000) Subject: Packets: Add reserve() / capacity() to PacketData interface X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=2ffca72ed06b10829071cd1b28d9047ff735f929;p=senf.git Packets: Add reserve() / capacity() to PacketData interface Utils/Daemon: Make argv() return 'char const **' git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@968 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/AnnotationRouter.hh b/PPI/AnnotationRouter.hh index a186fd5..2d331a8 100644 --- a/PPI/AnnotationRouter.hh +++ b/PPI/AnnotationRouter.hh @@ -100,7 +100,7 @@ namespace module { struct DuplicateKeyException : public senf::Exception { DuplicateKeyException(AnnotationType const & key) - : senf::Exception("Duplicate senf::ppi::module::AnnotationRouter routing key") + : senf::Exception("Duplicate senf::ppi::module::AnnotationRouter routing key ") { append(boost::lexical_cast(key)); } }; private: diff --git a/Packets/PacketData.cci b/Packets/PacketData.cci index 9ea4cef..73719c5 100644 --- a/Packets/PacketData.cci +++ b/Packets/PacketData.cci @@ -108,6 +108,17 @@ prefix_ void senf::PacketData::clear() impl().clear(this); } +prefix_ void senf::PacketData::reserve(size_type n) +{ + impl().reserve(n + size() - impl().size()); +} + +prefix_ senf::PacketData::size_type senf::PacketData::capacity() + const +{ + return impl().capacity() - (impl().size() - size()); +} + prefix_ bool senf::PacketData::valid() { return impl_; diff --git a/Packets/PacketData.hh b/Packets/PacketData.hh index 7760200..05e5aa8 100644 --- a/Packets/PacketData.hh +++ b/Packets/PacketData.hh @@ -133,6 +133,9 @@ namespace senf { void resize(size_type n, byte v=0); + void reserve(size_type n); + size_type capacity() const; + ///@} protected: diff --git a/Packets/PacketImpl.cci b/Packets/PacketImpl.cci index 1e0cad0..4bd2bf3 100644 --- a/Packets/PacketImpl.cci +++ b/Packets/PacketImpl.cci @@ -175,6 +175,17 @@ prefix_ void senf::detail::PacketImpl::erase(PacketData * self, iterator first, updateIterators(self,ix,-delta); } +prefix_ void senf::detail::PacketImpl::reserve(size_type n) +{ + data_.reserve(n); +} + +prefix_ senf::detail::PacketImpl::size_type senf::detail::PacketImpl::capacity() + const +{ + return data_.capacity(); +} + /////////////////////////////////////////////////////////////////////////// // senf::detail::PacketImpl::Guard diff --git a/Packets/PacketImpl.hh b/Packets/PacketImpl.hh index 1933949..de52e40 100644 --- a/Packets/PacketImpl.hh +++ b/Packets/PacketImpl.hh @@ -183,6 +183,9 @@ namespace detail { void erase(PacketData * self, iterator first, iterator last); void clear(PacketData * self); + void reserve(size_type n); + size_type capacity() const; + // Annotations template Annotation & annotation(); diff --git a/Utils/Daemon/Daemon.cc b/Utils/Daemon/Daemon.cc index 93bfba5..6bd84ae 100644 --- a/Utils/Daemon/Daemon.cc +++ b/Utils/Daemon/Daemon.cc @@ -89,7 +89,7 @@ prefix_ int senf::Daemon::argc() return argc_; } -prefix_ char ** senf::Daemon::argv() +prefix_ char const ** senf::Daemon::argv() { return argv_; } @@ -107,7 +107,7 @@ namespace { prefix_ void senf::Daemon::removeDaemonArgs() { - char ** last (std::remove_if(argv_+1, argv_+argc_, IsDaemonOpt())); + char const ** last (std::remove_if(argv_+1, argv_+argc_, IsDaemonOpt())); *last = 0; argc_ = last - argv_; } @@ -238,7 +238,7 @@ prefix_ void senf::Daemon::exit(unsigned code) throw DaemonExitException(code); } -prefix_ int senf::Daemon::start(int argc, char ** argv) +prefix_ int senf::Daemon::start(int argc, char const ** argv) { argc_ = argc; argv_ = argv; diff --git a/Utils/Daemon/Daemon.hh b/Utils/Daemon/Daemon.hh index 8747182..e38a62c 100644 --- a/Utils/Daemon/Daemon.hh +++ b/Utils/Daemon/Daemon.hh @@ -157,7 +157,7 @@ namespace senf { successful startup. */ int argc(); ///< Access command line parameter count - char ** argv(); ///< Access command line parameters + char const ** argv(); ///< Access command line parameters void removeDaemonArgs(); ///< Remove the daemon arguments from argc()/argv() static void exit(unsigned code=0); ///< Terminate daemon with failure @@ -168,7 +168,7 @@ namespace senf { ///\} - int start(int argc, char ** argv); ///< Called from main() to launch daemon. + int start(int argc, char const ** argv); ///< Called from main() to launch daemon. /**< Normally not called directly but from the \ref SENF_DAEMON_MAIN macro. */ @@ -211,7 +211,7 @@ namespace senf { void installSighandlers(); int argc_; - char ** argv_; + char const ** argv_; bool daemonize_; std::string stdoutLog_; @@ -234,7 +234,7 @@ namespace senf { \ingroup process */ # define SENF_DAEMON_MAIN(klass) \ - int main(int argc, char ** argv) \ + int main(int argc, char const ** argv) \ { \ klass instance; \ return instance.start(argc, argv); \ diff --git a/Utils/Daemon/Daemon.test.cc b/Utils/Daemon/Daemon.test.cc index 6d991c4..584761f 100644 --- a/Utils/Daemon/Daemon.test.cc +++ b/Utils/Daemon/Daemon.test.cc @@ -73,7 +73,7 @@ namespace { } }; - int myMain(int argc, char ** argv) + int myMain(int argc, char const ** argv) { MyDaemon instance; return instance.start(argc, argv);