Changeset 973 for cpp/frams/_demos


Ignore:
Timestamp:
07/03/20 00:37:13 (4 years ago)
Author:
Maciej Komosinski
Message:

Increased SString and std::string compatibility: introduced length(), size(), and capacity(), and removed legacy methods that have std::string equivalents

Location:
cpp/frams/_demos
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/genooper_test.cpp

    r955 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    99{
    1010        printf("Genotype: %s\nFormat: %s\nValid: %s\nComment: %s\n",
    11                 g.getGenes().c_str(), g.getFormat().c_str(), g.isValid() ? "yes" : "no", g.getComment().len() == 0 ? "(empty)" : g.getComment().c_str());
     11                g.getGenes().c_str(), g.getFormat().c_str(), g.isValid() ? "yes" : "no", g.getComment().length() == 0 ? "(empty)" : g.getComment().c_str());
    1212}
    1313
  • cpp/frams/_demos/loader_test_geno.cpp

    r732 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    2020                        "If a genotype is indicated (by providing the optional genotype identifier), the program will output the raw genotype, suitable for Framsticks Theater's genotype viewer mode. If a genotype and a field name is given, the field value (instead of the raw genotype) is printed. If the second argument is not given, the genotype names from the file will be listed.\n"
    2121                        "Example: loader_test walking.gen \"Basic Quadruped\" | theater -g -\n"
    22                         );
     22                );
    2323                return 1;
    2424        }
     
    2929        const char* selected = (argc < 3) ? NULL : argv[2];
    3030        const char* field_name = (argc < 4) ? NULL : argv[3];
    31         int selected_index = (selected&&isdigit(selected[0])) ? atol(selected) : 0;
     31        int selected_index = (selected && isdigit(selected[0])) ? atol(selected) : 0;
    3232        // using char* constructor (passing the file name to open)
    3333        GenotypeMini *loaded;
     
    3636                // loaded into MiniGenotype object
    3737                count++;
    38                 totalsize += loaded->genotype.len();
     38                totalsize += loaded->genotype.length();
    3939                if (selected)
    4040                {
     
    6565                        return 0;
    6666                }
    67                 fprintf(stderr, "%d. %s\t(%d characters)\n", count, loaded->name.c_str(), loaded->genotype.len());
     67                fprintf(stderr, "%d. %s\t(%d characters)\n", count, loaded->name.c_str(), loaded->genotype.length());
    6868        }
    6969        // the loop repeats until loaded==NULL, which could be beacause of error
  • cpp/frams/_demos/paramtree_stdin_test.cpp

    r744 r973  
    4545        while (group_names.getNextToken(pos, line, '\n'))
    4646        {
    47                 if ((line.len() > 0) && (line[line.len() - 1] == '\r')) //support for reading \r\n files...
    48                         line = line.substr(0, line.len() - 1);
    49                 if (line.len() > 0 && line[0] != '#') //skip empty lines and #commment lines
     47                if ((line.length() > 0) && (line[line.length() - 1] == '\r')) //support for reading \r\n files...
     48                        line = line.substr(0, line.length() - 1);
     49                if (line.length() > 0 && line[0] != '#') //skip empty lines and #commment lines
    5050                        param.addGroup(line.c_str());
    5151        }
  • cpp/frams/_demos/printconvmap.cpp

    r739 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4848                return;
    4949        }
    50         len1 = gen1.len();
     50        len1 = gen1.length();
    5151        SString g1 = gen1;
    5252        stripstring(g1);
     
    7373                        y2 = len1;
    7474                }
    75                 else    {
     75                else {
    7676                        id = map.findMappingId(y);
    7777                        mr = &map.getMapping(id)->to;
     
    8080                if ((y2 - y) > left_column_padding) y2 = y + left_column_padding;
    8181                if (y2 > (y + len1)) y2 = y + len1;
    82                 printmapping(g + y, y2 - y, *mr, g2.c_str(), g2.len(), left_column_padding);
     82                printmapping(g + y, y2 - y, *mr, g2.c_str(), g2.length(), left_column_padding);
    8383                y = y2;
    8484        }
  • cpp/frams/_demos/simil_test.cpp

    r895 r973  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    7878                M.m_adFactors[i] = -1.0;
    7979        }
    80        
     80
    8181        iCurrParam++;
    8282        szCurrParam = argv[iCurrParam];
    83         int measure_type = -1; 
     83        int measure_type = -1;
    8484        nResult = sscanf(szCurrParam, "%d", &measure_type);
    8585        if (nResult != 1)
     
    8888                return -1;
    8989        }
    90        
     90
    9191        if (measure_type != 0 && measure_type != 1)
    9292        {
    9393                printf("Measure type should be 0 (flexible criteria order and optimal matching) or 1 (vertex degree order and greedy matching)!\n");
    94                 return -1;             
    95         }
    96        
     94                return -1;
     95        }
     96
    9797        M.matching_method = measure_type;
    9898
     
    150150                // while a valid genotype was loaded
    151151                count++;
    152                 totalsize += loaded->genotype.len();
     152                totalsize += loaded->genotype.length();
    153153                // create a Geno object based on the MiniGenotype
    154154                Geno *pNextGenotype = new Geno(loaded->genotype);
     
    156156                {
    157157                        pvGenos.push_back(pNextGenotype);
    158                         char *szNewName = new char[loaded->name.len() + 1];
     158                        char *szNewName = new char[loaded->name.length() + 1];
    159159                        strcpy(szNewName, loaded->name.c_str());
    160160                        pvNames.push_back(szNewName);
Note: See TracChangeset for help on using the changeset viewer.