K2Informatics.Erlnet.OtpInputStream.read_tuple_head C# (CSharp) Méthode

read_tuple_head() public méthode

public read_tuple_head ( ) : int
Résultat int
        public int read_tuple_head()
        {
            int arity = 0;
            int tag = read1skip_version();

            // decode the tuple header and get arity
            switch (tag)
            {
                case OtpExternal.smallTupleTag:
                    arity = read1();
                    break;

                case OtpExternal.largeTupleTag:
                    arity = read4BE();
                    break;

                default:
                    throw new OtpErlangDecodeException("Not valid tuple tag: " + tag);
            }

            return arity;
        }

Usage Example

        /**
         * Create a tuple from a stream containing an tuple encoded in Erlang
         * external format.
         *
         * @param buf
         *                the stream containing the encoded tuple.
         *
         * @exception OtpErlangDecodeException
         *                    if the buffer does not contain a valid external
         *                    representation of an Erlang tuple.
         */
        public OtpErlangTuple(OtpInputStream buf)
        {
            int arity = buf.read_tuple_head();

            if (arity > 0)
            {
                elems = new OtpErlangObject[arity];

                for (int i = 0; i < arity; i++)
                {
                    elems[i] = buf.read_any();
                }
            }
            else
            {
                elems = NO_ELEMENTS;
            }
        }