STE-Industries: utilities testing
IntegerParameterDescriptor.cpp
Go to the documentation of this file.
1 
16 # include "Graphic.h"
18 # include "IntegerException.h"
19 
20 # include <string.h>
21 # include <ctype.h>
22 # include <errno.h>
23 
24 namespace GraphicSpace
25 {
26 
28 template<>
29 const char* NumericParameterDescriptor<unsigned int,
30  IntegerExceptionType>::UsageFormat =
31  "\t%s%c<number> with number in the range [%u .. %u] (default %u)\n";
32 
63 
64 template<>
66  Assign(const char* String,
67  Bitmap::CorrectionParameters& Parameters) const noexcept(false)
68  {
69  char* EndPointer;
70  unsigned long Value;
71 
72  if (*String != EQUAL_CHARACTER)
73  throw IntegerException(ExceptionKind, 0);
74  if (not isdigit(*++String))
75  throw IntegerException(ExceptionKind, 0);
76  errno = 0;
77  Value = strtoul(String, &EndPointer, DECIMAL_BASE);
78  if (*EndPointer != END_STRING or errno != 0 or Value < Minimum or
79  Value > Maximum)
80  throw IntegerException(ExceptionKind, Value);
81  Parameters.*ParameterPointer = static_cast<unsigned int>(Value);
82  }
83 
84 }
NumericParameterDescriptor.h
Graphic.h
GraphicSpace::IntegerException
Definition: IntegerException.h:92
GraphicSpace::IntegerExceptionType
IntegerExceptionType
Definition: IntegerException.h:35
GraphicSpace::Bitmap::CorrectionParameters
Definition: Bitmap.h:182
END_STRING
static constexpr char END_STRING
Definition: Graphic.h:26
GraphicSpace
Definition: Bitmap.cpp:29
DECIMAL_BASE
static constexpr int DECIMAL_BASE
Definition: Graphic.h:31
GraphicSpace::NumericParameterDescriptor::Assign
void Assign(const char *String, Bitmap::CorrectionParameters &Parameters) const noexcept(false) override
IntegerException.h