Changeset 45105b


Ignore:
Timestamp:
Oct 16, 2008, 9:25:56 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
88e31c
Parents:
93d0ee
Message:

New function IsValidNumber(): checks whether a command line argument os truely a valid number

This is needed for the following commits where each command line arguments makes thorough checks to the number of its subsequent arguments.

Location:
molecuilder/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/helpers.cpp

    r93d0ee r45105b  
    182182};
    183183
     184/** Tests whether a given string contains a valid number or not.
     185 * \param *string
     186 * \return true - is a number, false - is not a valid number
     187 */
     188bool IsValidNumber( const char *string)
     189{
     190  int ptr = 0;
     191  if ((string[ptr] == '.') || (string[ptr] == '-')) // number may be negative or start with dot
     192    ptr++;
     193  if ((string[ptr] >= '0') && (string[ptr] <= '9'))
     194    return true;
     195  return false;
     196};
     197
     198
  • molecuilder/src/helpers.hpp

    r93d0ee r45105b  
    5959void Free(void ** buffer, const char* output);
    6060char *FixedDigitNumber(const int FragmentNumber, const int digits);
     61bool IsValidNumber( const char *string);
    6162
    6263/********************************************** helpful template functions *********************************/
Note: See TracChangeset for help on using the changeset viewer.