Eidolon
Public Member Functions | Private Member Functions | List of all members
enum Class Reference
Inheritance diagram for enum:
Inheritance graph
Collaboration diagram for enum:
Collaboration graph

Public Member Functions

def __init__ (self, vals, kwargs)
 
def append (self, name, comps)
 
def findName (self, item)
 
def indexOf (self, name)
 
def __str__ (self)
 
def __len__ (self)
 
def __iter__ (self)
 
def __contains__ (self, i)
 
def __getitem__ (self, i)
 
def __getattr__ (self, i)
 
def __setattr__ (self, name, value)
 

Private Member Functions

def _getVal (self, i)
 

Detailed Description

Simulate a Java-like enum type. An instance is initialized with a list of tuples, the first value of each is
the enum member name, the following are the values that name stores. If instead a list of strings is given those
strings are used as the name and value, similarly if a list of singleton tuples is given the names are used as
values. An entry can be accessed as a member of the object using the given name if the name with spaces replaced
with _ is a valid Python identifier.

A second member with the same name prepended with _ returns the name itself. The [] operator can query
values by index or by name. Containment (in/not in) is defined as name membership in the enum.
The members of the enum are also iterable in the given order, each element being a tuple of the name+values.

The constructor accepts keyword arguments to define secondary properties of the enum: "doc" should contain a
documentation string describing the members of the enum, and "valtype" should be a tuple stating the type for each
value in the entries, which assumes all entries have values of the same type.

Eg. given e=enum( ('foo',1,2), ('bar',3,4), ('baz thunk', 5), ('plonk',) )
    'foo' in e   -> True
    e.foo        -> (1,2)
    e._foo       -> 'foo'
    e[1]         -> ('bar',3,4)
    e['bar']     -> (3,4)
    e.baz_thunk  -> 5
    e.plonk      -> 'plonk'

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  vals,
  kwargs 
)
Here is the call graph for this function:

Member Function Documentation

◆ __contains__()

def __contains__ (   self,
  i 
)
Here is the call graph for this function:

◆ __getattr__()

def __getattr__ (   self,
  i 
)
Here is the call graph for this function:

◆ __getitem__()

def __getitem__ (   self,
  i 
)
Here is the call graph for this function:

◆ __iter__()

def __iter__ (   self)

◆ __len__()

def __len__ (   self)

◆ __setattr__()

def __setattr__ (   self,
  name,
  value 
)

◆ __str__()

def __str__ (   self)

◆ _getVal()

def _getVal (   self,
  i 
)
private
Here is the caller graph for this function:

◆ append()

def append (   self,
  name,
  comps 
)
Here is the caller graph for this function:

◆ findName()

def findName (   self,
  item 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexOf()

def indexOf (   self,
  name 
)
Here is the call graph for this function:

The documentation for this class was generated from the following file: