Commits

Anonymous committed c252cba

added serialization support for characters (suggested by ian eslick)

Comments (0)

Files changed (3)

+2005-01-22 Sven Van Caekenberghe <svc@mac.com>
+
+        * added serialization support for characters (suggested by ian eslick) 
+
+

src/serialization.lisp

   (s-xml:print-string-xml object stream)
   (write-string "</STRING>" stream))
 
+(defmethod serialize-xml-internal ((object character) stream serialization-state)
+  (declare (ignore serialization-state))
+  (write-string "<CHARACTER>" stream)
+  (s-xml:print-string-xml (princ-to-string object) stream)
+  (write-string "</CHARACTER>" stream))
+
 (defmethod serialize-xml-internal ((object symbol) stream serialization-state)
   (declare (ignore serialization-state))
   (write-string "<SYMBOL>" stream)
   (declare (ignore serialization-state))
   (prin1 object stream))
 
+(defmethod serialize-sexp-internal ((object character) stream serialization-state)
+  (declare (ignore serialization-state))
+  (prin1 object stream))
+
 (defmethod serialize-sexp-internal ((object symbol) stream serialization-state)
   (declare (ignore serialization-state))
   (print-symbol object stream))
 	  (:null nil)
 	  (:true t)
 	  (:string (or seed ""))
+          (:character (char seed 0))
 	  (:key (car seed))
 	  (:value (car seed))
 	  (:entry (nreverse seed))

test/test-serialization.lisp

         ""))
 
 (assert
+ (equal (serialize-and-deserialize-xml #\A)
+        #\A))
+
+(assert
+ (equal (serialize-and-deserialize-sexp #\A)
+        #\A))
+
+(assert
+ (equal (serialize-and-deserialize-xml #\<)
+        #\<))
+
+(assert
+ (equal (serialize-and-deserialize-sexp #\<)
+        #\<))
+
+(assert
  (equal (serialize-and-deserialize-xml "Hello <foo> & </bar>!")
 	"Hello <foo> & </bar>!"))