lemon/lgf_reader.h
branch1.1
changeset 1069 b1b534ddb539
parent 646 f63e87b9748e
parent 1067 54464584b157
child 1081 f1398882a928
child 1107 2b6bffe0e7e8
equal deleted inserted replaced
42:7e811f9a8501 47:f0ae74dddb27
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2009
     5  * Copyright (C) 2003-2011
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
   962         std::map<std::string, int> maps;
   962         std::map<std::string, int> maps;
   963 
   963 
   964         std::string map;
   964         std::string map;
   965         int index = 0;
   965         int index = 0;
   966         while (_reader_bits::readToken(line, map)) {
   966         while (_reader_bits::readToken(line, map)) {
       
   967           if(map == "-") {
       
   968               if(index!=0)
       
   969                 throw FormatError("'-' is not allowed as a map name");
       
   970               else if (line >> std::ws >> c)
       
   971                 throw FormatError("Extra character at the end of line");
       
   972               else break;
       
   973             }
   967           if (maps.find(map) != maps.end()) {
   974           if (maps.find(map) != maps.end()) {
   968             std::ostringstream msg;
   975             std::ostringstream msg;
   969             msg << "Multiple occurence of arc map: " << map;
   976             msg << "Multiple occurence of arc map: " << map;
   970             throw FormatError(msg.str());
   977             throw FormatError(msg.str());
   971           }
   978           }
  1832         std::map<std::string, int> maps;
  1839         std::map<std::string, int> maps;
  1833 
  1840 
  1834         std::string map;
  1841         std::string map;
  1835         int index = 0;
  1842         int index = 0;
  1836         while (_reader_bits::readToken(line, map)) {
  1843         while (_reader_bits::readToken(line, map)) {
       
  1844           if(map == "-") {
       
  1845               if(index!=0)
       
  1846                 throw FormatError("'-' is not allowed as a map name");
       
  1847               else if (line >> std::ws >> c)
       
  1848                 throw FormatError("Extra character at the end of line");
       
  1849               else break;
       
  1850             }
  1837           if (maps.find(map) != maps.end()) {
  1851           if (maps.find(map) != maps.end()) {
  1838             std::ostringstream msg;
  1852             std::ostringstream msg;
  1839             msg << "Multiple occurence of edge map: " << map;
  1853             msg << "Multiple occurence of edge map: " << map;
  1840             throw FormatError(msg.str());
  1854             throw FormatError(msg.str());
  1841           }
  1855           }