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 
00151         static std::string escape(const std::string& str);
00152 
00163         static std::string escape(
00164                 const std::string& str,
00165                 const std::string& allowed,
00166                 bool is_allowed_sorted = false);
00167 
00174         static std::string unescape(const std::string& str);
00176 
00177 private:
00178          // only "http", "https", "ftp", and "secondlife" schemes are parsed
00179          // secondlife scheme parses authority as "" and includes it as part of
00180          // the path.  See lluri_tut.cpp
00181          // i.e. secondlife://app/login has mAuthority = "" and mPath = "/app/login"
00182         void parseAuthorityAndPathUsingOpaque();
00183         std::string mScheme;
00184         std::string mEscapedOpaque;
00185         std::string mEscapedAuthority;
00186         std::string mEscapedPath;
00187         std::string mEscapedQuery;
00188 };
00189 
00190 #endif // LL_LLURI_H

Generated on Fri May 16 08:32:09 2008 for SecondLife by  doxygen 1.5.5