// -*-C++-*-
//
// $Id: URI.icc,v 1.6 1999/12/02 20:08:04 carzanig Exp $
//
// inline methods for class URI
//

inline URI::URI(): rep(NULL) {};

inline URI::URI(const URI &x): rep(x.rep) {
    if (rep != NULL) ++(rep->ref_count);
}

inline URI::~URI() {
    if (rep != NULL) 
	if (--(rep->ref_count) == 0) delete(rep);
}

inline URISchema URI::schema() const {
    if (rep != NULL) return rep->schema;
    return NULL_SCHEMA;
}

inline const URIRep * URI::representation() const {
    return rep;
}

inline string URI::to_string() const { 
    if (rep == NULL) { 
	return "";
    } else {
	return rep->to_string(); 
    }
}

inline URI & URI::operator = (const URI &x) {
    if (rep != NULL)
	if (--(rep->ref_count) == 0) delete(rep);
    rep = x.rep;
    if (rep != NULL) ++(rep->ref_count);
  return *this;
}

inline iostream * URI::open_connection() const {
    if (rep == NULL) throw BadURI();
    return rep->open_connection();
}

inline bool URI::operator ==(const URI &x) const { 
    if (rep == x.rep) return true;
    if (rep == NULL || x.rep == NULL) return false;
    if (rep->schema != x.rep->schema) return false;
    return *rep == *x.rep;
}

inline bool URI::operator < (const URI &x) const { 
    if (rep == x.rep || x.rep == NULL) return false;
    if (rep == NULL) return true;
    if (rep->schema != x.rep->schema) return rep->schema < x.rep->schema;
    return *rep < *x.rep;
}
