sync with tizen_2.0
[platform/framework/native/appfw.git] / inc / FBaseUtilUrlEncoder.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FBaseUtilUrlEncoder.h
20  * @brief               This is the header file for the %UrlEncoder class.
21  *
22  * This header file contains the declarations of the %UrlEncoder class.
23  */
24
25 #ifndef _FBASE_UTIL_URL_ENCODER_H_
26 #define _FBASE_UTIL_URL_ENCODER_H_
27
28 // includes
29 #include <FBaseString.h>
30
31
32 namespace Tizen { namespace Base { namespace Utility
33 {
34 /**
35  * @class       UrlEncoder
36  * @brief       This class provides a method for encoding a string using a specific encoding scheme.
37  *
38  * @since 2.0
39  *
40  * The %UrlEncoder class provides a method for encoding a string using a specific encoding scheme.
41  *
42  * 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>.
43  *
44  * The following example demonstrates how to use the %UrlEncoder class.
45  *
46  * @code
47  *      #include <FBase.h>
48  *
49  *      using namespace Tizen::Base;
50  *      using namespace Tizen::Base::Utility;
51  *
52  *      void
53  *      MyClass::UrlEncoderSample(void)
54  *      {
55  *              result r = E_SUCCESS;
56  *              String str1(L"url encoding test?");
57  *              String str2;
58  *
59  *              // Encodes the input string
60  *              r = UrlEncoder::Encode(str1, L"UTF-8", str2);
61  *      }
62  * @endcode
63  */
64
65
66 class _OSP_EXPORT_ UrlEncoder
67 {
68 public:
69         /**
70         * Encodes an input string using a specific encoding scheme. @n
71         * It encodes all unsafe characters of a string.
72         *
73         * @since 2.0
74         *
75         * @return               An error code
76         * @param[in]    str                                                     An instance of String to encode
77         * @param[in]    encodingScheme                          The supported encoding scheme
78         * @param[out]   encodedStr                                      The encoded string
79         * @exception    E_SUCCESS                                       The method is successful.
80         * @exception    E_INVALID_ARG                           A specified input parameter is invalid.
81         * @exception            E_SYSTEM                                        A system error has occurred.
82         * @exception    E_UNSUPPORTED_TYPE              The specified encoding scheme is not supported.
83         * @exception    E_INVALID_ENCODING_RANGE        The specified string contains code points that are outside the bounds of the character encoding scheme.
84         * @remarks      This method is used for encoding. It encodes input string into an
85         * application/x-www-form-urlencoded     format using a specific encoding scheme. This method uses the specified
86         * 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_