blob: bd08be8b3de689fbe7ecb1b55d9b5bbf7ed3f4a3 [file] [log] [blame]
cristyf2f27272009-12-17 14:48:46 +00001/*
cristy45ef08f2012-12-07 13:13:34 +00002 Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
cristyf2f27272009-12-17 14:48:46 +00003 dedicated to making software imaging solutions freely available.
cristye27293e2009-12-18 02:53:20 +00004
cristyf2f27272009-12-17 14:48:46 +00005 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
cristye27293e2009-12-18 02:53:20 +00007
cristyf2f27272009-12-17 14:48:46 +00008 http://www.imagemagick.org/script/license.php
cristye27293e2009-12-18 02:53:20 +00009
cristyf2f27272009-12-17 14:48:46 +000010 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)
22extern "C" {
23#endif
24
cristyf697adb2013-01-11 12:20:05 +000025#include "MagickCore/locale_.h"
cristydbdd0e32011-11-04 23:29:40 +000026
cristy9b34e302011-11-05 02:15:45 +000027static 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
cristydbdd0e32011-11-04 23:29:40 +000042static inline double StringToDouble(const char *restrict string,
43 char **restrict sentinal)
44{
45 return(InterpretLocaleValue(string,sentinal));
46}
47
48static inline double StringToDoubleInterval(const char *string,
cristy63657e32011-11-03 12:05:05 +000049 const double interval)
cristyf2f27272009-12-17 14:48:46 +000050{
51 char
52 *q;
53
54 double
cristyf2f27272009-12-17 14:48:46 +000055 value;
56
cristy9b34e302011-11-05 02:15:45 +000057 value=InterpretLocaleValue(string,&q);
cristy670aa3c2011-11-03 00:54:00 +000058 if (*q == '%')
59 value*=interval/100.0;
cristyf2f27272009-12-17 14:48:46 +000060 return(value);
61}
62
cristydbdd0e32011-11-04 23:29:40 +000063static inline int StringToInteger(const char *restrict value)
cristy7ce14bc2010-01-17 00:01:01 +000064{
65 return((int) strtol(value,(char **) NULL,10));
66}
67
cristydbdd0e32011-11-04 23:29:40 +000068static inline long StringToLong(const char *restrict value)
cristyf2f27272009-12-17 14:48:46 +000069{
cristy963bbf92010-05-31 00:38:47 +000070 return(strtol(value,(char **) NULL,10));
cristyf2f27272009-12-17 14:48:46 +000071}
72
cristydbdd0e32011-11-04 23:29:40 +000073static inline unsigned long StringToUnsignedLong(const char *restrict value)
cristye27293e2009-12-18 02:53:20 +000074{
cristy963bbf92010-05-31 00:38:47 +000075 return(strtoul(value,(char **) NULL,10));
cristye27293e2009-12-18 02:53:20 +000076}
77
cristyf2f27272009-12-17 14:48:46 +000078#if defined(__cplusplus) || defined(c_plusplus)
79}
80#endif
81
82#endif