gravatar
deba@inf.elte.hu
deba@inf.elte.hu
Improvments in map name handling - The label map is not necessary - If the item set is empty and no map is read, then the map name line can be ommited
0 1 0
default
1 file changed with 78 insertions and 34 deletions:
↑ Collapse diff ↑
Show white space 6 line context
... ...
@@ -883,5 +883,11 @@
883 883

	
884
      if (!readLine()) 
885
	throw DataFormatError("Cannot find map captions");
886
      
884
      char c;
885
      if (!readLine() || !(line >> c) || c == '@') {
886
	if (readSuccess() && line) line.putback(c);
887
	if (!_node_maps.empty()) 
888
	  throw DataFormatError("Cannot find map names");
889
	return;
890
      }
891
      line.putback(c);
892

	
887 893
      {
... ...
@@ -914,5 +920,7 @@
914 920
	  std::map<std::string, int>::iterator jt = maps.find("label");
915
	  if (jt == maps.end())
916
	    throw DataFormatError("Label map not found in file");
917
	  label_index = jt->second;
921
	  if (jt != maps.end()) {
922
	    label_index = jt->second;
923
	  } else {
924
	    label_index = -1;
925
	  }
918 926
	}
... ...
@@ -921,3 +929,2 @@
921 929

	
922
      char c;
923 930
      while (readLine() && line >> c && c != '@') {
... ...
@@ -939,4 +946,7 @@
939 946
	  n = _digraph.addNode();
940
	  _node_index.insert(std::make_pair(tokens[label_index], n));
947
	  if (label_index != -1)
948
	    _node_index.insert(std::make_pair(tokens[label_index], n));
941 949
	} else {
950
	  if (label_index == -1) 
951
	    throw DataFormatError("Label map not found in file");
942 952
	  typename std::map<std::string, Node>::iterator it =
... ...
@@ -966,4 +976,10 @@
966 976

	
967
      if (!readLine()) 
968
	throw DataFormatError("Cannot find map captions");
977
      char c;
978
      if (!readLine() || !(line >> c) || c == '@') {
979
	if (readSuccess() && line) line.putback(c);
980
	if (!_arc_maps.empty()) 
981
	  throw DataFormatError("Cannot find map names");
982
	return;
983
      }
984
      line.putback(c);
969 985
      
... ...
@@ -997,5 +1013,7 @@
997 1013
	  std::map<std::string, int>::iterator jt = maps.find("label");
998
	  if (jt == maps.end())
999
	    throw DataFormatError("Label map not found in file");
1000
	  label_index = jt->second;
1014
	  if (jt != maps.end()) {
1015
	    label_index = jt->second;
1016
	  } else {
1017
	    label_index = -1;
1018
	  }
1001 1019
	}
... ...
@@ -1004,3 +1022,2 @@
1004 1022

	
1005
      char c;
1006 1023
      while (readLine() && line >> c && c != '@') {
... ...
@@ -1015,3 +1032,3 @@
1015 1032
	if (!_reader_bits::readToken(line, target_token))
1016
	  throw DataFormatError("Source not found");
1033
	  throw DataFormatError("Target not found");
1017 1034
	
... ...
@@ -1050,4 +1067,7 @@
1050 1067
	  a = _digraph.addArc(source, target);
1051
	  _arc_index.insert(std::make_pair(tokens[label_index], a));
1068
	  if (label_index != -1) 
1069
	    _arc_index.insert(std::make_pair(tokens[label_index], a));
1052 1070
	} else {
1071
	  if (label_index == -1) 
1072
	    throw DataFormatError("Label map not found in file");
1053 1073
	  typename std::map<std::string, Arc>::iterator it =
... ...
@@ -1725,4 +1745,10 @@
1725 1745

	
1726
      if (!readLine()) 
1727
	throw DataFormatError("Cannot find map captions");
1746
      char c;
1747
      if (!readLine() || !(line >> c) || c == '@') {
1748
	if (readSuccess() && line) line.putback(c);
1749
	if (!_node_maps.empty()) 
1750
	  throw DataFormatError("Cannot find map names");
1751
	return;
1752
      }
1753
      line.putback(c);
1728 1754
      
... ...
@@ -1756,5 +1782,7 @@
1756 1782
	  std::map<std::string, int>::iterator jt = maps.find("label");
1757
	  if (jt == maps.end())
1758
	    throw DataFormatError("Label map not found in file");
1759
	  label_index = jt->second;
1783
	  if (jt != maps.end()) {
1784
	    label_index = jt->second;
1785
	  } else {
1786
	    label_index = -1;
1787
	  }
1760 1788
	}
... ...
@@ -1763,3 +1791,2 @@
1763 1791

	
1764
      char c;
1765 1792
      while (readLine() && line >> c && c != '@') {
... ...
@@ -1781,4 +1808,7 @@
1781 1808
	  n = _graph.addNode();
1782
	  _node_index.insert(std::make_pair(tokens[label_index], n));
1809
	  if (label_index != -1) 
1810
	    _node_index.insert(std::make_pair(tokens[label_index], n));
1783 1811
	} else {
1812
	  if (label_index == -1) 
1813
	    throw DataFormatError("Label map not found in file");
1784 1814
	  typename std::map<std::string, Node>::iterator it =
... ...
@@ -1808,4 +1838,10 @@
1808 1838

	
1809
      if (!readLine()) 
1810
	throw DataFormatError("Cannot find map captions");
1839
      char c;
1840
      if (!readLine() || !(line >> c) || c == '@') {
1841
	if (readSuccess() && line) line.putback(c);
1842
	if (!_edge_maps.empty()) 
1843
	  throw DataFormatError("Cannot find map names");
1844
	return;
1845
      }
1846
      line.putback(c);
1811 1847
      
... ...
@@ -1839,5 +1875,7 @@
1839 1875
	  std::map<std::string, int>::iterator jt = maps.find("label");
1840
	  if (jt == maps.end())
1841
	    throw DataFormatError("Label map not found in file");
1842
	  label_index = jt->second;
1876
	  if (jt != maps.end()) {
1877
	    label_index = jt->second;
1878
	  } else {
1879
	    label_index = -1;
1880
	  }
1843 1881
	}
... ...
@@ -1846,3 +1884,2 @@
1846 1884

	
1847
      char c;
1848 1885
      while (readLine() && line >> c && c != '@') {
... ...
@@ -1854,6 +1891,6 @@
1854 1891
	if (!_reader_bits::readToken(line, source_token))
1855
	  throw DataFormatError("Source not found");
1892
	  throw DataFormatError("Node u not found");
1856 1893

	
1857 1894
	if (!_reader_bits::readToken(line, target_token))
1858
	  throw DataFormatError("Source not found");
1895
	  throw DataFormatError("Node v not found");
1859 1896
	
... ...
@@ -1892,4 +1929,7 @@
1892 1929
	  e = _graph.addEdge(source, target);
1893
	  _edge_index.insert(std::make_pair(tokens[label_index], e));
1930
	  if (label_index != -1) 
1931
	    _edge_index.insert(std::make_pair(tokens[label_index], e));
1894 1932
	} else {
1933
	  if (label_index == -1) 
1934
	    throw DataFormatError("Label map not found in file");
1895 1935
	  typename std::map<std::string, Edge>::iterator it =
... ...
@@ -2327,4 +2367,8 @@
2327 2367
    void readMaps(std::vector<std::string>& maps) {
2328
      if (!readLine()) 
2329
	throw DataFormatError("Cannot find map captions");
2368
      char c;
2369
      if (!readLine() || !(line >> c) || c == '@') {
2370
	if (readSuccess() && line) line.putback(c);
2371
	return;
2372
      }
2373
      line.putback(c);
2330 2374
      std::string map;
0 comments (0 inline)