lemon/lgf_reader.h
branch1.0
changeset 426 8276e0ee48b1
parent 376 d3524090d5e2
parent 422 54464584b157
child 427 c59bdcc8e33e
equal deleted inserted replaced
36:54724ef48a42 38:9d3088ff2df1
     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
   963         std::map<std::string, int> maps;
   963         std::map<std::string, int> maps;
   964 
   964 
   965         std::string map;
   965         std::string map;
   966         int index = 0;
   966         int index = 0;
   967         while (_reader_bits::readToken(line, map)) {
   967         while (_reader_bits::readToken(line, map)) {
       
   968           if(map == "-") {
       
   969               if(index!=0)
       
   970                 throw FormatError("'-' is not allowed as a map name");
       
   971               else if (line >> std::ws >> c)
       
   972                 throw FormatError("Extra character at the end of line");
       
   973               else break;
       
   974             }
   968           if (maps.find(map) != maps.end()) {
   975           if (maps.find(map) != maps.end()) {
   969             std::ostringstream msg;
   976             std::ostringstream msg;
   970             msg << "Multiple occurence of arc map: " << map;
   977             msg << "Multiple occurence of arc map: " << map;
   971             throw FormatError(msg.str());
   978             throw FormatError(msg.str());
   972           }
   979           }
  1805         std::map<std::string, int> maps;
  1812         std::map<std::string, int> maps;
  1806 
  1813 
  1807         std::string map;
  1814         std::string map;
  1808         int index = 0;
  1815         int index = 0;
  1809         while (_reader_bits::readToken(line, map)) {
  1816         while (_reader_bits::readToken(line, map)) {
       
  1817           if(map == "-") {
       
  1818               if(index!=0)
       
  1819                 throw FormatError("'-' is not allowed as a map name");
       
  1820               else if (line >> std::ws >> c)
       
  1821                 throw FormatError("Extra character at the end of line");
       
  1822               else break;
       
  1823             }
  1810           if (maps.find(map) != maps.end()) {
  1824           if (maps.find(map) != maps.end()) {
  1811             std::ostringstream msg;
  1825             std::ostringstream msg;
  1812             msg << "Multiple occurence of edge map: " << map;
  1826             msg << "Multiple occurence of edge map: " << map;
  1813             throw FormatError(msg.str());
  1827             throw FormatError(msg.str());
  1814           }
  1828           }