io_helper.cc
changeset 6 3a44a2bb6da8
child 7 f227a74db59d
equal deleted inserted replaced
-1:000000000000 0:83d40710729e
       
     1 #include "io_helper.h"
       
     2 
       
     3 namespace lemon {
       
     4   void xml(XmlIo &x, MapValue::Type& v)
       
     5   {
       
     6     if(x.write()) {
       
     7       switch (v)
       
     8       {
       
     9         case MapValue::NUMERIC:
       
    10           { x("type", std::string("numeric")); }
       
    11           break;
       
    12         case MapValue::STRING:
       
    13           { x("type", std::string("string")); }
       
    14           break;
       
    15       }
       
    16     }
       
    17     else {
       
    18       std::string type;
       
    19       { x("type", type); }
       
    20       if (type == "numeric")
       
    21       {
       
    22         v = MapValue::NUMERIC;
       
    23       }
       
    24       else if (type == "string")
       
    25       {
       
    26         v = MapValue::STRING;
       
    27       }
       
    28       else
       
    29       {
       
    30         throw DataFormatError("Bad format");
       
    31       }
       
    32     }
       
    33   }
       
    34 };