namespace X3DTK {

template<class V>
void FieldLoader<V>::load(X3DField &field, const SFString &name)
{
  *reinterpret_cast<V *>(field.data()) = V(name);
}

template<class V>
SFString FieldWriter<V>::write(const X3DField &field)
{
  return (*reinterpret_cast<V *>(field.data())).toSFString();
}

template<class V>
void FieldWriter<V>::writeToFile(SFString &output, const SFString &name, const X3DField &field, const SFString &init)
{
  SFString value = (*reinterpret_cast<V *>(field.data())).toSFString();
  if (value != init)
    output += " " + name + "=" + value;
}

template<class V>
void FieldWriter<V>::write(SFString &output, const V &value)
{
  output += value.toSFString();
}

}
