Changeset 220 for osgVisual


Ignore:
Timestamp:
Feb 2, 2011, 10:14:57 AM (14 years ago)
Author:
Torben Dannhauer
Message:

Added util functions to convert string to bool, int or double.
Modified all files to use this functions.

Location:
osgVisual/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r219 r220  
    8383        <precipitation rate_mmPerHour_rain="5.0" rate_mmPerHour_drySnow="7.0" rate_mmPerHour_wetSnow="10.0" rate_mmPerHour_sleet="0.0"></precipitation>
    8484      </cloudlayer>
    85       <cloudlayer slot="2" type="CUMULUS_MEDIOCRIS" enabled="yes" fadetime="15">
     85      <cloudlayer slot="2" type="CUMULUS_MEDIOCRIS" enabled="no" fadetime="15">
    8686        <geometry baselength="50000" basewidth="50000" thickness="1600" baseHeight="1000" density="0.07"></geometry>
    8787      </cloudlayer>
  • osgVisual/trunk/include/util/visual_util.h

    r219 r220  
    276276         * @return : double representation of the string.
    277277         */
    278         static int strToDouble(std::string s);
     278        static double strToDouble(std::string s);
    279279
    280280        /**
     
    284284         * @return : Integer representation of the string.
    285285         */
    286         static double strToInt(std::string s);
     286        static int strToInt(std::string s);
    287287
    288288        /**
  • osgVisual/trunk/src/util/visual_util.cpp

    r218 r220  
    536536}
    537537
    538 int util::strToDouble(std::string s)
     538double util::strToDouble(std::string s)
    539539{
    540540        double tmp;
    541541        std::stringstream sstr(s);
    542         sstr >> tmp;
    543         return tmp;
    544 }
    545 
    546 double util::strToInt(std::string s)
     542    if (!(sstr >> tmp))
     543        {
     544                OSG_ALWAYS << __FUNCTION__ << "Warning:Unable to convert "<< s <<" to double, using 0.0 as default!" << std::endl;
     545                return 0.0;
     546        }
     547        else
     548                return tmp;
     549}
     550
     551int util::strToInt(std::string s)
    547552{
    548553        int tmp;
    549554        std::stringstream sstr(s);
    550         sstr >> tmp;
    551         return tmp;
     555        if (!(sstr >> tmp))
     556        {
     557                OSG_ALWAYS << __FUNCTION__ << "Warning:Unable to convert "<< s <<" to int, using 0 as default!" << std::endl;
     558                return 0;
     559        }
     560        else
     561                return tmp;
    552562}
    553563
Note: See TracChangeset for help on using the changeset viewer.