Changeset 8536


Ignore:
Timestamp:
06/07/11 15:37:28 (14 years ago)
Author:
jschierm
Message:

Options: Added Get method for list of strings from cell.

Location:
issm/trunk/src/c/Container
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Container/Options.cpp

    r8224 r8536  
    213213                memcpy(outstring,default_value,stringsize*sizeof(char));
    214214                *pvalue=outstring;
     215        }
     216
     217}
     218/*}}}*/
     219/*FUNCTION Options::Get(char*** ppvalue,int* numel,char* name){{{1*/
     220void Options::Get(char*** ppvalue,int* numel,const char* name){
     221
     222        vector<Object*>::iterator object;
     223        Option* option=NULL;
     224        Option* option2=NULL;
     225        Options* options=NULL;
     226        int   i;
     227
     228        /*Get option*/
     229        option=GetOption(name);
     230
     231        /*If the pointer is not NULL, the option has been found*/
     232        if(option){
     233                /*If the object is a Cell, copy the strings from its options dataset*/
     234                if(option->Enum()==OptionCellEnum){
     235                        if (option->NumEl()) {
     236                                *ppvalue=(char **) xmalloc(option->NumEl()*sizeof(char *));
     237                                if (numel) *numel=option->NumEl();
     238                                option->Get(&options);
     239                                for (i=0; i<option->NumEl(); i++) {
     240                                        option2=((Option *)options->GetObjectByOffset(i));
     241                                        if(option2->Enum()==OptionCharEnum && option2->NDims()==2)
     242                                                option2->Get(&((*ppvalue)[i]));
     243                                        else
     244                                                ((*ppvalue)[i])=NULL;
     245                                }
     246                        }
     247                }
     248                /*Else: not supported*/
     249                else{
     250                        _error_("Cannot recover field \"%s\" for an option of type %s",name,EnumToStringx(option->Enum()));
     251                }
     252        }
     253        /*Else, the Option does not exist, no default provided*/
     254        else{
     255                *ppvalue=NULL;
     256                if (numel) *numel=0;
    215257        }
    216258
  • issm/trunk/src/c/Container/Options.h

    r7760 r8536  
    2929                void Get(char**   pvalue,const char* name);
    3030                void Get(char**   pvalue,const char* name,const char* default_value);
     31                void Get(char***  pvalue,int* numel,const char* name);
    3132                void Get(double** pvalue,int* numel,const char* name);
    3233};
Note: See TracChangeset for help on using the changeset viewer.