]> granicus.if.org Git - imagemagick/blob - MagickCore/string-private.h
(no commit message)
[imagemagick] / MagickCore / string-private.h
1 /*
2   Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7
8     http://www.imagemagick.org/script/license.php
9
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.
15
16   MagickCore private string methods.
17 */
18 #ifndef _MAGICKCORE_STRING_PRIVATE_H
19 #define _MAGICKCORE_STRING_PRIVATE_H
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 #include <MagickCore/locale_.h>
26
27 static inline double SiPrefixToDoubleInterval(const char *string,
28   const double interval)
29 {
30   char
31     *q;
32
33   double
34     value;
35
36   value=InterpretSiPrefixValue(string,&q);
37   if (*q == '%')
38     value*=interval/100.0;
39   return(value);
40 }
41
42 static inline double StringToDouble(const char *restrict string,
43   char **restrict sentinal)
44 {
45   return(InterpretLocaleValue(string,sentinal));
46 }
47
48 static inline double StringToDoubleInterval(const char *string,
49   const double interval)
50 {
51   char
52     *q;
53
54   double
55     value;
56
57   value=InterpretLocaleValue(string,&q);
58   if (*q == '%')
59     value*=interval/100.0;
60   return(value);
61 }
62
63 static inline int StringToInteger(const char *restrict value)
64 {
65   return((int) strtol(value,(char **) NULL,10));
66 }
67
68 static inline long StringToLong(const char *restrict value)
69 {
70   return(strtol(value,(char **) NULL,10));
71 }
72
73 static inline unsigned long StringToUnsignedLong(const char *restrict value)
74 {
75   return(strtoul(value,(char **) NULL,10));
76 }
77
78 #if defined(__cplusplus) || defined(c_plusplus)
79 }
80 #endif
81
82 #endif