ser

package
v0.0.0-...-e6da677 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2013 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ser provides serialization support for implementing save games.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(input io.Reader) (topValue interface{}, err error)

func Register

func Register(obj Serializable)

Register records a type, identified by a value for that type, under its internal type name.

func RegisterName

func RegisterName(name string, value Serializable)

RegisterName is like Register but uses the provided name rather than the type's default.

func Save

func Save(topValue interface{}, output io.Writer) (err error)

Types

type Archive

type Archive interface {
	// Visit tells the archive to serialize or deserialize, depending on
	// archive type, the given pointer values.
	Visit(value ...interface{})

	// Input returns the io.Reader for a deserializing archive and nil for a
	// serializing one.
	Input() io.Reader

	// Output returns the io.Writer for a serializing archive and nil for a
	// deserializing one.
	Output() io.Writer

	// TagPointer explicitly marks a pointer to a pointer value for the
	// archive. The target of the pointer will need to be serialized
	// separately (once), and on deserialization the pointed pointer will need
	// to be rewritten to whatever the new address of the thing ends up being.
	// This method may be deprecated in favor of just using Visit once Visit
	// becomes sufficiently smart to deal with pointers.
	TagPointer(ptr interface{})

	// StoreGob uses the gob facility to store simple structured data. The
	// data mustn't contain pointers that are used anywhere else, since gob
	// will flatten everything. May be deprecated once the visit method gets
	// smarter.
	StoreGob(value interface{})
}

type Serializable

type Serializable interface {
	// Serialize is the catch-all method that handles both serialization and
	// deserialization by changing the behavior of the Archive object that
	// visits the pointers to the member fields.
	Serialize(a Archive) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL