-(defun char-ptr-points-to-null (char-ptr)
- "Returns T if foreign character pointer refers to 'NULL' string. Only called for numeric entries"
- ;; Uses short cut and returns T if first character is #\N. It should
- ;; never be non-numeric
- (declare (type char-ptr-def char-ptr))
- (char-equal #\N (uffi:ensure-char-character
- (uffi:deref-pointer char-ptr :char))))
-
-(defun convert-raw-field (char-ptr types index)
- (let ((type (if (listp types)
- (nth index types)
- types)))
- (cond
- ((and (or (eq type :double) (eq type :int32) (eq type :int)
- (eq type :int64))
- (char-ptr-points-to-null char-ptr))
- nil)
+(defun strtoul (char-ptr)
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type char-ptr-def char-ptr))
+ (c-strtoul char-ptr uffi:+null-cstring-pointer+ 10))
+
+(defun strtoull (char-ptr)
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type char-ptr-def char-ptr))
+ (c-strtoull char-ptr uffi:+null-cstring-pointer+ 10))
+
+(defun strtoll (char-ptr)
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type char-ptr-def char-ptr))
+ (c-strtoll char-ptr uffi:+null-cstring-pointer+ 10))
+
+(defun convert-raw-field (char-ptr type &key length encoding)
+ (declare (optimize (speed 3) (safety 0) (space 0))
+ (type char-ptr-def char-ptr))
+ (unless (uffi:null-pointer-p char-ptr)
+ (case type
+ (:double (atof char-ptr))
+ (:int (atol char-ptr))
+ (:int32 (atoi char-ptr))
+ (:uint32 (strtoul char-ptr))
+ (:uint (strtoul char-ptr))
+ (:int64 (strtoll char-ptr))
+ (:uint64 (strtoull char-ptr))
+ (:blob
+ (if length
+ (uffi:convert-from-foreign-usb8 char-ptr length)
+ (error "Can't return blob since length is not specified.")))