summaryrefslogtreecommitdiff
path: root/src/tests/url.cpp
blob: 4dc8c461918cdf6cf56eb731f77420191f3ce226 (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
#include "bu/url.h"

#include <stdio.h>

int main( int argc, char *argv[] )
{
	for( argc--, argv++; argc >= 0; argc--, argv++ )
	{
		printf("encodede: %s\n", Bu::Url::encode( *argv ).getStr() );
		printf("decodede: %s\n", Bu::Url::decode( *argv ).getStr() );
		Bu::Url u( *argv );

		printf("Protocol: %s\n", u.getProtocol().getStr() );
		printf("User:     %s\n", u.getUser().getStr() );
		printf("Pass:     %s\n", u.getPass().getStr() );
		printf("Host:     %s\n", u.getHost().getStr() );
		printf("Path:     %s\n", u.getPath().getStr() );
		try
		{
			printf("Port:     %d\n", u.getPort() );
		} catch( Bu::ExceptionBase &e )
		{
			printf("Port:     not set.\n");
		}
		printf("Parameters:\n");
		for( Bu::Url::ParamList::const_iterator i = u.getParamBegin(); i; i++ )
		{
			printf("  \"%s\" = \"%s\"\n",
				(*i).sName.getStr(), (*i).sValue.getStr()
				);
		}
	}

	return 0;
}