lemon/lgf_reader.h
changeset 1067 54464584b157
parent 517 afd134142111
child 1068 e8afd887d706
child 1069 b1b534ddb539
child 1070 c8c8801db0a4
equal deleted inserted replaced
36:46f2d261df48 45:815081e88de9
     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-2008
     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
   961         std::map<std::string, int> maps;
   961         std::map<std::string, int> maps;
   962 
   962 
   963         std::string map;
   963         std::string map;
   964         int index = 0;
   964         int index = 0;
   965         while (_reader_bits::readToken(line, map)) {
   965         while (_reader_bits::readToken(line, map)) {
       
   966           if(map == "-") {
       
   967               if(index!=0)
       
   968                 throw FormatError("'-' is not allowed as a map name");
       
   969               else if (line >> std::ws >> c)
       
   970                 throw FormatError("Extra character at the end of line");
       
   971               else break;
       
   972             }
   966           if (maps.find(map) != maps.end()) {
   973           if (maps.find(map) != maps.end()) {
   967             std::ostringstream msg;
   974             std::ostringstream msg;
   968             msg << "Multiple occurence of arc map: " << map;
   975             msg << "Multiple occurence of arc map: " << map;
   969             throw FormatError(msg.str());
   976             throw FormatError(msg.str());
   970           }
   977           }
  1801         std::map<std::string, int> maps;
  1808         std::map<std::string, int> maps;
  1802 
  1809 
  1803         std::string map;
  1810         std::string map;
  1804         int index = 0;
  1811         int index = 0;
  1805         while (_reader_bits::readToken(line, map)) {
  1812         while (_reader_bits::readToken(line, map)) {
       
  1813           if(map == "-") {
       
  1814               if(index!=0)
       
  1815                 throw FormatError("'-' is not allowed as a map name");
       
  1816               else if (line >> std::ws >> c)
       
  1817                 throw FormatError("Extra character at the end of line");
       
  1818               else break;
       
  1819             }
  1806           if (maps.find(map) != maps.end()) {
  1820           if (maps.find(map) != maps.end()) {
  1807             std::ostringstream msg;
  1821             std::ostringstream msg;
  1808             msg << "Multiple occurence of edge map: " << map;
  1822             msg << "Multiple occurence of edge map: " << map;
  1809             throw FormatError(msg.str());
  1823             throw FormatError(msg.str());
  1810           }
  1824           }