source: cpp/gdk/loadertest.cpp @ 97

Last change on this file since 97 was 66, checked in by Maciej Komosinski, 14 years ago

set 'eol-style' to 'native'

  • Property svn:eol-style set to native
File size: 1.2 KB
RevLine 
[64]1// This file is a part of the Framsticks GDK library.
2// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
[5]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.