Source/NFX.Erlang/ErlInputStream.cs
/// <summary>
/// Read an Erlang atom from the stream
/// </summary>
Read an Erlang atom from the stream
Read an Erlang atom from the stream
public ErlAtom ReadAtom()
      {
        var tag = readTag();
        int len;
        Encoding enc;
        switch (tag)
        {
          case ErlExternalTag.Atom:
            len = Read2BE();
            enc = Encoding.ASCII;
            break;
          case ErlExternalTag.SmallAtom:
            len = Read1();
            enc = Encoding.ASCII;
            break;
          case ErlExternalTag.AtomUtf8:
            len = Read2BE();
            enc = Encoding.UTF8;
            break;
          case ErlExternalTag.SmallAtomUtf8:
            len = Read1();
            enc = Encoding.UTF8;
            break;
          default:
            throw new ErlException(StringConsts.ERL_INVALID_TERM_TYPE_ERROR,
                "atom", tag.ToString());
        }
        checkSpace(len);
        int n = Math.Min(len, AtomTable.MAX_ATOM_LEN);
        string s = enc.GetString(m_Buffer, m_Position, n);
        m_Position += len;
        return new ErlAtom(s);
      }
public ErlAtom ReadAtom ( ) { var tag = readTag ( ) ; int len ; Encoding enc ; switch ( tag ) { case ErlExternalTag . Atom : len = Read2BE ( ) ; enc = Encoding . ASCII ; break ; case ErlExternalTag . SmallAtom : len = Read1 ( ) ; enc = Encoding . ASCII ; break ; case ErlExternalTag . AtomUtf8 : len = Read2BE ( ) ; enc = Encoding . UTF8 ; break ; case ErlExternalTag . SmallAtomUtf8 : len = Read1 ( ) ; enc = Encoding . UTF8 ; break ; default : throw new ErlException ( StringConsts . ERL_INVALID_TERM_TYPE_ERROR , " " , tag . ToString ( ) ) ; } checkSpace ( len ) ; int n = Math . Min ( len , AtomTable . MAX_ATOM_LEN ) ; string s = enc . GetString ( m_Buffer , m_Position , n ) ; m_Position += len ; return new ErlAtom ( s ) ; }
Read an Erlang atom from the stream
Read an Erlang atom from the stream