2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								! Copyright (C) 2006 Chris Double.  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								! See http://factorcode.org/license.txt for BSD license.  
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								USING:  help.syntax  help.markup  byte-arrays  io  ;
  
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								IN:  serialize  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  serialize  
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "obj"  "object to serialize"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Serializes the object to "  { $link output-stream  } "."  } ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  deserialize  
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $values { "obj"  "deserialized object"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $description "Deserializes an object by reading from "  { $link input-stream  } "."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  object>bytes  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "obj"  "object to serialize"  } { "bytes"  byte-array }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Serializes the object to a byte array."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								HELP:  bytes>object  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{ $values { "bytes"  byte-array } { "obj"  "deserialized object"  } 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $description "Deserializes an object from a byte array."  } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ARTICLE: "serialize"  "Binary object serialization" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"The "  { $vocab-link "serialize"  } " vocabulary implements binary serialization for all Factor data types except for continuations. Unlike the prettyprinter, shared structure and circularity is preserved."  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$nl
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"Storing objects on streams:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    serialize
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    deserialize
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"Storing objects as byte arrays:"  
						 
					
						
							
								
									
										
										
										
											2009-10-01 15:56:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ $subsections
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    object>bytes
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    bytes>object
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-14 23:49:17 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ABOUT: "serialize"