lemon/lgf_reader.h
changeset 956 4dd3dc8eb5a7
parent 877 141f9c0db4a3
parent 949 54464584b157
child 966 c8fce9beb46a
equal deleted inserted replaced
43:a6b2db1aa9d6 45:b1805ea5c4ff
     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-2010
     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           }