Ignore:
Timestamp:
27/08/2010 19:33:13 (21 months ago)
Author:
chris
Message:

Add support for account numbers greater than 0x7fffffff without
wrapping. (merges [2696] from trunk).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • box/RELEASE/0.11/lib/common/Configuration.cpp

    r2493 r2716  
    454454        else 
    455455        { 
    456                 long value = ::strtol((i->second).c_str(), NULL, 0 /* C style handling */); 
     456                long value = ::strtol((i->second).c_str(), NULL, 
     457                        0 /* C style handling */); 
    457458                if(value == LONG_MAX || value == LONG_MIN) 
     459                { 
     460                        THROW_EXCEPTION(CommonException, ConfigBadIntValue) 
     461                } 
     462                return (int)value; 
     463        } 
     464} 
     465 
     466 
     467// -------------------------------------------------------------------------- 
     468// 
     469// Function 
     470//              Name:    Configuration::GetKeyValueUint32(const std::string& rKeyName) 
     471//              Purpose: Gets a key value as a 32-bit unsigned integer 
     472//              Created: 2003/07/23 
     473// 
     474// -------------------------------------------------------------------------- 
     475uint32_t Configuration::GetKeyValueUint32(const std::string& rKeyName) const 
     476{ 
     477        std::map<std::string, std::string>::const_iterator i(mKeys.find(rKeyName)); 
     478         
     479        if(i == mKeys.end()) 
     480        { 
     481                THROW_EXCEPTION(CommonException, ConfigNoKey) 
     482        } 
     483        else 
     484        { 
     485                errno = 0; 
     486                long value = ::strtoul((i->second).c_str(), NULL, 
     487                        0 /* C style handling */); 
     488                if(errno != 0) 
    458489                { 
    459490                        THROW_EXCEPTION(CommonException, ConfigBadIntValue) 
     
    681712                                        } 
    682713                                } 
     714 
     715                                // Check it's a number? 
     716                                if(pvkey->Flags() & ConfigTest_IsUint32) 
     717                                {                                        
     718                                        // Test it... 
     719                                        char *end; 
     720                                        errno = 0; 
     721                                        uint32_t r = ::strtoul(val, &end, 0); 
     722                                        if(errno != 0 || end != (val + rval.size())) 
     723                                        { 
     724                                                // not a good value 
     725                                                ok = false; 
     726                                                rErrorMsg += rLevel + mName + "." + pvkey->Name() + " (key) is not a valid unsigned 32-bit integer.\n"; 
     727                                        } 
     728                                } 
    683729                                 
    684730                                // Check it's a bool? 
Note: See TracChangeset for help on using the changeset viewer.