//--------------------------------------------------------------------------------------------------------------------// //Afairese tis perites parenthesis apo ena dentro parenthesis * simplify(parenthesis * input) { int i=0; parenthesis ** kids=input->subparenthesis; parenthesis * temporal; char * temp=(char*) malloc(MAX); if(temp== NULL) { fprintf(stderr, "out of memory\n"); return NULL; } if((input->kids)==1) { strcpy(temp,kids[0]->content); wrapwithparenthesis(temp); if(!strcmp(temp,input->content)) { replacement(input->content,input->content, kids[0]->content); temporal=addpar(input->content,input->parent,NULL,input->num,input->depth); removetree(input); free(input); } else { return input; } temporal=simplify(temporal); free(temp); return temporal; } else if ((input->kids)>1) { for(i=0;i<input->kids;i++) { strcpy(temp,(kids[i]->content)); kids[i]= simplify(kids[i]); replacement(input->content,temp, kids[i]->content); temporal=addpar(input->content,input->parent,NULL,input->num,input->depth); removetree(input); free(input); input=temporal; kids=input->subparenthesis; } free(temp); } else { free(temp); return input; } return input; }
QtXmlWrapper::QtXmlWrapper() : d( new XmlData ) { version.Major = 2; version.Minor = 4; version.Revision = 1; minimal = true; d->m_node = d->m_doc.createElement( "ZynAddSubFX-data" ); d->m_node.setAttribute( "version-major", QString::number( version.Major ) ); d->m_node.setAttribute( "version-minor", QString::number( version.Minor ) ); d->m_node.setAttribute( "version-revision", QString::number( version.Revision ) ); d->m_node.setAttribute( "ZynAddSubFX-author", "Nasca Octavian Paul" ); d->m_doc.appendChild( d->m_node ); //make the empty branch that will contain the information parameters d->m_info = d->addparams("INFORMATION", 0); //save zynaddsubfx specifications beginbranch("BASE_PARAMETERS"); addpar("max_midi_parts", NUM_MIDI_PARTS); addpar("max_kit_items_per_instrument", NUM_KIT_ITEMS); addpar("max_system_effects", NUM_SYS_EFX); addpar("max_insertion_effects", NUM_INS_EFX); addpar("max_instrument_effects", NUM_PART_EFX); addpar("max_addsynth_voices", NUM_VOICES); endbranch(); }
//--------------------------------------------------------------------------------------------------------------------// //Dhmiourgia tou dentrou apo ena string parenthesis* addpar(char * content,parenthesis * parent,parenthesis* current,int num,int depth) { //---------------Initializing-----------------Memory Allocation---------------------------------// int next=0; int i=0; char * temporal=(char *) malloc(MAX); if(temporal == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } char * inputemp=(char *) malloc(MAX); if(inputemp == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } char * input=(char*)malloc(MAX); if(input == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } if (current==NULL) { current=(parenthesis*) malloc(sizeof(parenthesis)); if(current == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } } parenthesis ** newkids=(parenthesis**) malloc(sizeof(parenthesis*)); if(newkids == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } current->content=(char *)malloc(MAX); strcpy(current->content,content); current->parent=parent; current->num=num; current->depth=depth; if (parent){(parent->subparenthesis)[num]=current;} //---------------Initializing-----------------Memory Allocation---------------------------------// //--------------------------Allocate space for the variables---------------------------------------// current->variables = malloc(MAX* sizeof(char *)); if(current->variables == NULL) { fprintf(stderr, "out of memory\n"); return; } for(i = 0; i < MAX; i++) { (current->variables)[i] = malloc(MAX * sizeof(char)); if(current->variables[i]==NULL) { fprintf(stderr, "out of memory\n"); return; } } //--------------------------Allocate space for the variables------------------------------------------------// //-----------------------Take the parents variables and add your own------------------------------------------// i=0; if (parent) { for (i=0;((strlen(parent->variables[i])>0)&&(i<MAX)&&(i<current->depth));i++) { strcpy((current->variables)[i],parent->variables[i]); if (i==MAX-1){break;} } } if (i<MAX-1){strcpy((current->variables)[i],varNparenthesis(NULL,content,temporal,NULL));} //-----------------------Take the parents variables and add your own------------------------------------------// //-----------------------Find the subrenthesis and add them to your subtree------------------------------------------// i=0; current->kids=0; strcpy(input,content); eatparethesis(input); while (next<strlen(input)) { strcpy(inputemp,""); next=take_next_parenthesis(input,inputemp,next); newkids = (parenthesis **) realloc(newkids,(i+1)*sizeof(parenthesis*)); if(newkids == NULL) { fprintf(stderr, "out of memory\n"); return NULL; } newkids[i]=(parenthesis*) malloc(sizeof(parenthesis)); current->subparenthesis=newkids; if(newkids[i]== NULL) { fprintf(stderr, "out of memory\n"); return NULL; } if (strlen(inputemp)>0) { addpar(inputemp,current,(newkids[i]),i,(depth+1)); i++; (current->kids)=(current->kids)+1; } current->subparenthesis=newkids; } //-----------------------Find the subrenthesis and add them to your subtree------------------------------------------// //-----------------------Free the Allocated memory you dont need anymore------------------------------------------// free(inputemp); free(input); free(temporal); //-----------------------Free the Allocated memory you dont need anymore------------------------------------------// return current; }