/[debian]/mimetic/trunk/mimetic/body.h
ViewVC logotype

Diff of /mimetic/trunk/mimetic/body.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 196 by gregoa, Sat Feb 25 16:49:22 2006 UTC revision 197 by gregoa, Sun Apr 16 12:21:05 2006 UTC
# Line 2  Line 2 
2      copyright            : (C) 2002-2005 by Stefano Barbato      copyright            : (C) 2002-2005 by Stefano Barbato
3      email                : stefano@codesink.org      email                : stefano@codesink.org
4    
5      $Id: body.h,v 1.14 2005/02/23 10:26:14 tat Exp $      $Id: body.h,v 1.15 2006/03/12 12:04:36 tat Exp $
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
# Line 16  Line 16 
16  #ifndef _MIMETIC_BODY_H_  #ifndef _MIMETIC_BODY_H_
17  #define _MIMETIC_BODY_H_  #define _MIMETIC_BODY_H_
18  #include <string>  #include <string>
19    #include <math.h>
20  #include <mimetic/rfc822/body.h>  #include <mimetic/rfc822/body.h>
21  #include <mimetic/codec/code.h>  #include <mimetic/codec/code.h>
22  #include <mimetic/mimeentitylist.h>  #include <mimetic/mimeentitylist.h>
# Line 108  bool Body::load(const std::string& fqn, Line 109  bool Body::load(const std::string& fqn,
109      File in(fqn);      File in(fqn);
110      if(!in)      if(!in)
111          return false;          return false;
112    
113      File::iterator beg = in.begin(), end = in.end();      File::iterator beg = in.begin(), end = in.end();
114      Codec codec(cc);      Codec codec(cc);
115    
116        if(codec.codeSizeMultiplier() > 1.0)
117        {
118            /* increase body string size */
119            struct stat st;
120            if(::stat(fqn.c_str(), &st))
121                return false;
122            reserve((size_type)(::ceil(st.st_size * codec.codeSizeMultiplier())));
123        }
124    
125      mimetic::code(beg, end, codec, back_inserter(*this) );      mimetic::code(beg, end, codec, back_inserter(*this) );
126      return true;      return true;
127  }  }
# Line 121  bool Body::code(const Codec& cc) Line 133  bool Body::code(const Codec& cc)
133      // OPTIMIZE      // OPTIMIZE
134      std::string coded;      std::string coded;
135      Codec codec(cc);      Codec codec(cc);
136    
137        if(codec.codeSizeMultiplier() > 1.0)
138            coded.reserve((size_type)::ceil(size() * codec.codeSizeMultiplier()));
139    
140      mimetic::code(begin(), end(), cc, back_inserter(coded) );      mimetic::code(begin(), end(), cc, back_inserter(coded) );
141      this->assign(coded);      this->assign(coded);
142      return true;      return true;

Legend:
Removed from v.196  
changed lines
  Added in v.197

  ViewVC Help
Powered by ViewVC 1.1.26