From ce49ad54a1ef73a557ef0a6d32362d21718ed2e0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 5 Mar 2013 08:02:05 +0100 Subject: [PATCH] some cleanup and fixing --- components/esm/loadglob.cpp | 8 ++------ components/esm/variant.cpp | 35 +++++++++++++++++++++-------------- components/esm/variant.hpp | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/components/esm/loadglob.cpp b/components/esm/loadglob.cpp index 0cb6d0a416..ccb519acd4 100644 --- a/components/esm/loadglob.cpp +++ b/components/esm/loadglob.cpp @@ -1,17 +1,13 @@ #include "loadglob.hpp" -#include "esmreader.hpp" -#include "esmwriter.hpp" - namespace ESM { - - void Global::load(ESMReader &esm) + void Global::load (ESMReader &esm) { mValue.read (esm, ESM::Variant::Format_Global); } - void Global::save(ESMWriter &esm) + void Global::save (ESMWriter &esm) { mValue.write (esm, ESM::Variant::Format_Global); } diff --git a/components/esm/variant.cpp b/components/esm/variant.cpp index bf8d2069b1..98786c20e3 100644 --- a/components/esm/variant.cpp +++ b/components/esm/variant.cpp @@ -37,7 +37,7 @@ ESM::VarType ESM::Variant::getType() const return mType; } -std::string ESM::Variant::toString() const +std::string ESM::Variant::getString() const { if (!mData) throw std::runtime_error ("can not convert empty variant to string"); @@ -81,23 +81,30 @@ void ESM::Variant::read (ESMReader& esm, Format format) } else // GMST { - esm.getSubName(); - NAME name = esm.retSubName(); - - if (name=="STRV") - { - type = VT_String; - } - else if (name=="INTV") + if (!esm.hasMoreSubs()) { - type = VT_Int; + type = VT_None; } - else if (name=="FLTV") + else { - type = VT_Float; + esm.getSubName(); + NAME name = esm.retSubName(); + + if (name=="STRV") + { + type = VT_String; + } + else if (name=="INTV") + { + type = VT_Int; + } + else if (name=="FLTV") + { + type = VT_Float; + } + else + esm.fail ("invalid subrecord: " + name.toString()); } - else - esm.fail ("invalid subrecord: " + name.toString()); } setType (type); diff --git a/components/esm/variant.hpp b/components/esm/variant.hpp index b50bb1d2fe..b78d647a82 100644 --- a/components/esm/variant.hpp +++ b/components/esm/variant.hpp @@ -45,7 +45,7 @@ namespace ESM VarType getType() const; - std::string toString() const; + std::string getString() const; ///< Will throw an exception, if value can not be represented as a string. int getInteger() const;