STE-Industries: utilities testing
FloatParameterDescriptor.cpp
Go to the documentation of this file.
1 
16 # include "Graphic.h"
18 # include "FloatException.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<float,
30  FloatExceptionType>::UsageFormat =
31  "\t%s%c<number> with number in the range [%g .. %g] (default %g)\n";
32 
61 
62 template<>
64  char* String, Bitmap::CorrectionParameters& Parameters) const
65  noexcept(false)
66  {
67  char* EndPointer;
68  float Value;
69 
70  if (*String != EQUAL_CHARACTER)
71  throw FloatException(ExceptionKind, 0);
72  if (not isdigit(*++String))
73  throw FloatException(ExceptionKind, 0);
74  errno = 0;
75  Value = strtof(String, &EndPointer);
76  if (*EndPointer != END_STRING or errno != 0 or Value < Minimum or
77  Value > Maximum)
78  throw FloatException(ExceptionKind, Value);
79  Parameters.*ParameterPointer = Value;
80  }
81 
82 }
NumericParameterDescriptor.h
Graphic.h
GraphicSpace::FloatException
Definition: FloatException.h:56
GraphicSpace::FloatExceptionType
FloatExceptionType
Definition: FloatException.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
FloatException.h
GraphicSpace::NumericParameterDescriptor::Assign
void Assign(const char *String, Bitmap::CorrectionParameters &Parameters) const noexcept(false) override