xml.h
changeset 7 f227a74db59d
parent 1 67188bd752db
     1.1 --- a/xml.h	Wed Aug 13 17:24:25 2008 +0100
     1.2 +++ b/xml.h	Fri Oct 10 13:36:20 2008 +0100
     1.3 @@ -25,6 +25,7 @@
     1.4  #include <list>
     1.5  #include <map>
     1.6  #include <lemon/error.h>
     1.7 +#include <lemon/assert.h>
     1.8  #include <lemon/dim2.h>
     1.9  
    1.10  namespace lemon {
    1.11 @@ -74,7 +75,7 @@
    1.12        if(write())
    1.13  	if(level>=0) indent(level);
    1.14  	else level=0;
    1.15 -      else throw LogicError();	
    1.16 +      else LEMON_ASSERT(true, "Invalid indentation.");	
    1.17      }
    1.18    
    1.19      ///Read/write a tag
    1.20 @@ -159,7 +160,7 @@
    1.21  
    1.22      void skipWhiteSpaces()
    1.23      {
    1.24 -      if(write()) throw LogicError();
    1.25 +      if(write()) LEMON_ASSERT(true, "Can't skip whitespaces in write mode.");
    1.26        {
    1.27  	char c;
    1.28  	while (is.get(c) && std::isspace(c,is.getloc()))
    1.29 @@ -180,7 +181,7 @@
    1.30      ///
    1.31      void useTag(const std::string &_tag) {
    1.32        if(nextTag()==_tag) useTag();
    1.33 -      else throw DataFormatError("",line_number,"Unexpected token name");
    1.34 +      else throw FormatError("Unexpected token name","",line_number);
    1.35      }
    1.36    public:
    1.37      ///Return the next tag (if a tag follows on the stream).
    1.38 @@ -189,16 +190,16 @@
    1.39      ///
    1.40      const std::string &nextTag() 
    1.41      {
    1.42 -      if(write()) throw LogicError();
    1.43 +      if(write()) LEMON_ASSERT(true,"Don't use nextTag() in write mode");
    1.44        else if(next_tag.empty()) {
    1.45  	char c;
    1.46  	skipWhiteSpaces();
    1.47  	if(!is.get(c) || c!='<')
    1.48 -	  throw DataFormatError("",line_number,"Bad format");
    1.49 +	  throw FormatError("Bad format","",line_number);
    1.50  	next_tag.clear();
    1.51  	while (is.get(c) && c!='>') next_tag.push_back(c);
    1.52  	if(c!='>')
    1.53 -	  throw DataFormatError("",line_number,"Bad format");
    1.54 +	  throw FormatError("Bad format","",line_number);
    1.55        }
    1.56        return next_tag;
    1.57      }
    1.58 @@ -229,7 +230,7 @@
    1.59        else {
    1.60  	skipWhiteSpaces();
    1.61  	if(!(is >> const_cast<int &>(v))) 
    1.62 -	  throw DataFormatError("",line_number,"Not an 'int'");
    1.63 +	  throw FormatError("Not an 'int'","",line_number);
    1.64        }
    1.65        return *this;
    1.66      }
    1.67 @@ -239,7 +240,7 @@
    1.68        else {
    1.69  	skipWhiteSpaces();
    1.70  	if(!(is >> const_cast<double &>(v))) 
    1.71 -	  throw DataFormatError("",line_number,"Not an 'double'");
    1.72 +	  throw FormatError("Not an 'double'","",line_number);
    1.73        }
    1.74        return *this;
    1.75      }
    1.76 @@ -271,7 +272,7 @@
    1.77  	while (is.get(c) && c!='<')
    1.78  	  if(c=='\\')
    1.79  	    if(!is.get(c))
    1.80 -	      throw DataFormatError("",line_number,"Bad string");
    1.81 +	      throw FormatError("Bad string","",line_number);
    1.82  	    else switch(c) {
    1.83  	    case 'n':
    1.84  	      w.push_back('\n');
    1.85 @@ -285,7 +286,7 @@
    1.86  	    w.push_back(c);
    1.87  	  }
    1.88  	if(c!='<')
    1.89 -	  throw DataFormatError("",line_number,"Unexpected eof");
    1.90 +	  throw FormatError("Unexpected eof","",line_number);
    1.91  	is.unget();
    1.92        }
    1.93        return *this;
    1.94 @@ -425,7 +426,7 @@
    1.95    ///\relates XmlIo
    1.96    ///
    1.97    template<class T>
    1.98 -  void xml(XmlIo &x,lemon::dim2::BoundingBox<T> &v)
    1.99 +  void xml(XmlIo &x,lemon::dim2::Box<T> &v)
   1.100    {
   1.101      if(x.write()) {
   1.102        if(!v.empty()) {