summaryrefslogtreecommitdiff
path: root/src/tests/rh.cpp
blob: 70abcb71a7203af63ad4179215dcf2002ddccf37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "bu/file.h"
#include "bu/hash.h"
#include "bu/archive.h"
#include "bu/fstring.h"
#include "bu/nids.h"
#include "bu/nidsstream.h"

int main( int argc, char *argv[] )
{
	if( argv[1][0] == 'r' )
	{
		typedef Bu::Hash<Bu::FString, int> Hsh;

		Bu::File fIn( argv[2], Bu::File::Read );
		Bu::Archive ar( fIn, Bu::Archive::load );

		Hsh h;
		ar >> h;

		printf("Read %d.\n", h.getSize() );
		for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
		{
			printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
		}

		printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
	}
	else if( argv[1][0] == 'n' )
	{
		typedef Bu::Hash<Bu::FString, int> Hsh;

		Bu::File fIn( argv[2], Bu::File::Read );
		Bu::Nids n( fIn );
		n.initialize();
		Bu::NidsStream sIn = n.openStream( 0 );
		Bu::Archive ar( sIn, Bu::Archive::load );

		Hsh h;
		ar >> h;

		printf("Read %d.\n", h.getSize() );
		for( Hsh::iterator i = h.begin(); i != h.end(); i++ )
		{
			printf(" - \"%s\" = %d\n", i.getKey().getStr(), i.getValue() );
		}

		printf("%d vs. %d\n", h.getSize(), h.getKeys().getSize() );
	}

	return 0;
}