io_helper.cc
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 10 Oct 2008 13:36:20 +0100
changeset 7 f227a74db59d
parent 1 67188bd752db
permissions -rw-r--r--
Update to compile with the latest LEMON (version 1.0 or [5e12d7734036])
hegyi@1
     1
#include "io_helper.h"
hegyi@1
     2
hegyi@1
     3
namespace lemon {
hegyi@1
     4
  void xml(XmlIo &x, MapValue::Type& v)
hegyi@1
     5
  {
hegyi@1
     6
    if(x.write()) {
hegyi@1
     7
      switch (v)
hegyi@1
     8
      {
hegyi@1
     9
        case MapValue::NUMERIC:
hegyi@1
    10
          { x("type", std::string("numeric")); }
hegyi@1
    11
          break;
hegyi@1
    12
        case MapValue::STRING:
hegyi@1
    13
          { x("type", std::string("string")); }
hegyi@1
    14
          break;
hegyi@1
    15
      }
hegyi@1
    16
    }
hegyi@1
    17
    else {
hegyi@1
    18
      std::string type;
hegyi@1
    19
      { x("type", type); }
hegyi@1
    20
      if (type == "numeric")
hegyi@1
    21
      {
hegyi@1
    22
        v = MapValue::NUMERIC;
hegyi@1
    23
      }
hegyi@1
    24
      else if (type == "string")
hegyi@1
    25
      {
hegyi@1
    26
        v = MapValue::STRING;
hegyi@1
    27
      }
hegyi@1
    28
      else
hegyi@1
    29
      {
alpar@7
    30
        throw FormatError("Bad format");
hegyi@1
    31
      }
hegyi@1
    32
    }
hegyi@1
    33
  }
hegyi@1
    34
};