Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53427 - in trunk: boost/iostreams/filter libs/iostreams/build libs/iostreams/src
From: ghost_at_[hidden]
Date: 2009-05-30 02:16:28


Author: vladimir_prus
Date: 2009-05-30 02:16:27 EDT (Sat, 30 May 2009)
New Revision: 53427
URL: http://svn.boost.org/trac/boost/changeset/53427

Log:
Avoid non-inline non-template functions in headers.

This fixes #2406. gzip.hpp had a few functions
that are not templates or inline, which caused link errors.
Since the functions are fairly big, this patch moves
them into a cpp file.

Added:
   trunk/libs/iostreams/src/gzip.cpp (contents, props changed)
Text files modified:
   trunk/boost/iostreams/filter/gzip.hpp | 155 ---------------------------------------
   trunk/libs/iostreams/build/Jamfile.v2 | 2
   2 files changed, 3 insertions(+), 154 deletions(-)

Modified: trunk/boost/iostreams/filter/gzip.hpp
==============================================================================
--- trunk/boost/iostreams/filter/gzip.hpp (original)
+++ trunk/boost/iostreams/filter/gzip.hpp 2009-05-30 02:16:27 EDT (Sat, 30 May 2009)
@@ -313,7 +313,7 @@
 namespace detail {
 
 // Processes gzip headers
-class gzip_header {
+class BOOST_IOSTREAMS_DECL gzip_header {
 public:
     gzip_header() { reset(); }
 
@@ -355,7 +355,7 @@
 };
 
 // Processes gzip footers
-class gzip_footer {
+class BOOST_IOSTREAMS_DECL gzip_footer {
 public:
     gzip_footer() { reset(); }
     
@@ -659,157 +659,6 @@
     return amt;
 }
 
-//------------------Implementation of gzip_header-----------------------------//
-
-namespace detail {
-
-void gzip_header::process(char c)
-{
- uint8_t value = static_cast<uint8_t>(c);
- switch (state_) {
- case s_id1:
- if (value != gzip::magic::id1)
- throw gzip_error(gzip::bad_header);
- state_ = s_id2;
- break;
- case s_id2:
- if (value != gzip::magic::id2)
- throw gzip_error(gzip::bad_header);
- state_ = s_cm;
- break;
- case s_cm:
- if (value != gzip::method::deflate)
- throw gzip_error(gzip::bad_method);
- state_ = s_flg;
- break;
- case s_flg:
- flags_ = value;
- state_ = s_mtime;
- break;
- case s_mtime:
- mtime_ += value << (offset_ * 8);
- if (offset_ == 3) {
- state_ = s_xfl;
- offset_ = 0;
- } else {
- ++offset_;
- }
- break;
- case s_xfl:
- state_ = s_os;
- break;
- case s_os:
- os_ = value;
- if (flags_ & gzip::flags::extra) {
- state_ = s_extra;
- } else if (flags_ & gzip::flags::name) {
- state_ = s_name;
- } else if (flags_ & gzip::flags::comment) {
- state_ = s_comment;
- } else if (flags_ & gzip::flags::header_crc) {
- state_ = s_hcrc;
- } else {
- state_ = s_done;
- }
- break;
- case s_xlen:
- xlen_ += value << (offset_ * 8);
- if (offset_ == 1) {
- state_ = s_extra;
- offset_ = 0;
- } else {
- ++offset_;
- }
- break;
- case s_extra:
- if (--xlen_ == 0) {
- if (flags_ & gzip::flags::name) {
- state_ = s_name;
- } else if (flags_ & gzip::flags::comment) {
- state_ = s_comment;
- } else if (flags_ & gzip::flags::header_crc) {
- state_ = s_hcrc;
- } else {
- state_ = s_done;
- }
- }
- break;
- case s_name:
- if (c != 0) {
- file_name_ += c;
- } else if (flags_ & gzip::flags::comment) {
- state_ = s_comment;
- } else if (flags_ & gzip::flags::header_crc) {
- state_ = s_hcrc;
- } else {
- state_ = s_done;
- }
- break;
- case s_comment:
- if (c != 0) {
- comment_ += c;
- } else if (flags_ & gzip::flags::header_crc) {
- state_ = s_hcrc;
- } else {
- state_ = s_done;
- }
- break;
- case s_hcrc:
- if (offset_ == 1) {
- state_ = s_done;
- offset_ = 0;
- } else {
- ++offset_;
- }
- break;
- default:
- assert(0);
- }
-}
-
-void gzip_header::reset()
-{
- file_name_.clear();
- comment_.clear();
- os_ = flags_ = offset_ = xlen_ = 0;
- mtime_ = 0;
- state_ = s_id1;
-}
-
-//------------------Implementation of gzip_footer-----------------------------//
-
-void gzip_footer::process(char c)
-{
- uint8_t value = static_cast<uint8_t>(c);
- if (state_ == s_crc) {
- crc_ += value << (offset_ * 8);
- if (offset_ == 3) {
- state_ = s_isize;
- offset_ = 0;
- } else {
- ++offset_;
- }
- } else if (state_ == s_isize) {
- isize_ += value << (offset_ * 8);
- if (offset_ == 3) {
- state_ = s_done;
- offset_ = 0;
- } else {
- ++offset_;
- }
- } else {
- assert(0);
- }
-}
-
-void gzip_footer::reset()
-{
- crc_ = isize_ = offset_ = 0;
- state_ = s_crc;
-}
-
-} // End namespace boost::iostreams::detail.
-
 //------------------Implementation of gzip_decompressor-----------------------//
 
 template<typename Alloc>

Modified: trunk/libs/iostreams/build/Jamfile.v2
==============================================================================
--- trunk/libs/iostreams/build/Jamfile.v2 (original)
+++ trunk/libs/iostreams/build/Jamfile.v2 2009-05-30 02:16:27 EDT (Sat, 30 May 2009)
@@ -138,7 +138,7 @@
 
 if $(z)
 {
- sources += boost_zlib zlib.cpp ;
+ sources += boost_zlib zlib.cpp gzip.cpp ;
 }
 
 local bz2 = [ create-library bzip2 : libbz2 bz2 :

Added: trunk/libs/iostreams/src/gzip.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/iostreams/src/gzip.cpp 2009-05-30 02:16:27 EDT (Sat, 30 May 2009)
@@ -0,0 +1,173 @@
+// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
+// (C) Copyright 2003-2007 Jonathan Turkanis
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
+
+// See http://www.boost.org/libs/iostreams for documentation.
+
+// To configure Boost to work with libbz2, see the
+// installation instructions here:
+// http://boost.org/libs/iostreams/doc/index.html?path=7
+
+// Define BOOST_IOSTREAMS_SOURCE so that <boost/iostreams/detail/config.hpp>
+// knows that we are building the library (possibly exporting code), rather
+// than using it (possibly importing code).
+#define BOOST_IOSTREAMS_SOURCE
+
+#include <boost/iostreams/detail/config/dyn_link.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+
+namespace boost { namespace iostreams {
+
+//------------------Implementation of gzip_header-----------------------------//
+
+namespace detail {
+
+void gzip_header::process(char c)
+{
+ uint8_t value = static_cast<uint8_t>(c);
+ switch (state_) {
+ case s_id1:
+ if (value != gzip::magic::id1)
+ throw gzip_error(gzip::bad_header);
+ state_ = s_id2;
+ break;
+ case s_id2:
+ if (value != gzip::magic::id2)
+ throw gzip_error(gzip::bad_header);
+ state_ = s_cm;
+ break;
+ case s_cm:
+ if (value != gzip::method::deflate)
+ throw gzip_error(gzip::bad_method);
+ state_ = s_flg;
+ break;
+ case s_flg:
+ flags_ = value;
+ state_ = s_mtime;
+ break;
+ case s_mtime:
+ mtime_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_xfl;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ case s_xfl:
+ state_ = s_os;
+ break;
+ case s_os:
+ os_ = value;
+ if (flags_ & gzip::flags::extra) {
+ state_ = s_extra;
+ } else if (flags_ & gzip::flags::name) {
+ state_ = s_name;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_xlen:
+ xlen_ += value << (offset_ * 8);
+ if (offset_ == 1) {
+ state_ = s_extra;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ case s_extra:
+ if (--xlen_ == 0) {
+ if (flags_ & gzip::flags::name) {
+ state_ = s_name;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ }
+ break;
+ case s_name:
+ if (c != 0) {
+ file_name_ += c;
+ } else if (flags_ & gzip::flags::comment) {
+ state_ = s_comment;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_comment:
+ if (c != 0) {
+ comment_ += c;
+ } else if (flags_ & gzip::flags::header_crc) {
+ state_ = s_hcrc;
+ } else {
+ state_ = s_done;
+ }
+ break;
+ case s_hcrc:
+ if (offset_ == 1) {
+ state_ = s_done;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ break;
+ default:
+ assert(0);
+ }
+}
+
+void gzip_header::reset()
+{
+ file_name_.clear();
+ comment_.clear();
+ os_ = flags_ = offset_ = xlen_ = 0;
+ mtime_ = 0;
+ state_ = s_id1;
+}
+
+//------------------Implementation of gzip_footer-----------------------------//
+
+void gzip_footer::process(char c)
+{
+ uint8_t value = static_cast<uint8_t>(c);
+ if (state_ == s_crc) {
+ crc_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_isize;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ } else if (state_ == s_isize) {
+ isize_ += value << (offset_ * 8);
+ if (offset_ == 3) {
+ state_ = s_done;
+ offset_ = 0;
+ } else {
+ ++offset_;
+ }
+ } else {
+ assert(0);
+ }
+}
+
+void gzip_footer::reset()
+{
+ crc_ = isize_ = offset_ = 0;
+ state_ = s_crc;
+}
+
+} // End namespace boost::iostreams::detail.
+
+} } // End namespaces iostreams, boost.


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk