Index: src/Parameters/StreamOperators.hpp
===================================================================
--- src/Parameters/StreamOperators.hpp	(revision 7b1a19958addd1d541b206cfb12e53e5af25165e)
+++ src/Parameters/StreamOperators.hpp	(revision 16876ca6994e6cfaa920af04bed6a9c17e390f42)
@@ -3,12 +3,9 @@
  *
  *  Created on: Apr 16, 2012
- *      Author: ankele
+ *      Author: ankele, heber
  */
 
 #ifndef STREAMOPERATORS_HPP_
 #define STREAMOPERATORS_HPP_
-
-
-
 
 // include config.h
@@ -17,5 +14,7 @@
 #endif
 
+#include <boost/tokenizer.hpp>
 #include <string>
+#include <sstream>
 #include <iosfwd>
 
@@ -23,18 +22,22 @@
 #include "LinearAlgebra/RealSpaceMatrix.hpp"
 #include "Box.hpp"
-#include "Element/element.hpp"
-#include "molecule.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/MoleculeIdDescriptor.hpp"
+#include "Element/periodentafel.hpp"
+#include "World.hpp"
 
 #include "CodePatterns/Assert.hpp"
 
-class Vector;
-class Box;
-class RealSpaceMatrix;
+class atom;
+class element;
 class molecule;
-class element;
-
-inline std::istream& operator>>(std::istream& ist, Vector& m)
-{
-
+
+/** Returns a single line from \a ist without leading and ending brackets.
+ *
+ * @param ist stream to get line from
+ * @return line as string without ()
+ */
+inline std::string getLine(std::istream& ist)
+{
   std::string line;
   getline(ist,line);
@@ -44,28 +47,25 @@
   if (!line.empty() && line[line.size() - 1] == ')')
     line.erase(line.size() - 1, 1);
-  Vector temp_vector;
-
-  // dissect by ","
-  double coord = 0.;
-  int counter = 0;
-  std::string::iterator olditer = line.begin();
-  for(std::string::iterator iter = line.begin(); (iter != line.end()) && (counter != 3); ++iter) {
-    if ((*iter == ',') || (*iter == ' ')) {
-      std::istringstream stream(std::string(olditer, iter));
-
-      stream >> coord;
-
-      temp_vector[counter++] = coord;
-
-      olditer = iter + 1;
-    }
-  }
-  if ((olditer != line.begin()) && (counter != 3)) { // insert last part also
-
-    std::istringstream stream(std::string(olditer, line.end()));
-    stream >> coord;
-    temp_vector[counter++] = coord;
-  }
-  m = temp_vector;
+
+  return line;
+}
+
+inline std::istream& operator>>(std::istream& ist, Vector& m)
+{
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  ConvertTo<double> converter;
+  std::vector<double> temp_vector;
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter)
+    temp_vector.push_back(converter(*iter));
+  ASSERT (temp_vector.size() == (size_t)NDIM,
+      "operator>>(std::istream& ist, Vector& m) - not "+toString((size_t)NDIM)+" but "
+      +toString(temp_vector.size())+" components given.");
+  for (size_t i=0;i<NDIM;++i)
+    m[i] = temp_vector[i];
   return ist;
 };
@@ -73,44 +73,26 @@
 inline std::istream& operator>>(std::istream& ist, RealSpaceMatrix& m)
 {
-
-  std::string line;
-  getline(ist,line);
-
-  if (!line.empty() && line[0] == '(')
-    line.erase(0, 1);
-  if (!line.empty() && line[line.size() - 1] == ')')
-    line.erase(line.size() - 1, 1);
-  double temp[6];
-
-  // dissect by ","
-  double coord = 0.;
-  int counter = 0;
-  std::string::iterator olditer = line.begin();
-  for(std::string::iterator iter = line.begin(); (iter != line.end()) && (counter != 6); ++iter) {
-    if ((*iter == ',') || (*iter == ' ')) {
-      std::istringstream stream(std::string(olditer, iter));
-
-      stream >> coord;
-
-      temp[counter++] = coord;
-
-      olditer = iter + 1;
-    }
-  }
-  if ((olditer != line.begin()) && (counter != 6)) { // insert last part also
-
-    std::istringstream stream(std::string(olditer, line.end()));
-    stream >> coord;
-    temp[counter++] = coord;
-  }
-  m.set(0,0, temp[0]);
-  m.set(0,1, temp[1]);
-  m.set(0,2, temp[2]);
-  m.set(1,0, temp[1]);
-  m.set(1,1, temp[3]);
-  m.set(1,2, temp[4]);
-  m.set(2,0, temp[2]);
-  m.set(2,1, temp[4]);
-  m.set(2,2, temp[5]);
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  ConvertTo<double> converter;
+  std::vector<double> temp_vector;
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter)
+    temp_vector.push_back(converter(*iter));
+  ASSERT (temp_vector.size() == (size_t)NDIM*(NDIM+1)/2,
+      "operator>>(std::istream& ist, RealSpaceMatrix& m) - not "+toString((size_t)NDIM*((size_t)NDIM+1)/2)+" but "
+      +toString(temp_vector.size())+" components given.");
+  m.set(0,0, temp_vector[0]);
+  m.set(0,1, temp_vector[1]);
+  m.set(0,2, temp_vector[2]);
+  m.set(1,0, temp_vector[1]);
+  m.set(1,1, temp_vector[3]);
+  m.set(1,2, temp_vector[4]);
+  m.set(2,0, temp_vector[2]);
+  m.set(2,1, temp_vector[4]);
+  m.set(2,2, temp_vector[5]);
   return ist;
 };
@@ -125,8 +107,29 @@
 
 
+inline std::istream& operator>>(std::istream& ist, const atom* & m)
+{
+  std::string line = getLine(ist);
+
+  ConvertTo<unsigned int> converter;
+  const atomId_t temp_value = converter(line);
+  const atom *a = World::getInstance().getAtom(AtomById(temp_value));
+  ASSERT( a != NULL,
+      "operator>>(std::istream& ist, const atom* & m) - atom molecule id "
+      +toString(temp_value)+".");
+  m = a;
+  return ist;
+}
+
 inline std::istream& operator>>(std::istream& ist, const molecule* & m)
 {
-  std::cout << "===============   operator >> (istream, const element *) not implemented!\n";
-  ASSERT(0, "operator >> (istream, const element *) not implemented!");
+  std::string line = getLine(ist);
+
+  ConvertTo<unsigned int> converter;
+  const moleculeId_t temp_value = converter(line);
+  const molecule *mol = World::getInstance().getMolecule(MoleculeById(temp_value));
+  ASSERT( mol != NULL,
+      "operator>>(std::istream& ist, const molecule* & m) - invalid molecule id "
+      +toString(temp_value)+".");
+  m = mol;
   return ist;
 }
@@ -135,6 +138,13 @@
 inline std::istream& operator>>(std::istream& ist, const element* & m)
 {
-  std::cout << "===============   operator >> (istream, const element *) not implemented!\n";
-  ASSERT(0, "operator >> (istream, const element *) not implemented!");
+  std::string line = getLine(ist);
+
+  ConvertTo<unsigned int> converter;
+  const atomicNumber_t temp_value = converter(line);
+  const element *elem = World::getInstance().getPeriode()->FindElement(temp_value);
+  ASSERT( elem != NULL,
+      "operator>>(std::istream& ist, const element* & m) - invalid atomic number "
+      +toString(temp_value)+".");
+  m = elem;
   return ist;
 }
@@ -143,14 +153,60 @@
 inline std::istream& operator>>(std::istream& ist, std::vector<const molecule*> & m)
 {
-  std::cout << "===============   operator >> (istream, std::vector<const element *>) not implemented!\n";
-  ASSERT(0, "operator >> (istream, std::vector<const element *>) not implemented!");
-  return ist;
-}
-
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  ConvertTo<unsigned int> converter;
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter) {
+    const moleculeId_t temp_value = converter(*iter);
+    const molecule *mol = World::getInstance().getMolecule(MoleculeById(temp_value));
+    ASSERT( mol != NULL,
+        "operator>>(std::istream& ist, std::vector<const molecule*> & m) - invalid molecule id "
+        +toString(temp_value)+".");
+    m.push_back(mol);
+  }
+  return ist;
+}
+
+
+inline std::istream& operator>>(std::istream& ist, std::vector<const atom*> & m)
+{
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  ConvertTo<unsigned int> converter;
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter) {
+    const atomId_t temp_value = converter(line);
+    const atom *a = World::getInstance().getAtom(AtomById(temp_value));
+    ASSERT( a != NULL,
+        "operator>>(std::istream& ist, std::vector<const atom*> & m) - invalid atom id "
+        +toString(temp_value)+".");
+    m.push_back(a);
+  }
+  return ist;
+}
 
 inline std::istream& operator>>(std::istream& ist, std::vector<const element*> & m)
 {
-  std::cout << "===============   operator >> (istream, std::vector<const element *>) not implemented!\n";
-  ASSERT(0, "operator >> (istream, std::vector<const element *>) not implemented!");
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  ConvertTo<unsigned int> converter;
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter) {
+    const atomicNumber_t temp_value = converter(*iter);
+    const element *elem = World::getInstance().getPeriode()->FindElement(temp_value);
+    ASSERT( elem != NULL,
+        "operator>>(std::istream& ist, std::vector<const element*> & m) - invalid atomic number "
+        +toString(temp_value)+".");
+    m.push_back(elem);
+  }
   return ist;
 }
@@ -159,6 +215,26 @@
 inline std::istream& operator>>(std::istream& ist, std::vector<std::string> & m)
 {
-  std::cout << "===============   operator >> (istream, std::vector<std::string>) not implemented!\n";
-  ASSERT(0, "operator >> (istream, std::vector<std::string>) not implemented!");
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter)
+    m.push_back(*iter);
+  return ist;
+}
+
+inline std::istream& operator>>(std::istream& ist, std::vector<unsigned int> & m)
+{
+  std::string line = getLine(ist);
+
+  // dissect by " " or ","
+  boost::char_separator<char> sep(", ");
+  boost::tokenizer<boost::char_separator<char> > tok(line, sep);
+  ConvertTo<unsigned int> converter;
+  for(boost::tokenizer<boost::char_separator<char> >::const_iterator iter = tok.begin();
+      iter != tok.end(); ++iter)
+    m.push_back(converter(*iter));
   return ist;
 }
