io_helper.cc
changeset 1 67188bd752db
child 7 f227a74db59d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/io_helper.cc	Mon Jul 07 08:10:39 2008 -0500
     1.3 @@ -0,0 +1,34 @@
     1.4 +#include "io_helper.h"
     1.5 +
     1.6 +namespace lemon {
     1.7 +  void xml(XmlIo &x, MapValue::Type& v)
     1.8 +  {
     1.9 +    if(x.write()) {
    1.10 +      switch (v)
    1.11 +      {
    1.12 +        case MapValue::NUMERIC:
    1.13 +          { x("type", std::string("numeric")); }
    1.14 +          break;
    1.15 +        case MapValue::STRING:
    1.16 +          { x("type", std::string("string")); }
    1.17 +          break;
    1.18 +      }
    1.19 +    }
    1.20 +    else {
    1.21 +      std::string type;
    1.22 +      { x("type", type); }
    1.23 +      if (type == "numeric")
    1.24 +      {
    1.25 +        v = MapValue::NUMERIC;
    1.26 +      }
    1.27 +      else if (type == "string")
    1.28 +      {
    1.29 +        v = MapValue::STRING;
    1.30 +      }
    1.31 +      else
    1.32 +      {
    1.33 +        throw DataFormatError("Bad format");
    1.34 +      }
    1.35 +    }
    1.36 +  }
    1.37 +};