RiakClient.Erlang.OtpInputStream.ReadAtom C# (CSharp) Method

ReadAtom() public method

Read an Erlang atom from the stream.
public ReadAtom ( ) : string
return string
        public string ReadAtom()
        {
            string atom;
            byte tag = Read1SkipVersion();
            switch (tag)
            {
                case OtpExternal.AtomTag:
                    int len = Read2BE();
                    byte[] buffer = new byte[len];
                    ReadN(buffer);
                    atom = OtpUtils.Latin1Encoding.GetString(buffer);
                    if (atom.Length > OtpExternal.MaxAtomLength)
                    {
                        /*
                         * Throwing an exception would be better I think, but truncation
                         * seems to be the way it has been done in other parts of OTP...
                         */
                        atom = atom.Substring(0, OtpExternal.MaxAtomLength);
                    }

                    break;
                default:
                    throw OnBadTag(tag, OtpExternal.AtomTag);
            }

            return atom;
        }

Usage Example

 public void Read_Atom(byte[] buf, string want)
 {
     using (var s = new OtpInputStream(buf))
     {
         string atom = s.ReadAtom();
         Assert.AreEqual(want, atom);
     }
 }
All Usage Examples Of RiakClient.Erlang.OtpInputStream::ReadAtom