GithubHelp home page GithubHelp logo

goamf's Introduction

First of all, please forgive my poor english.

This is an adobe amf library for golang. As you know amf has defined many types that go does not
support, for those types, this library just ignored. This library has implmented amf3.

Endode:
Encode means to map go types to amf types, there is serveral rules you should know
1. go string will be encode to amf string, the length should be no longer thant a u29
2. go int8, int16 will be encode as amf integer, e.g u29
3. go int64, int32, int, if it lies in [-0xfffffff, 0x20000000), it will be encoded as u29,
if it lies in [-0x7fffffff, -0xfffffff], it will be encoded as double,
otherwise, it will be encoded as string
4. go uint8, uint16 will be encode as amf integer
5. go uint64, uint32, uint, if it lies in [0, 0x2000000), it will be encoded as u29,
if it lies in [0x20000000, 0x7fffffff], it will be encoded as double,
otherwise, it will be encoded as string
6. go float32, float64 will be encoded as double
7. go array, slice will be encoded as amf array, emca array does not supported
8. go map, struct will be encoded as amf object, only amf dynamic object supported
9. other types not listed above will not supported

NOTICE:
Because struct is passed by value, so just for effient, you should pass the top level struct as
pointer, or it will return an error. Struct field name will be encoded as object key follows such
rules:
1. if field has tag "amf.name", the tag will be used.
2. encoder configed as reserved, the field name will be used.
3. encoder configed as not reserved, the first rune of field name will be transfered to lower
4. if field can't be accssed, ignore

Usage:

encoder := amf.NewEncoder(writer, true)
err := encoder.Encode(xxx)
if err != nil {
	xxx	
}

Decode:
Decode means to map amf types to go types, the rule is the same as encoding.
As you can see, many go types may map to only one amf type, so decoder support to specify
a concrete value

Usage:

decoder := amf.NewDecoder(reader)
ret := new(xxx)
err := decoder.Decode(ret)
if err != nil {
	xxx
}

For more information, you could just see the test as example.

goamf's People

Contributors

lazytiger avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.