Logo Search packages:      
Sourcecode: lttoolbox version File versions  Download package

void TransExe::read ( FILE *  input,
int  encoding_base 
)

Read method with an encoding base

Parameters:
input the stream
encoding_base the base to decode (tipically, number of different symbols)

Definition at line 63 of file TransExe.C.

References Node::addTransition(), destroy(), finals, initial_id, Compression::multibyte_read(), and node_list.

{
  TransExe &new_t = *this;
  new_t.destroy();
  new_t.initial_id = Compression::multibyte_read(input);
  int finals_size = Compression::multibyte_read(input);

  int base = 0;

  set<int> myfinals;

  while(finals_size > 0)
  {
    finals_size--;

    base += Compression::multibyte_read(input);
    myfinals.insert(base);
  }

  base = Compression::multibyte_read(input);

  int number_of_states = base;
  int current_state = 0;   
  new_t.node_list.resize(number_of_states);

  for(set<int>::iterator it = myfinals.begin(), limit = myfinals.end(); 
      it != limit; it++)
  {
    new_t.finals.insert(&new_t.node_list[*it]);
  }

  while(number_of_states > 0)
  {
    int number_of_local_transitions = Compression::multibyte_read(input);
    int tagbase = 0;
    
    Node &mynode = new_t.node_list[current_state];

    while(number_of_local_transitions > 0)
    {
      number_of_local_transitions--;
      tagbase += Compression::multibyte_read(input);
      int state = (current_state + Compression::multibyte_read(input)) % base;

      unsigned short i_symbol = static_cast<unsigned short>(tagbase / encoding_base);
      unsigned short o_symbol = static_cast<unsigned short>(tagbase % encoding_base);

      mynode.addTransition(i_symbol, o_symbol, &new_t.node_list[state]);
    }   
    number_of_states--;
    current_state++;
  }
}


Generated by  Doxygen 1.6.0   Back to index