From ec22623f1cc80bf09b88dc20bf23e89cbaf7c4ba Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Tue, 12 Jun 2012 09:10:26 +0200 Subject: [PATCH] Add helper method for optional stg values Anders Gidenstam: Style and indentation. --- simgear/scene/tgdb/ReaderWriterSTG.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/simgear/scene/tgdb/ReaderWriterSTG.cxx b/simgear/scene/tgdb/ReaderWriterSTG.cxx index 5b58262b..14318bcf 100644 --- a/simgear/scene/tgdb/ReaderWriterSTG.cxx +++ b/simgear/scene/tgdb/ReaderWriterSTG.cxx @@ -60,6 +60,19 @@ static SGBucket bucketIndexFromFileName(const std::string& fileName) return SGBucket(index); } +static bool hasOptionalValue(sg_gzifstream &in) +{ + while ( (in.peek() != '\n') && (in.peek() != '\r') + && isspace(in.peek()) ) { + in.get(); + } + if ( isdigit(in.peek()) || (in.peek() == '-') ){ + return true; + } else { + return false; + } +} + ReaderWriterSTG::ReaderWriterSTG() { supportsExtension("stg", "SimGear stg database format"); @@ -287,12 +300,7 @@ ReaderWriterSTG::readStgFile(const std::string& absoluteFileName, matrix.preMultRotate(osg::Quat(SGMiscd::deg2rad(hdg), osg::Vec3(0, 0, 1))); - while ( (in.peek() != '\n') && (in.peek() != '\r') && - (in.peek() != '-') && isspace(in.peek()) ) { - in.get(); - } - - if (isdigit(in.peek()) || (in.peek() == '-')){ + if ( hasOptionalValue(in) ){ double pitch(0.0), roll(0.0); in >> pitch >> roll; -- 2.39.5