GDBMS 1.0
|
00001 #include "maininclude.h" 00002 #include "listi.h" 00003 #include "settings.h" 00004 #include "hash_table.h" 00005 #include "tr_twin_ht.h" 00006 #include "file_semaphore.h" 00007 #include "some_functions.h" 00008 #include "initial_mode_commands.h" 00009 #include "session_mode_commands.h" 00010 #include "transaction_mode_commands.h" 00011 #include "transaction_mode_commands_types.h" 00012 #include "transaction_mode_commands_nodes.h" 00013 #include "transaction_mode_commands_edges.h" 00014 #include "transaction_mode_commands_find.h" 00015 00016 using namespace std; 00017 listi::listi(char* init_str, char separator) 00018 { 00019 if(!init_str){ 00020 int i; 00021 separ=separator; 00022 int strsize=2; 00023 this->buf=new char[strsize]; 00024 for(i=0; i<strsize; i++) 00025 buf[i]=0; 00026 return; 00027 } 00028 00029 int strsize=strlen(init_str)+2; 00030 this->buf=new char[strsize]; 00031 int i; 00032 for(i=0; i<strsize; i++) 00033 buf[i]=0; 00034 strcpy(buf, init_str); 00035 settings::split(buf, &(this->num), &(this->a), separator); 00036 separ=separator; 00037 } 00038 listi::~listi() 00039 { 00040 if(this->buf) 00041 delete this->buf; 00042 if(this->a){ 00043 int i; 00044 for(i=0; i<this->num; i++) 00045 if(a[i]) 00046 delete a[i]; 00047 delete this->a; 00048 } 00049 } 00050 void listi::addelement(char* element) 00051 { 00052 int newsize=strlen(buf)+ strlen(element)+2; 00053 char *newbuf=new char[newsize]; 00054 if(newbuf){ 00055 int i; 00056 for(i=0; i<newsize; i++) 00057 newbuf[i]=0; 00058 strcat(newbuf, buf); 00059 newbuf[strlen(newbuf)]=separ; 00060 strcat(newbuf, element); 00061 this->~listi(); 00062 this->listi(newbuf, separ); 00063 delete newbuf; 00064 } 00065 00066 } 00067 char* listi::getith(int i) 00068 { 00069 return this->a[i]; 00070 } 00071 int listi::getnum() 00072 { 00073 return this->num; 00074 } 00075 void listi::removeelement(char* element) 00076 { 00077 int i; 00078 int n=strlen(this->buf)+2; 00079 char *newbuf=new char[n]; 00080 for(i=0; i<n; i++) 00081 newbuf[i]=0; 00082 for(i=0; i<this->num; i++){ 00083 if(!strcmp(element, a[i])){ 00084 delete a[i]; 00085 a[i]=0; 00086 i++; 00087 continue; 00088 }else{ 00089 strcat(newbuf, a[i]); 00090 newbuf[strlen(newbuf)]=separ; 00091 } 00092 } 00093 00094 newbuf[strlen(newbuf)]=0; 00095 this->~listi(); 00096 this->listi(newbuf, separ); 00097 delete newbuf; 00098 00099 00100 } 00101 char* listi::returnstring() 00102 { 00103 return this->buf; 00104 } 00105