UDK 3.2.7 C/C++ API Reference

rtl/uri.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 
00020 #ifndef _RTL_URI_HXX_
00021 #define _RTL_URI_HXX_
00022 
00023 #include "rtl/malformeduriexception.hxx"
00024 #include "rtl/uri.h"
00025 #include "rtl/textenc.h"
00026 #include "rtl/ustring.hxx"
00027 #include "sal/types.h"
00028 
00029 namespace rtl {
00030 
00033 class Uri
00034 {
00035 public:
00039     static inline rtl::OUString encode(rtl::OUString const & rText,
00040                                        sal_Bool const * pCharClass,
00041                                        rtl_UriEncodeMechanism eMechanism,
00042                                        rtl_TextEncoding eCharset)
00043         SAL_THROW(());
00044 
00048     static inline rtl::OUString encode(rtl::OUString const & rText,
00049                                        rtl_UriCharClass eCharClass,
00050                                        rtl_UriEncodeMechanism eMechanism,
00051                                        rtl_TextEncoding eCharset)
00052         SAL_THROW(());
00053 
00056     static inline rtl::OUString decode(rtl::OUString const & rText,
00057                                        rtl_UriDecodeMechanism eMechanism,
00058                                        rtl_TextEncoding eCharset)
00059         SAL_THROW(());
00060 
00067     static inline rtl::OUString convertRelToAbs(
00068         rtl::OUString const & rBaseUriRef, rtl::OUString const & rRelUriRef);
00069 
00070 private:
00072     Uri();
00073 
00075     Uri(Uri &);
00076 
00078     ~Uri();
00079 
00081     void operator =(Uri);
00082 };
00083 
00084 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
00085                                  sal_Bool const * pCharClass,
00086                                  rtl_UriEncodeMechanism eMechanism,
00087                                  rtl_TextEncoding eCharset)
00088     SAL_THROW(())
00089 {
00090     rtl::OUString aResult;
00091     rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
00092                   pCharClass,
00093                   eMechanism,
00094                   eCharset,
00095                   &aResult.pData);
00096     return aResult;
00097 }
00098 
00099 inline rtl::OUString Uri::encode(rtl::OUString const & rText,
00100                                  rtl_UriCharClass eCharClass,
00101                                  rtl_UriEncodeMechanism eMechanism,
00102                                  rtl_TextEncoding eCharset)
00103     SAL_THROW(())
00104 {
00105     rtl::OUString aResult;
00106     rtl_uriEncode(const_cast< rtl::OUString & >(rText).pData,
00107                   rtl_getUriCharClass(eCharClass),
00108                   eMechanism,
00109                   eCharset,
00110                   &aResult.pData);
00111     return aResult;
00112 }
00113 
00114 inline rtl::OUString Uri::decode(rtl::OUString const & rText,
00115                                  rtl_UriDecodeMechanism eMechanism,
00116                                  rtl_TextEncoding eCharset)
00117     SAL_THROW(())
00118 {
00119     rtl::OUString aResult;
00120     rtl_uriDecode(const_cast< rtl::OUString & >(rText).pData,
00121                   eMechanism,
00122                   eCharset,
00123                   &aResult.pData);
00124     return aResult;
00125 }
00126 
00127 inline rtl::OUString Uri::convertRelToAbs(rtl::OUString const & rBaseUriRef,
00128                                           rtl::OUString const & rRelUriRef)
00129 {
00130     rtl::OUString aResult;
00131     rtl::OUString aException;
00132     if (!rtl_uriConvertRelToAbs(
00133             const_cast< rtl::OUString & >(rBaseUriRef).pData,
00134             const_cast< rtl::OUString & >(rRelUriRef).pData, &aResult.pData,
00135             &aException.pData))
00136         throw MalformedUriException(aException);
00137     return aResult;
00138 }
00139 
00140 }
00141 
00142 #endif // _RTL_URI_HXX_
00143 
00144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines