Scopira 20080306

url.h

00001 
00002 /*
00003  *  Copyright (c) 2004    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INLUCDED__SCOPIRA_TOOL_URL_H_
00015 #define __INLUCDED__SCOPIRA_TOOL_URL_H_
00016 
00017 #include <string>
00018 
00019 #include <scopira/tool/export.h>
00020 
00021 namespace scopira
00022 {
00023   namespace tool
00024   {
00025     class url;
00026 
00027     class itflow_i; //fwd
00028     class otflow_i; //fwd
00029     class oflow_i; //fwd
00030   }
00031 }
00032 
00045 class scopira::tool::url
00046 {
00047   protected:
00049     std::string dm_full;
00050 
00051     // the various components of the url
00052 
00054     std::string::size_type dm_proto_begin, dm_proto_end;
00056     std::string::size_type dm_host_begin, dm_host_end;
00058     int dm_port;
00060     std::string::size_type dm_file_begin, dm_file_end;
00061 
00062   public:
00067     SCOPIRA_EXPORT url(void);
00077     SCOPIRA_EXPORT url(const std::string &fullurl);
00083     SCOPIRA_EXPORT url(const std::string &hostname, int port);
00088     SCOPIRA_EXPORT url(const std::string &proto, const std::string &hostname, int port, const std::string &filename);
00093     SCOPIRA_EXPORT ~url();
00094 
00099     SCOPIRA_EXPORT bool load(scopira::tool::itflow_i& in);
00104     SCOPIRA_EXPORT void save(scopira::tool::otflow_i& out) const;
00105 
00110     SCOPIRA_EXPORT void clear_url(void);
00111 
00117     SCOPIRA_EXPORT bool set_url(const std::string &fullurl);
00123     SCOPIRA_EXPORT void set_url(const std::string &hostname, int port);
00128     SCOPIRA_EXPORT void set_url(const std::string &proto, const std::string &hostname, int port, const std::string &filename);
00129 
00134     const std::string & get_url(void) const { return dm_full; }
00135 
00140     SCOPIRA_EXPORT std::string get_proto(void) const;
00145     SCOPIRA_EXPORT std::string get_hostname(void) const;
00151     int get_port(void) const { return dm_port; }
00156     SCOPIRA_EXPORT std::string get_filename(void) const;
00157 };
00158 
00159 SCOPIRA_EXPORT scopira::tool::oflow_i& operator<<(scopira::tool::oflow_i& o, const scopira::tool::url& u);
00160 
00161 #endif
00162