Enable build with iniparser v 3.1
[platform/framework/native/appfw.git] / inc / FBaseUtilUrlEncoder.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file                FBaseUtilUrlEncoder.h
19  * @brief               This is the header file for the %UrlEncoder class.
20  *
21  * This header file contains the declarations of the %UrlEncoder class.
22  */
23
24 #ifndef _FBASE_UTIL_URL_ENCODER_H_
25 #define _FBASE_UTIL_URL_ENCODER_H_
26
27 // includes
28 #include <FBaseString.h>
29
30
31 namespace Tizen { namespace Base { namespace Utility
32 {
33 /**
34  * @class       UrlEncoder
35  * @brief       This class provides a method for encoding a string using a specific encoding scheme.
36  *
37  * @since 2.0
38  *
39  * The %UrlEncoder class provides a method for encoding a string using a specific encoding scheme.
40  *
41  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/url_encoder_decoder.htm">UrlEncoder and UrlDecoder</a>.
42  *
43  * The following example demonstrates how to use the %UrlEncoder class.
44  *
45  * @code
46  *      #include <FBase.h>
47  *
48  *      using namespace Tizen::Base;
49  *      using namespace Tizen::Base::Utility;
50  *
51  *      void
52  *      MyClass::UrlEncoderSample(void)
53  *      {
54  *              result r = E_SUCCESS;
55  *              String str1(L"url encoding test?");
56  *              String str2;
57  *
58  *              // Encodes the input string
59  *              r = UrlEncoder::Encode(str1, L"UTF-8", str2);
60  *      }
61  * @endcode
62  */
63
64
65 class _OSP_EXPORT_ UrlEncoder
66 {
67 public:
68         /**
69         * Encodes the specified input string using the specified encoding scheme. @n
70         * It encodes all unsafe characters of a string.
71         *
72         * @since 2.0
73         *
74         * @return               An error code
75         * @param[in]    str                                                     An instance of String to encode
76         * @param[in]    encodingScheme                          The supported encoding scheme
77         * @param[out]   encodedStr                                      The encoded string
78         * @exception    E_SUCCESS                                       The method is successful.
79         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
80         * @exception    E_SYSTEM                                        A system error has occurred.
81         * @exception    E_UNSUPPORTED_TYPE              The specified encoding scheme is not supported.
82         * @exception    E_INVALID_ENCODING_RANGE        The specified string contains code points that are outside the bounds of the character encoding scheme.
83         * @remarks              This method is used for encoding. @n
84         *                               It encodes input string into an
85         *                               application/x-www-form-urlencoded format using a specific encoding scheme. @n
86         *                               This method uses the specified encoding scheme to obtain the bytes for unsafe characters.
87         * @see                  UrlDecoder
88         */
89         static result Encode(const Tizen::Base::String& str, const Tizen::Base::String& encodingScheme, Tizen::Base::String& encodedStr);
90
91 private:
92         /**
93         * This default constructor is intentionally declared as private so that only the platform can create an instance.
94         */
95         UrlEncoder(void);
96
97         /*
98          * This destructor is intentionally declared as private so that only the platform can delete an instance.
99          */
100         virtual ~UrlEncoder(void);
101
102         /**
103          * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
104          *
105          * @param[in]   rhs     An instance of %UrlEncoder
106          */
107         UrlEncoder(const UrlEncoder& rhs);
108
109         /**
110          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
111          *
112          * @param[in]   rhs     An instance of %UrlEncoder
113          */
114         UrlEncoder& operator =(const UrlEncoder& rhs);
115 }; // UrlEncoder
116
117 }}} // Tizen::Base::Utility
118 #endif // _FBASE_UTIL_URL_ENCODER_H_