cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1 | /* |
cristy | 45ef08f | 2012-12-07 13:13:34 +0000 | [diff] [blame] | 2 | Copyright 1999-2013 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 | |
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
cristy | f697adb | 2013-01-11 12:20:05 +0000 | [diff] [blame] | 25 | #include "MagickCore/locale_.h" |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 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 | |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 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, |
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 | |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 63 | static inline int StringToInteger(const char *restrict value) |
cristy | 7ce14bc | 2010-01-17 00:01:01 +0000 | [diff] [blame] | 64 | { |
| 65 | return((int) strtol(value,(char **) NULL,10)); |
| 66 | } |
| 67 | |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 68 | static inline long StringToLong(const char *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 | |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 73 | static inline unsigned long StringToUnsignedLong(const char *restrict value) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 74 | { |
cristy | 963bbf9 | 2010-05-31 00:38:47 +0000 | [diff] [blame] | 75 | return(strtoul(value,(char **) NULL,10)); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 76 | } |
| 77 | |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 78 | #if defined(__cplusplus) || defined(c_plusplus) |
| 79 | } |
| 80 | #endif |
| 81 | |
| 82 | #endif |