Files
Cnomicon/include/libnet++/UriParse.h
2021-01-22 10:16:20 -05:00

92 lines
2.3 KiB
C++

//
// URI Parser
// Neal Probert
//
/* prevent multiple inclusions */
#ifndef __UriParse__
#define __UriParse__
/* includes *****************************************************************/
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <vector>
#include "QueryString.h"
/* defines ******************************************************************/
/* macros *******************************************************************/
/* structs & typedefs *******************************************************/
/* c class definitions ******************************************************/
//
// Chop up the URI into it's component parts
//
class UriParse {
// public data
public:
std::string Proto;
std::string User;
std::string Pass;
std::string Host;
std::string Port;
std::string Path;
std::vector<QueryString> Queries;
// private data
private:
int Rate;
// static data
// public methods
public:
// constructors
UriParse();
UriParse( const char *uri );
// destructor
virtual ~UriParse();
// access methods
int setUri( const char *uri ); // parse
int getUri( char *buf, int size );
void setProto( const char *s ) { Proto = s; };
void setUser( const char *s ) { User = s; };
void setPassword( const char *s ) { Pass = s; };
void setHost( const char *s ) { Host = s; };
void setService( const char *s ){ Port = s; };
void setPort( int p ) { Port = p; };
void setPath( const char *s ) { Path = s; };
void setRate( int r ) { Rate = r; };
const char *getProto(void) { return Proto.c_str(); };
const char *getUser(void) { return User.c_str(); };
const char *getPassword(void) { return Pass.c_str(); };
const char *getHost(void) { return Host.c_str(); };
const char *getService(void) { return Port.c_str(); };
int getPort(void);
const char *getPath(void) { return Path.c_str(); };
int getRate(void) { return Rate; };
void setQuery( const char *name, const char *value );
const char *getQuery( const char *name );
// static methods
// private methods
private:
void Init(void);
int Parse( const char *uri );
};
#endif