lluri.h

Go to the documentation of this file.
00001 
00034 #ifndef LL_LLURI_H
00035 #define LL_LLURI_H
00036 
00037 #include <string>
00038 
00039 class LLSD;
00040 class LLUUID;
00041 class LLApp;
00042 
00049 class LLURI
00050 {
00051 public:
00052   LLURI();
00053   LLURI(const std::string& escaped_str);
00054   LLURI(const std::string& scheme,
00055                 const std::string& userName,
00056                 const std::string& password,
00057                 const std::string& hostName,
00058                 U16 hostPort,
00059                 const std::string& escapedPath,
00060                 const std::string& escapedQuery);
00061           
00062   // construct from escaped string, as would be transmitted on the net
00063 
00064         ~LLURI();
00065 
00066         static LLURI buildHTTP(
00067                 const std::string& prefix,
00068                 const LLSD& path);
00069 
00070         static LLURI buildHTTP(
00071                 const std::string& prefix,
00072                 const LLSD& path,
00073                 const LLSD& query);
00078 
00079         static LLURI buildHTTP(
00080                 const std::string& host,
00081                 const U32& port,
00082                 const LLSD& path);
00083         static LLURI buildHTTP(
00084                 const std::string& host,
00085                 const U32& port,
00086                 const LLSD& path,
00087                 const LLSD& query);
00088 
00089         std::string asString() const;
00091   
00094         // These functions return parts of the decoded URI.  The returned
00095         // strings are un-escaped as needed
00096   
00097         // for all schemes
00098         std::string scheme() const;             
00099         std::string opaque() const;             
00100   
00101   // for schemes that follow path like syntax (http, https, ftp)
00102   std::string authority() const;        // ex.: "host.com:80"
00103   std::string hostName() const; // ex.: "host.com"
00104   std::string userName() const;
00105   std::string password() const;
00106   U16 hostPort() const;                 // ex.: 80, will include implicit port
00107   BOOL defaultPort() const;             // true if port is default for scheme
00108   const std::string& escapedPath() const { return mEscapedPath; }
00109   std::string path() const;             // ex.: "/abc/def", includes leading slash
00110   //    LLSD pathArray() const;                 // above decoded into an array of strings
00111   std::string query() const;            // ex.: "x=34", section after "?"
00112   const std::string& escapedQuery() const { return mEscapedQuery; }
00113   LLSD queryMap() const;                        // above decoded into a map
00114   static LLSD queryMap(std::string escaped_query_string);
00115 
00124         static std::string mapToQueryString(const LLSD& query_map);
00125 
00128         // Escape a string by urlencoding all the characters that aren't
00129         // in the allowed string.
00130         static std::string escape(const std::string& str);
00131         static std::string escape(
00132                 const std::string& str,
00133                 const std::string & allowed); 
00134         static std::string unescape(const std::string& str);
00136 
00137 private:
00138         std::string mScheme;
00139         std::string mEscapedOpaque;
00140         std::string mEscapedAuthority;
00141         std::string mEscapedPath;
00142         std::string mEscapedQuery;
00143 };
00144 
00145 #endif // LL_LLURI_H

Generated on Thu Jul 1 06:09:24 2010 for Second Life Viewer by  doxygen 1.4.7