source: cpp/gdk/loadertest.cpp @ 57

Last change on this file since 57 was 5, checked in by sz, 16 years ago

added the GDK (Genotype Development Kit)

File size: 1.2 KB
RevLine 
[5]1// This file is a part of Framsticks GDK library.
2// Copyright (C) 2002-2006  Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.frams.alife.pl/ for further information.
4
5#include "genotypeloader.h"
6
7/**
8 @file
9 Sample code: Loading genotypes from Framsticks files
10
11 \include loadertest.cpp
12*/
13
14int main(int argc,char*argv[])
15{
16puts("This example shows how to load genotypes from the standard Framsticks genotype file");
17if (argc<2)
18        {
19        puts("(Please give the file name as command line argument)");
20        return 1;
21        }
22
23long count=0,totalsize=0;
24MiniGenotypeLoader loader(argv[1]);
25// using char* constructor (passing the file name to open)
26MiniGenotype *loaded;
27while(loaded=loader.loadNextGenotype())
28        { // if loaded != NULL then the "org:" object data was
29         // loaded into MiniGenotype object
30        count++;
31        totalsize+=loaded->genotype.len();
32        printf("%d. %s\t(%d characters)\n",count,(const char*)loaded->name,loaded->genotype.len());
33        }
34// the loop repeats until loaded==NULL, which could be beacause of error
35if (loader.getStatus()==MiniGenotypeLoader::OnError)
36        printf("Error: %s",(const char*)loader.getError());
37// (otherwise it was the end of the file)
38
39printf("\ntotal: %d items, %d characters\n",count,totalsize);
40return 0;
41}
Note: See TracBrowser for help on using the repository browser.