COIN-OR::LEMON - Graph Library

Changeset 1157:3996d2098090 in lemon-0.x


Ignore:
Timestamp:
02/19/05 22:11:20 (15 years ago)
Author:
Mihaly Barasz
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1558
Message:

lemon/error.h: boost::shared_ptr helyett std::auto_ptr

(Sokkal kenylemetlenebb, es nem teljesen biztos, hogy helyes megoldas)

Location:
src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/error.h

    r1151 r1157  
    11/* -*- C++ -*-
     2 *
    23 * src/lemon/error.h - Part of LEMON, a generic C++ optimization library
    34 *
    4  * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    5  * (Egervary Combinatorial Optimization Research Group, EGRES).
     5 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi
     6 * Kutatocsoport (Egervary Combinatorial Optimization Research Group,
     7 * EGRES).
    68 *
    79 * Permission to use, modify and distribute this software is granted
     
    2729#include <iostream>
    2830#include <cstdlib>
    29 
    30 #include <boost/shared_ptr.hpp>
     31#include <memory>
    3132
    3233namespace lemon {
     
    4344  protected:
    4445    ///\e
    45     boost::shared_ptr<std::ostringstream> buf;
     46    ///\todo The good solution is boost:shared_ptr...
     47    mutable
     48    std::auto_ptr<std::ostringstream> buf;
    4649   
    4750    ///\e
     
    5356        buf.reset();
    5457      }
    55       return buf;
     58      return buf.get();
    5659    }
    5760
     
    6063    ///\e
    6164    ErrorMessage() throw() { init(); }
     65
     66    ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { }
    6267
    6368    ///\e
     
    7681    template <typename T>
    7782    ErrorMessage& operator<<(const T &t) throw() {
    78       if( !buf ) return *this;
     83      if( ! buf.get() ) return *this;
    7984
    8085      try {
     
    8893    ///\e
    8994    const char* message() throw() {
    90       if( !buf ) return 0;
     95      if( ! buf.get() ) return 0;
    9196
    9297      const char* mes = 0;
     
    188193    const char *_message;
    189194    int _line;
    190     boost::shared_ptr<std::string> _file;
    191 
    192   public:
     195
     196    ///\todo Much better solution is boost::shared_ptr
     197    mutable
     198    std::auto_ptr<std::string> _file;
     199
     200  public:
     201
     202    DataFormatError(const DataFormatError &dfe) :
     203      IOError(dfe), _message(dfe._message), _line(dfe._line),
     204      _file(dfe._file) {}
     205
    193206    ///\e
    194207    explicit DataFormatError(const char *the_message)
     
    223236    /// Returns \e "(unknown)" if the filename was not specified.
    224237    const char* file() const {
    225       if( _file )
     238      if( _file.get() )
    226239        return _file->c_str();
    227240      else
     
    235248        std::ostringstream ostr;
    236249        ostr << _message;
    237         if( _file || _line ) {
     250        if( _file.get() || _line ) {
    238251          ostr << " (";
    239           if( _file ) ostr << "in file '" << *_file << "'";
    240           if( _file && _line ) ostr << " ";
     252          if( _file.get() ) ostr << "in file '" << *_file << "'";
     253          if( _file.get() && _line ) ostr << " ";
    241254          if( _line ) ostr << "at line " << _line;
    242255          ostr << ")";
Note: See TracChangeset for help on using the changeset viewer.