lemon/lemon_writer.h
changeset 2084 59769591eb60
parent 2016 ecb067198349
child 2101 439b7f21ccc4
     1.1 --- a/lemon/lemon_writer.h	Mon May 15 09:46:33 2006 +0000
     1.2 +++ b/lemon/lemon_writer.h	Mon May 15 09:49:51 2006 +0000
     1.3 @@ -16,7 +16,7 @@
     1.4   *
     1.5   */
     1.6  
     1.7 -///\ingroup io_group
     1.8 +///\ingroup lemon_io
     1.9  ///\file
    1.10  ///\brief Lemon Format writer.
    1.11  
    1.12 @@ -257,7 +257,7 @@
    1.13  
    1.14    }
    1.15  
    1.16 -  /// \ingroup io_group
    1.17 +  /// \ingroup lemon_io
    1.18    /// \brief Lemon Format writer class.
    1.19    /// 
    1.20    /// The Lemon Format contains several sections. We do not want to
    1.21 @@ -310,10 +310,15 @@
    1.22        /// It gives back the header of the section.
    1.23        virtual std::string header() = 0;
    1.24  
    1.25 -      /// \brief  Writer function of the section.
    1.26 +      /// \brief Writer function of the section.
    1.27        ///
    1.28        /// Write the content of the section.
    1.29        virtual void write(std::ostream& os) = 0;
    1.30 +      
    1.31 +      /// \brief Gives back true when the section should be written.
    1.32 +      ///
    1.33 +      /// Gives back true when the section should be written.
    1.34 +      virtual bool valid() { return true; }
    1.35      };
    1.36  
    1.37      /// \brief Constructor for LemonWriter.
    1.38 @@ -355,8 +360,10 @@
    1.39      void run() {
    1.40        SectionWriters::iterator it;
    1.41        for (it = writers.begin(); it != writers.end(); ++it) {
    1.42 -	*os << (*it)->header() << std::endl;
    1.43 -	(*it)->write(*os);
    1.44 +        if ((*it)->valid()) {
    1.45 +          *os << (*it)->header() << std::endl;
    1.46 +          (*it)->write(*os);
    1.47 +        }
    1.48        }
    1.49        *os << "@end" << std::endl;
    1.50      }
    1.51 @@ -464,7 +471,7 @@
    1.52      /// Write the content of the section.
    1.53      virtual void write(std::ostream& os) {
    1.54        for (int i = 0; i < (int)writers.size(); ++i) {
    1.55 -	if (writers[i].first == "label" || (writers[i].first == "id" && labelMap == 0)) {
    1.56 +	if (writers[i].first == "label") {
    1.57  	  labelMap = writers[i].second;
    1.58  	  forceLabelMap = false;
    1.59  	  break;
    1.60 @@ -636,7 +643,7 @@
    1.61  	throw DataFormatError("Cannot find nodeset or label map");
    1.62        }
    1.63        for (int i = 0; i < (int)writers.size(); ++i) {
    1.64 -	if (writers[i].first == "label" || (writers[i].first == "id" && labelMap == 0)) {
    1.65 +	if (writers[i].first == "label") {
    1.66  	  labelMap = writers[i].second;
    1.67  	  forceLabelMap = false;
    1.68  	  break;
    1.69 @@ -1008,6 +1015,11 @@
    1.70  	os << std::endl;
    1.71        }
    1.72      }
    1.73 +
    1.74 +    /// \brief Gives back true when the section should be written.
    1.75 +    ///
    1.76 +    /// Gives back true when the section should be written.
    1.77 +    virtual bool valid() { return !writers.empty(); }
    1.78      
    1.79    private:
    1.80  
    1.81 @@ -1087,6 +1099,11 @@
    1.82  	os << std::endl;
    1.83        }
    1.84      }
    1.85 +
    1.86 +    /// \brief Gives back true when the section should be written.
    1.87 +    ///
    1.88 +    /// Gives back true when the section should be written.
    1.89 +    virtual bool valid() { return !writers.empty(); }
    1.90      
    1.91    private:
    1.92  
    1.93 @@ -1189,6 +1206,13 @@
    1.94  	os << std::endl;
    1.95        }
    1.96      }
    1.97 +
    1.98 +    /// \brief Gives back true when the section should be written.
    1.99 +    ///
   1.100 +    /// Gives back true when the section should be written.
   1.101 +    virtual bool valid() { 
   1.102 +      return !uEdgeWriters.empty() || !edgeWriters.empty(); 
   1.103 +    }
   1.104      
   1.105    private:
   1.106  
   1.107 @@ -1288,6 +1312,11 @@
   1.108        }
   1.109      }    
   1.110  
   1.111 +    /// \brief Gives back true when the section should be written.
   1.112 +    ///
   1.113 +    /// Gives back true when the section should be written.
   1.114 +    virtual bool valid() { return !writers.empty(); }
   1.115 +
   1.116    private:
   1.117      std::string name;
   1.118