| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1 | /* |
| cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 2 | Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3 | dedicated to making software imaging solutions freely available. |
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 4 | |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 5 | You may not use this file except in compliance with the License. |
| 6 | obtain a copy of the License at |
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7 | |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 8 | http://www.imagemagick.org/script/license.php |
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 9 | |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 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 | |
| cristy | 6398ec7 | 2013-11-28 02:00:27 +0000 | [diff] [blame] | 21 | #include "MagickCore/locale_.h" |
| 22 | |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 23 | #if defined(__cplusplus) || defined(c_plusplus) |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 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 | |
| dirk | 05d2ff7 | 2015-11-18 23:13:43 +0100 | [diff] [blame^] | 42 | static inline double StringToDouble(const char *magick_restrict string, |
| 43 | char **magick_restrict sentinal) |
| cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 44 | { |
| 45 | return(InterpretLocaleValue(string,sentinal)); |
| 46 | } |
| 47 | |
| 48 | static inline double StringToDoubleInterval(const char *string, |
| cristy | 63657e3 | 2011-11-03 12:05:05 +0000 | [diff] [blame] | 49 | const double interval) |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 50 | { |
| 51 | char |
| 52 | *q; |
| 53 | |
| 54 | double |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 55 | value; |
| 56 | |
| cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 57 | value=InterpretLocaleValue(string,&q); |
| cristy | 670aa3c | 2011-11-03 00:54:00 +0000 | [diff] [blame] | 58 | if (*q == '%') |
| 59 | value*=interval/100.0; |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 60 | return(value); |
| 61 | } |
| 62 | |
| dirk | 05d2ff7 | 2015-11-18 23:13:43 +0100 | [diff] [blame^] | 63 | static inline int StringToInteger(const char *magick_restrict value) |
| cristy | 7ce14bc | 2010-01-17 00:01:01 +0000 | [diff] [blame] | 64 | { |
| 65 | return((int) strtol(value,(char **) NULL,10)); |
| 66 | } |
| 67 | |
| dirk | 05d2ff7 | 2015-11-18 23:13:43 +0100 | [diff] [blame^] | 68 | static inline long StringToLong(const char *magick_restrict value) |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 69 | { |
| cristy | 963bbf9 | 2010-05-31 00:38:47 +0000 | [diff] [blame] | 70 | return(strtol(value,(char **) NULL,10)); |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| dirk | 05d2ff7 | 2015-11-18 23:13:43 +0100 | [diff] [blame^] | 73 | static inline unsigned long StringToUnsignedLong( |
| 74 | const char *magick_restrict value) |
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 75 | { |
| cristy | 963bbf9 | 2010-05-31 00:38:47 +0000 | [diff] [blame] | 76 | return(strtoul(value,(char **) NULL,10)); |
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 79 | #if defined(__cplusplus) || defined(c_plusplus) |
| 80 | } |
| 81 | #endif |
| 82 | |
| 83 | #endif |