// LIST.CPP #ifndef __LIST_CPP #define __LIST_CPP #include "list.h" #include #include ///////////////////////////////////////////////////////////////////////////// int List::SeqNumber = 1; List::List() { strcpy( Msg, " *** " ); LineNum = 0; Code = 0; Prev = NULL; Next = NULL; // SEQ NUMBER ID ID = SeqNumber; SeqNumber++; } List::List( int linenum, int code, char *msg ) { LineNum = linenum; Code = code; strcpy( Msg, msg ); Prev = NULL; Next = NULL; // SEQ NUMBER ID ID = SeqNumber; SeqNumber++; } inline List::~List() { ; } List *List::Connect_Left_of( List *Right ) { List *Left = Right->Prev; if( Right ) { Prev = Left; Right->Prev = this; Next = Right; if( Left ) Left->Next = this; return( this ); } else { Next = NULL; return( NULL ); } } List *List::Connect_Right_of( List *Left ) { List *Right = Left->Next; if( Left ) { Next = Right; Left->Next = this; Prev = Left; if( Right ) Right->Prev = this; return( this ); } else { Prev = NULL; return( NULL ); } } List *List::Disconnect() { List *Left = Prev; List *Right = Next; if( Left ) Left->Next = this->Next; if( Right ) Right->Prev = this->Prev; this->Prev = NULL; this->Next = NULL; return( this ); } void List::Add( int linenum, int code, char *msg ) { List *tmp; List *ptr; tmp = new List; tmp->LineNum = linenum; tmp->Code = code; strcpy( tmp->Msg, msg ); ptr = this; while( ptr->Next ) ptr = ptr->Next; tmp->Connect_Right_of( ptr ); } void List::Print( void ) { List *ptr; ptr = this; //Next; // while( ptr ) // { cout << "\n #" << ptr->ID << " " << ptr->Msg << " Line: " << ptr->LineNum << " Rule: " << ptr->Code << "\n" ; // ptr = ptr->Next; // } // cout << "\n"; } ///////////////////////////////////////////////////////////////////////////// #endif // __LIST_CPP