NAME

getvar - reads a value from a file which was formatted according to io::putvar()

SYNOPSIS

io::getvar()
io::getvar(file)
file.getvar()

DESCRIPTION

Reads a single (possibly composite) value from the given file. If the file is not specified, reads from io::Input. The values must formatted with type and structure information. Type information includes integral and floating point type suffixes, and character and string quotes. Structure information includes syntax for arrays, lists, packed arrays, and objects.

The grammar for structured input is as follows:

        value   : item
                | T_LBRAK packed T_RBRAK
                | T_HASH_LBRACE array T_RBRACE
                | T_LBRACE list T_RBRACE
                | T_LLL list T_RRR
                ;
  
        qname   : T_NAME
                | T_NS_NAME T_COLON_COLON T_NAME
                | T_PUBLIC T_COLON_COLON T_NAME
                | T_COLON_COLON T_NAME
                ;
  
        item    : T_CONST
                | qname                         // Only if qname is NOT a CL_CLASS
                | qname T_LBRACE props T_RBRACE // Only if qname is a CL_CLASS
                | qname qname T_LBRACE props T_RBRACE // Only if first qname is a CL_CLASS
                | T_CLASS qname
                | T_H_OBJ T_LPAR T_CONST T_RPAR
                | T_H_PTR T_LPAR T_CONST T_RPAR
                | T_H_PRC T_LPAR T_CONST T_RPAR
                ;
  
        packed  : item
                | item T_COMMA packed
                | T_LBRAK packed T_RBRAK
                | T_LBRAK packed T_RBRAK T_COMMA packed
                ;
  
        array   : item
                | item T_COMMA array
                | T_HASH_LBRACE array T_RBRACE
                | T_HASH_LBRACE array T_RBRACE T_COMMA array
                ;
  
        list    : value
                | value T_COMMA list
                ;
  
        props   : // NOTHING
                | prop props
                ;
  
        prop    : T_CONST T_EQUALS value
                ;

Note that the T_CONST terminal encompasses any valid OADL input constant token, including integral constants, floating point constants, characters, strings, and named items.

RETURN VALUE

The value read

ERRORS

AccessCheck for an attempt to access a closed file
IoCheck for other miscellaneous I/O errors (see ferror)

EXAMPLES

        io::getvar() // Next line is typed by the user
    [[1,2],[3,4]]
    1 2
    3 4

        io::getvar() // Next line is typed by the user
    L"Hello\nWorld!"
    Hello!
    World

        class foo {public var x, y;}
        io::getvar()

        foo bar {x = 3}
        io::getvar // Next line is typed by the user
    foo bar { x = 3 }
    bar

        bar.x
    3

SEE ALSO

putvar
new File