Show
Ignore:
Timestamp:
10/09/06 22:00:12 (2 years ago)
Author:
ug
Message:

Improved GameList? interface (e.g. for different board sizes). Added Makefile.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 06/libkombilo/sgfparser.cc

    r191 r195  
    122122} 
    123123 
    124 char_p* parseRootNode(Node* n) throw(SGFError) { 
    125  
    126   char_p* results = new char_p[15]; 
    127   for(int ii=0; ii<15; ii++) results[ii] = 0; 
    128  
     124vector<string>* parseRootNode(Node* n, vector<string>* tags) throw(SGFError) { 
     125  vector<string>* results = new vector<string>(tags->size()); 
    129126  string s = n->SGFstring; 
    130127  int lSGFstring = s.size(); 
     
    199196      if (i >= lSGFstring || s[i] != '[') { 
    200197        propValue[propValueIndex-2] = 0; 
    201         if (!strcmp(ID,"BR")) { 
    202           results[posBR] = new char[strlen(propValue)+1]; 
    203           strcpy(results[posBR], propValue); 
    204         } else 
    205         if (!strcmp(ID,"CA")) { 
    206           results[posCA] = new char[strlen(propValue)+1]; 
    207           strcpy(results[posCA], propValue); 
    208         } else 
    209         if (!strcmp(ID,"DT")) { 
    210           results[posDT] = new char[strlen(propValue)+1]; 
    211           strcpy(results[posDT], propValue); 
    212         } else 
    213         if (!strcmp(ID,"EV")) { 
    214           results[posEV] = new char[strlen(propValue)+1]; 
    215           strcpy(results[posEV], propValue); 
    216         } else 
    217         if (!strcmp(ID,"HC")) { 
    218           results[posHC] = new char[strlen(propValue)+1]; 
    219           strcpy(results[posHC], propValue); 
    220         } else 
    221         if (!strcmp(ID,"KM")) { 
    222           results[posKM] = new char[strlen(propValue)+1]; 
    223           strcpy(results[posKM], propValue); 
    224         } else 
    225         if (!strcmp(ID,"PB")) { 
    226           results[posPB] = new char[strlen(propValue)+1]; 
    227           strcpy(results[posPB], propValue); 
    228         } else 
    229         if (!strcmp(ID,"PC")) { 
    230           results[posPC] = new char[strlen(propValue)+1]; 
    231           strcpy(results[posPC], propValue); 
    232         } else 
    233         if (!strcmp(ID,"PW")) { 
    234           results[posPW] = new char[strlen(propValue)+1]; 
    235           strcpy(results[posPW], propValue); 
    236         } else 
    237         if (!strcmp(ID,"RE")) { 
    238           results[posRE] = new char[strlen(propValue)+1]; 
    239           strcpy(results[posRE], propValue); 
    240         } else 
    241         if (!strcmp(ID,"RO")) { 
    242           results[posRO] = new char[strlen(propValue)+1]; 
    243           strcpy(results[posRO], propValue); 
    244         } else 
    245         if (!strcmp(ID,"RU")) { 
    246           results[posRU] = new char[strlen(propValue)+1]; 
    247           strcpy(results[posRU], propValue); 
    248         } else 
    249         if (!strcmp(ID,"SZ")) { 
    250           results[posSZ] = new char[strlen(propValue)+1]; 
    251           strcpy(results[posSZ], propValue); 
    252         } else 
    253         if (!strcmp(ID,"US")) { 
    254           results[posUS] = new char[strlen(propValue)+1]; 
    255           strcpy(results[posUS], propValue); 
    256         } else 
    257         if (!strcmp(ID,"WR")) { 
    258           results[posWR] = new char[strlen(propValue)+1]; 
    259           strcpy(results[posWR], propValue); 
     198        string IDstring = ID; 
     199        int ctr = 0; 
     200        for(vector<string>::iterator it = tags->begin(); it != tags->end(); it++) { 
     201          if (IDstring == *it) { 
     202            (*results)[ctr] = propValue; 
     203            break; 
     204          } 
     205          ctr++; 
    260206        } 
    261207        delete [] propValue;