2 Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
8 https://www.imagemagick.org/script/license.php
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 MagickCore private string methods.
18 #ifndef MAGICKCORE_STRING_PRIVATE_H
19 #define MAGICKCORE_STRING_PRIVATE_H
21 #include "MagickCore/locale_.h"
23 #if defined(__cplusplus) || defined(c_plusplus)
27 static inline double SiPrefixToDoubleInterval(const char *string,
28 const double interval)
36 value=InterpretSiPrefixValue(string,&q);
38 value*=interval/100.0;
42 static inline double StringToDouble(const char *magick_restrict string,
43 char **magick_restrict sentinal)
45 return(InterpretLocaleValue(string,sentinal));
48 static inline double StringToDoubleInterval(const char *string,
49 const double interval)
57 value=InterpretLocaleValue(string,&q);
59 value*=interval/100.0;
63 static inline int StringToInteger(const char *magick_restrict value)
65 return((int) strtol(value,(char **) NULL,10));
68 static inline long StringToLong(const char *magick_restrict value)
70 return(strtol(value,(char **) NULL,10));
73 static inline MagickSizeType StringToMagickSizeType(const char *string,
74 const double interval)
79 value=SiPrefixToDoubleInterval(string,interval);
80 if (value >= (double) MagickULLConstant(~0))
81 return(MagickULLConstant(~0));
82 return((MagickSizeType) value);
85 static inline size_t StringToSizeType(const char *string,
86 const double interval)
91 value=SiPrefixToDoubleInterval(string,interval);
92 if (value >= (double) MagickULLConstant(~0))
93 return((size_t) MagickULLConstant(~0));
94 return((size_t) value);
97 static inline unsigned long StringToUnsignedLong(
98 const char *magick_restrict value)
100 return(strtoul(value,(char **) NULL,10));
103 #if defined(__cplusplus) || defined(c_plusplus)