6dbead1fb1f94b6684f4b7a330567ae62efcfef9
[platform/framework/native/json.git] / src / FWebJson_JsonWriterImpl.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                FWebJson_JsonWriterImpl.h
20  * @brief               This is the header file  for _JsonWriterImpl Class.
21  */
22
23 #ifndef _FWEB_JSON_INTERNAL_JSON_WRITER_IMPL_H_
24 #define _FWEB_JSON_INTERNAL_JSON_WRITER_IMPL_H_
25
26 #include <FBaseByteBuffer.h>
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
29
30 namespace Tizen { namespace Web { namespace Json
31 {
32 class IJsonValue;
33 class JsonWriter;
34 }}} // Tizen::Web::Json
35
36 namespace Tizen { namespace Web { namespace Json
37 {
38
39 class _JsonWriterImpl
40         : public Tizen::Base::Object
41 {
42 public:
43         /**
44          * This functionality is used to serialize json encoded data from JSON value to a string object
45          *
46          * @since                       2.0
47          * @param[in]       value                                        JSON value
48          * @param[out]      string              File path of JSON file
49          * @return                      An error code
50          * @exception           E_SUCCESS                       The method was successful.
51          * @exception           E_FAILURE                               In case of error.
52          */
53         static result Compose(const IJsonValue* pValue, Tizen::Base::String& filePath);
54
55         /**
56          * This functionality is used to serialize json encoded data from JSON value to a buffer
57          *
58          * @since                       2.0
59          * @param[in]       value                   A JSON encoded string.
60          * @param[in]           bufferLength                    Json encoded data buffer length.
61          * @param[out]      pBuffer                 Buffer with Json encoded data.
62          * @return                      An error code
63          * @exception           E_SUCCESS                       The method was successful.
64          * @exception           E_FAILURE                               In case of error.
65          */
66         static result Compose(const IJsonValue* pValue, void* pBuffer, int bufferLength);
67
68         /**
69          * This functionality is used to serialize json encoded data from JSON value to a byte buffer
70          *
71          * @since                       2.0
72          * @param[in]       value                   A JSON encoded string.
73          * @param[out]      buffer              Buffer with Json encoded data
74          * @return                      An error code
75          * @exception           E_SUCCESS                       The method was successful.
76          * @exception           E_FAILURE                               In case of error.
77          */
78         static result Compose(const IJsonValue* pValue, Tizen::Base::ByteBuffer& buffer);
79
80 private:
81         /**
82          * This is the default constructor for this class.
83          *
84          * @remarks             This constructor is hidden.
85          */
86         _JsonWriterImpl(void){}
87
88         /**
89          * This is the default destructor for this class.
90          *
91          * @remarks             This constructor is hidden.
92          */
93         virtual ~_JsonWriterImpl(void){}
94
95         static result ConvertIJsonToString(IJsonValue* pValue, Tizen::Base::String& outString);
96
97         static result ToEscString(const Tizen::Base::String& unEscStr, Tizen::Base::String& escString);
98
99 }; // _JsonWriterImpl
100
101 }}} // Tizen::Web::Json
102 #endif // _FWEBJSON_INTERNAL_JSON_WRITER_IMPL_H_