| 439 | **********************************************************************/ |
| 440 | |
| 441 | int msCopyClass(classObj *dst, classObj *src, layerObj *layer) |
| 442 | { |
| 443 | int i, return_value; |
| 444 | |
| 445 | return_value = msCopyExpression(&(dst->expression),&(src->expression)); |
| 446 | if (return_value != MS_SUCCESS) { |
| 447 | msSetError(MS_MEMERR, "Failed to copy expression.", "msCopyClass()"); |
| 448 | return MS_FAILURE; |
| 449 | } |
| 450 | |
| 451 | MS_COPYSTELEM(status); |
| 452 | |
| 453 | /* free any previous styles on the dst layer */ |
| 454 | for(i=0;i<dst->numstyles;i++) { /* each style */ |
| 455 | if (dst->styles[i]!=NULL) { |
| 456 | if( freeStyle(dst->styles[i]) == MS_SUCCESS ) { |
| 457 | msFree(dst->styles[i]); |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | msFree(dst->styles); |
| 462 | dst->numstyles = 0; |
| 463 | |
| 464 | for (i = 0; i < src->numstyles; i++) { |
| 465 | if (msGrowClassStyles(dst) == NULL) |
| 466 | return MS_FAILURE; |
| 467 | if (initStyle(dst->styles[i]) != MS_SUCCESS) { |
| 468 | msSetError(MS_MEMERR, "Failed to init style.", "msCopyClass()"); |
| 469 | return MS_FAILURE; |
| 470 | } |
| 471 | if (msCopyStyle(dst->styles[i], src->styles[i]) != MS_SUCCESS) { |
| 472 | msSetError(MS_MEMERR, "Failed to copy style.", "msCopyClass()"); |
| 473 | return MS_FAILURE; |
| 474 | } |
| 475 | |
| 476 | dst->numstyles++; |
| 477 | } |
| 478 | |
| 479 | if (msCopyLabel(&(dst->label), &(src->label)) != MS_SUCCESS) { |
| 480 | msSetError(MS_MEMERR, "Failed to copy label.", "msCopyClass()"); |
| 481 | return MS_FAILURE; |
| 482 | } |
| 483 | |
| 484 | MS_COPYSTRING(dst->keyimage, src->keyimage); |
| 485 | MS_COPYSTRING(dst->name, src->name); |
| 486 | MS_COPYSTRING(dst->title, src->title); |
| 487 | MS_COPYSTRING(dst->group, src->group); |
| 488 | |
| 489 | if (msCopyExpression(&(dst->text), &(src->text)) != MS_SUCCESS) { |
| 490 | msSetError(MS_MEMERR, "Failed to copy text.", "msCopyClass()"); |
| 491 | return MS_FAILURE; |
| 492 | } |
| 493 | |
| 494 | #ifndef __cplusplus |
| 495 | MS_COPYSTRING(dst->template, src->template); |
| 496 | #else |
| 497 | MS_COPYSTRING(dst->_template, src->_template); |
| 498 | #endif |
no test coverage detected