Update the size check in MessagePort
[platform/framework/native/appfw.git] / inc / FBaseByteBuffer.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                FBaseByteBuffer.h
20  * @brief               This is the header file for the %ByteBuffer class.
21  *
22  * This header file contains the declarations of the %ByteBuffer class.
23  */
24
25 #ifndef _FBASE_BYTE_BUFFER_H_
26 #define _FBASE_BYTE_BUFFER_H_
27
28 #include <FBaseBufferBase.h>
29 #include <FBaseBuffer.h>
30
31
32 namespace Tizen { namespace Base
33 {
34
35 /**
36  * @class       ByteBuffer
37  * @brief       This class provides a contiguous sequence of the @c byte (@c unsigned @c char) built-in type.
38  *
39  * @since 2.0
40  *
41  * The %ByteBuffer class provides a means of encapsulating a sequence of bytes in memory. It defines
42  * methods to read and write all primitive built-in types (except @c bool), to and from a sequence of
43  * bytes. These methods read the size of primitive type bytes from a @c byte sequence and
44  * convert it to the actual primitive type.
45  *
46  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/buffer.htm">Buffer</a>.
47  *
48  * @see         Tizen::Base::BufferBase
49  *
50  * The following example demonstrates how to use the %ByteBuffer class.
51  *
52  * @code
53  *      #include <FBase.h>
54  *
55  *      using namespace Tizen::Base;
56  *
57  *      void
58  *      MyClass::ByteBufferSample(void)
59  *      {
60  *              // Defines the maximum buffer size : capacity
61  *              const int BUFFER_SIZE_MAX = 1024;
62  *
63  *              // Initializes a buf using the Construct method to the capacity
64  *              ByteBuffer buf;
65  *              buf.Construct(BUFFER_SIZE_MAX);
66  *
67  *              // Copies five values into the buf
68  *              for (int i = 0; i < 5; i++)
69  *              {
70  *                      byte b = 'A' + i;
71  *
72  *                      // Writes byte b to the current position of the buf
73  *                      buf.SetByte(b); // The position is incremented by one
74  *              }
75  *              // The position is moved to 5
76  *
77  *              // Flips the buf
78  *              buf.Flip();
79  *              // Now, position = 0 and limit = 5        
80  *
81  *              // Reads bytes from the buf using "relative access method"
82  *              while (buf.HasRemaining())
83  *              {
84  *                      byte b;
85  *
86  *                      // Reads byte b from the current position of the buf
87  *                      buf.GetByte(b); // The position is incremented by one
88  *              }
89  *
90  *
91  *              // Clears the buf
92  *              buf.Clear();
93  *              // The buf's position = 0 and limit = capacity
94  *
95  *              // Writes int values to the buf
96  *              for (int i = 0; i < 5; i++)
97  *              {
98  *                      // Writes int value at the current position
99  *                      buf.SetInt(i); // The position is incremented by sizeof(int)
100  *              }
101  *
102  *              // Flips the buf
103  *              buf.Flip();
104  *              // Now, position = 0 and limit = sizeof(int) * 5
105  *
106  *              // Creates a new view, IntBuffer.
107  *              // Capacity of intBuf = 5
108  *              // The content of intBuf is from the buf's position to the buf's limit
109  *              IntBuffer* pIntBuf = buf.AsIntBufferN();
110  *
111  *              // Tests whether the change in view buffer(IntBuffer) is visible in original buffer(ByteBuffer)
112  *              pIntBuf->Set(4, 9);
113  *
114  *              // Reads int values from the buf using "absolute access method"
115  *              for (int i = 0; i < 5; i++)
116  *              {
117  *                      int out;
118  *
119  *                      // Reads int value from the buf with the specified index.
120  *                      buf.GetInt((i * sizeof(int)), out);             // 0, 1, 2, 3, 9
121  *                                                                                                      //  The position is not changed
122  *              }
123  *
124  *              delete pIntBuf;
125  *
126  *      }
127  *
128  * @endcode
129  */
130 class _OSP_EXPORT_ ByteBuffer
131         : public BufferBase
132 {
133
134 public:
135         /**
136          * The object is not fully constructed after this constructor is called.
137          * For full construction, the Construct() method must be called right after calling this constructor.
138          *
139          * @since 2.0
140          *
141          * @remarks             After creating an instance of the %ByteBuffer class, one of the Construct() methods must be called explicitly to initialize this instance.
142          * @see                         Construct()
143          */
144         ByteBuffer(void);
145
146         /**
147          * This destructor overrides Tizen::Base::Object::~Object().
148          *
149          * @since 2.0
150          */
151         virtual ~ByteBuffer(void);
152
153         /**
154          * Initializes this instance of %ByteBuffer which is a view of the specified buffer. @n
155          * This is the copy constructor for the %ByteBuffer class.
156          *
157          * @since 2.0
158          *
159          * @param[in]   buffer          The %ByteBuffer instance used to initialize new object
160          * @exception   E_SUCCESS               The method is successful.
161          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or
162          *                                                              the source buffer is not constructed.
163          * @see                         ByteBuffer()
164          */
165         result Construct(const ByteBuffer& buffer);
166
167         /**
168          * Initializes this instance of %ByteBuffer with the specified @c capacity.
169          *
170          * @since 2.0
171          *
172          * @return              An error code
173          * @param[in]   capacity                The number of elements
174          * @exception   E_SUCCESS               The method is successful.
175          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or
176          *                                              the specified @c capacity is negative.
177          * @see                         ByteBuffer()
178          */
179         result Construct(int capacity);
180
181         /**
182         * Initializes this instance of %ByteBuffer with the specified @c buffer which is shared with this instance.
183         *
184         * @since 2.0
185         *
186         * @return           An error code
187         * @param[in]       pBuffer                The buffer which is shared
188         * @param[in]       index                  The starting index of the buffer from where the first @c byte value is read
189         * @param[in]       length                 The number of bytes to read from the given buffer @n This is a limit of this instance.
190         * @param[in]       capacity               The capacity of this instance
191         * @exception       E_SUCCESS           The method is successful.
192         * @exception       E_INVALID_ARG     A specified input parameter is invalid, or
193         *                                               the @c pBuffer is @c null.
194         * @exception       E_OUT_OF_RANGE  The specified index is outside the bounds of the data structure, or
195         *                                               the @c index is larger than the @c length.
196         */
197         result Construct(const byte *pBuffer, int index, int length, int capacity);
198
199         /**
200          * Gets the reference to the byte value at the specified index.
201          *
202          * @since 2.0
203          *
204          * @return              A reference to the @c byte value
205          * @param[in]   index   The index of the @c byte value in the calling %ByteBuffer instance @n
206          *                                              It must be less than the limit.
207          */
208         byte& operator [](int index);
209
210         /**
211          * Gets the byte value at the specified index of const object.
212          *
213          * @since 2.0
214          *
215          * @return              A value to the @c byte value
216          * @param[in]   index   The index of the @c byte value in the calling %ByteBuffer instance @n
217          *                                              It must be less than the limit.
218          */
219         byte operator [](int index) const;
220
221         /**
222          * Compares the two %ByteBuffer instances.
223          *
224          * @since 2.0
225          *
226          * @return              @c true if the input buffer is equal to the calling %ByteBuffer instance, @n
227          *                              else @c false
228          * @param[in]   buffer  The %ByteBuffer instance to compare with the current instance
229          * @remarks             This method returns @c true only if the two buffers have the same number of
230          *                                              remaining elements, and the two sequences of remaining elements are equal
231          *                                              (considered independently, irrespective of their starting positions).
232          * @see                         Equals()
233          */
234         bool operator ==(const ByteBuffer& buffer) const;
235
236         /**
237          * Checks whether the current instance and the specified instance of %ByteBuffer are not equal.
238          *
239          * @since 2.0
240          *
241          * @return              @c true if the two objects are not the same, @n
242          *                              else @c false
243          * @param[in]   buffer  The buffer to compare with the current instance
244          * @remarks             This method returns @c false only if the two buffers being compared have the same
245          *                                              number of remaining elements, and the two sequences of remaining elements are equal
246          *                                              (considered independently, irrespective of their starting positions).
247          * @see                         Equals()
248          */
249         bool operator !=(const ByteBuffer& buffer) const;
250
251         /**
252          * Creates a new @c double buffer view for the content of the byte buffer.
253          *      
254          * @since 2.0
255          *
256          * @return              DoubleBuffer A pointer to the current position of the calling object
257          * @remarks             The content of the view buffer starts at the current position of the calling buffer.
258          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
259          *                              are equal to the remaining part of this buffer divided by the size of @c double.
260          *                              Any change to the byte buffer content is visible in the @c double buffer view, and vice versa.
261          */
262         DoubleBuffer* AsDoubleBufferN(void) const;
263
264         /**
265          * Creates a new @c float buffer view for the content of the byte buffer.
266          *
267          * @since 2.0   
268          *
269          * @return              FloatBuffer A pointer to the current position of the calling buffer
270          * @remarks             The content of the view buffer starts at the current position of the calling buffer.
271          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
272          *                              are equal to the remaining part of the calling buffer divided by the size of @c float.
273          *                              Any change to the byte buffer content is visible in the @c float buffer view, and vice versa.
274          */
275         FloatBuffer* AsFloatBufferN(void) const;
276
277         /**
278          * Creates a new @c int buffer view for the content of the byte buffer.
279          *
280          * @since 2.0   
281          *
282          * @return              IntBuffer A pointer to the current position of the calling buffer
283          * @remarks             The content of the view buffer starts at the current position of the calling buffer.
284          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
285          *                              are equal to the remaining part of calling buffer divided by the size of @c int.
286          *                              Any change to the byte buffer content is visible in the Int buffer view, and vice versa.
287          */
288         IntBuffer* AsIntBufferN(void) const;
289
290         /**
291          * Creates a new @c long buffer view for the content of the byte buffer.
292          *
293          * @since 2.0   
294          *
295          * @return              LongBuffer A pointer to the current position of the calling buffer
296          * @remarks             The content of the view buffer starts at the current position of this buffer.
297          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
298          *                              are equal to the remaining part of calling buffer divided by the size of @c long.
299          *                              Any change to the byte buffer content is visible in the @c long buffer view, and vice versa.
300          */
301         LongBuffer* AsLongBufferN(void) const;
302
303         /**
304          * Creates a new @c long @c long buffer view for the content of the byte buffer.
305          *
306          * @since 2.0   
307          *
308          * @return              LongLongBuffer A pointer to the current position of the calling buffer
309          * @remarks             The content of the view buffer starts at the current position of this buffer.
310          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
311          *                              are equal to the remaining part of calling buffer divided by the size of @c long.
312          *                              Any change to the byte buffer content is visible in the @c long @c long buffer view, and vice versa.
313          */
314         LongLongBuffer* AsLongLongBufferN(void) const;
315
316         /**
317          * @if OSPDEPREC
318          * Creates a new @c mchar buffer view of the underlying content of the byte buffer.
319          *
320          * @brief       <i> [Deprecated] </i>
321          * @deprecated This method is deprecated as @c mchar type is changed to @c wchar_t type.
322          * Instead of using this method, use the AsWcharBufferN() method.
323          * @since 2.0   
324          *
325          * @return              McharBuffer A pointer to the current position of the calling buffer
326          * @remarks             The content of the view buffer starts at the current position of this buffer.
327          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
328          *                              are equal to the remaining part of the calling buffer divided by the size of @c long.
329          *                              Any change to the byte buffer content is visible in the @c mchar buffer view, and vice versa.
330          * @endif
331          */
332         McharBuffer* AsMcharBufferN(void) const;
333
334         /**
335          * Creates a new wchar Buffer view of the underlying content of the byte buffer.
336          *
337          * @since 2.0
338          *
339          * @return              WcharBuffer pointer to the current position of the calling buffer
340          * @remarks             The content of the view buffer start at the current position of this buffer. @n
341          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
342          *                              are equal to the remaining part of the calling buffer divided by the size of @c long. @n
343          *                              Any changes to the calling buffer's content (that is, the content of %ByteBuffer instance) @n
344          *                              are visible in the WcharBuffer view, and vice versa.
345          */
346         WcharBuffer* AsWcharBufferN(void) const;
347
348         /**
349          * Creates a new @c short buffer view for the content of the byte buffer.
350          *
351          * @since 2.0
352          *
353          * @return              ShortBuffer pointer to the current position of the calling buffer
354          * @remarks             The content of the view buffer starts at the current position of this buffer.
355          *                              The new buffer's position is zero, the mark is undefined, and the capacity and limit
356          *                              are equal to the remaining part of calling buffer divided by the size of @c long.
357          *                              Any change to the byte buffer content is visible in the @c short buffer view, and vice versa.
358          */
359         ShortBuffer* AsShortBufferN(void) const;
360
361         /**
362          * Copies the remaining bytes of the input %ByteBuffer instance into the calling %ByteBuffer object. @n
363          * It returns E_OVERFLOW if the remaining bytes in the current instance are less
364          * than the remaining bytes in the input instance.
365          *
366          * @since 2.0
367          *
368          * @return              An error code
369          * @param[in]   buffer          The source buffer from which bytes are read @n
370          *                                                      It must not be the calling object.
371          * @exception   E_SUCCESS               The method is successful.
372          * @exception   E_INVALID_ARG   A specified input parameter is invalid. @n
373          *                                                              The source buffer is same as destination buffer,
374          *                                                              that is, the current instance of the buffer.
375          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow. @n
376          *                                                              The number of remaining bytes of the current buffer is smaller than
377          *                                                              the number of remaining bytes of the input buffer.
378          * @remarks             After the copy operation, the current (destination) buffer's position and the given
379          *                              (source) buffer's positions are incremented by the number of bytes copied (the number of
380          *                              remaining bytes of the given buffer). @n
381          *                              If the remaining part of the current instance is greater than or equal to the remaining part of the input instance,
382          *                              the effect of this method and the ReadFrom(%ByteBuffer) method is the same. But when the remaining part of the
383          *                              current instance is less, the ReadFrom() method copies the number of remaining elements of the current
384          *                              instance while this method returns E_OVERFLOW and does not copy.
385          * @see                 ReadFrom()
386          *
387          * The following example demonstrates how to use the %CopyFrom() method.
388          *
389          * @code
390          *
391          *      // Creates instances of ByteBuffer to act as source and destination buffers
392          *      ByteBuffer srcBuf;
393          *      ByteBuffer destBuf;
394          *
395          *      // Declares an array of byte values
396          *      byte pArray[] = {'A','B','C','D','E','F','G','H','I','J'};
397          *
398          *      // Initializes the source array with a capacity of ten elements.
399          *      srcBuf.Construct(10);
400          *
401          *      // Copies the ten values from pArray starting at position 0 to the srcBuf
402          *      // Now, srcBuf's position = 10
403          *      srcBuf.SetArray(pArray, 0, 10);
404          *
405          *      // Flips the buffer: The limit is set to the current position and
406          *      // then the position is set to zero
407          *      srcBuf.Flip();                  // srcBuf's position = 0 and limit = 10
408          *
409          *
410          *      destBuf.Construct(20);
411          *
412          *      // Copies from the srcBuf to the destBuf
413          *      // Now, srcBuf's position = 10, the destBuf's position = 10
414          *      destBuf.CopyFrom(srcBuf);
415          *
416          * @endcode
417          *
418          * The following example has exactly the same effect as the above %CopyFrom() method.
419          *
420          * @code
421          *      
422          *      int copyNum = srcBuf.GetRemaining();
423          *      for (int i = 0; i < copyNum; i++)
424          *      {
425          *              byte b;
426          *
427          *              // Reads from source buffer
428          *              srcBuf.GetByte(b);                      // The srcBuf position is incremented by 1
429          *
430          *              // Writes to destination buffer
431          *              destBuf.SetByte(b);                     // The destBuf position is incremented by 1
432          *
433          *      }
434          * @endcode
435          */
436         result CopyFrom(ByteBuffer& buffer);
437
438         /**
439          * Gets the specified number of bytes from the current instance of %ByteBuffer.
440          *
441          * @since 2.0
442          *
443          * @return              An error code
444          * @param[out]  pArray          A pointer to the destination array into which the bytes are written
445          * @param[in]   index           The starting index in the array of the first byte to write
446          * @param[in]   length          The number of bytes to write to the given array
447          * @exception   E_SUCCESS               The method is successful.
448          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or
449          *                                                              the @c pArray is @c null.
450          * @exception   E_OUT_OF_RANGE  A specified input parameter is invalid. @n
451          *                                                              The @c index or @c length is less than @c 0.
452          * @exception   E_UNDERFLOW             The operation (arithmetic/casting/conversion) has caused an underflow, or
453          *                                                              the remaining bytes of this buffer are smaller than @c length.
454          * @remarks             This method copies @c length bytes from the current instance of %ByteBuffer to the given array,
455          *                              starting at the current position and at the given index in the array.
456          *                              After the copy operation, the position is incremented by @c length bytes.
457          * @see                 SetArray()
458          */
459         result GetArray(byte* pArray, int index, int length);
460
461         /**
462          * Gets the @c byte value from the buffer at the current position, and then increments the position. @n
463          * Provides a way for relative indexing and reading.
464          *
465          * @since 2.0
466          *
467          * @return              An error code
468          * @param[out]  value           The @c byte value at the current position in the %ByteBuffer instance
469          * @exception   E_SUCCESS               The method is successful.
470          * @exception   E_UNDERFLOW             The operation (arithmetic/casting/conversion) has caused an underflow, or
471          *                                                              the current position is not smaller than the limit.
472          * @see                 SetByte()
473          */
474         result GetByte(byte& value);
475
476         /**
477          * Gets the @c byte value at the given index. @n
478          * Provides a way for absolute indexing and reading.
479          *
480          * @since 2.0
481          *
482          * @return              An error code
483          * @param[in]   index           The index of the current %ByteBuffer instance, from which the byte is read
484          * @param[out]  value           The @c byte value at the given @c index
485          * @exception   E_SUCCESS               The method is successful.
486          * @exception   E_OUT_OF_RANGE  The specified index is outside the bounds of the data structure, or
487          *                                                              the @c index is not smaller than the limit or less than @c 0.
488          * @see                 SetByte()
489          */
490         result GetByte(int index, byte& value) const;
491
492         /**
493          * Gets the size of @c double number of bytes from the buffer at the current position, converts
494          * it to the corresponding @c double equivalent, and then increments the position. @n
495          * Provides a way for relative indexing and reading.
496          *
497          * @since 2.0
498          *
499          * @return              An error code
500          * @param[out]  value           The @c double value at the current position in the %ByteBuffer instance
501          * @exception   E_SUCCESS               The method is successful.
502          * @exception   E_UNDERFLOW             The operation (arithmetic/casting/conversion) has caused an underflow, or
503          *                                                              the remaining bytes of this buffer are smaller than the size of @c double.
504          * @remarks             This method reads the next size of @c double number of bytes at the current position,
505          *                              composing it into a @c double value, and then increments the position by the size of @c double.
506          * @see                 SetDouble()
507          */
508         result GetDouble(double& value);
509
510         /**
511          * Gets the size of @c double number of bytes at the given index and converts it to the equivalent @c double value. @n
512          * Provides a way for absolute indexing and reading.
513          *
514          * @since 2.0
515          *
516          * @return              An error code
517          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
518          * @param[out]  value           The @c double value at the given index
519          * @exception   E_SUCCESS                       The method is successful.
520          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the data structure, or
521          *                                                                      the @c index is larger than the limit minus size of @c double or less than @c 0.
522          * @remarks             This method reads size of @c double number of bytes at the given index,
523          *                              composing them into a @c double value.
524          * @see                 SetDouble()
525          */
526         result GetDouble(int index, double& value) const;
527
528         /**
529          * Gets the size of @c float number of bytes from the buffer at the current position, converts
530          * it to the corresponding @c float equivalent, and then increments the position. @n
531          * Provides a way for relative indexing and reading.
532          *
533          * @since 2.0
534          *
535          * @return              An error code
536          * @param[out]  value           The @c float value at the current position in the %ByteBuffer instance
537          * @exception   E_SUCCESS                       The method is successful.
538          * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow, or
539          *                                                                      the remaining bytes of this buffer are smaller than the size of @c float.
540          * @remarks             This method reads the next size of @c float number of bytes at the current position,
541          *                              composing it into a @c float value, and then increments the position by the size of @c float.
542          * @see                 SetFloat()
543          */
544         result GetFloat(float& value);
545
546         /**
547          * Gets the size of @c float number of bytes at the given index and converts it to equivalent @c float value. @n
548          * Provides a way for absolute indexing and reading.
549          *
550          * @since 2.0
551          *
552          * @return              An error code
553          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
554          * @param[out]  value           The @c float value at the given index
555          * @exception   E_SUCCESS                       The method is successful.
556          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
557          *                                                                      the @c index is larger than the limit minus size of @c float or less than @c 0.
558          * @remarks             This method reads the size of @c float number of bytes at the given index,
559          *                              composing it into a @c float value.
560          * @see                 SetFloat()
561          */
562         result GetFloat(int index, float& value) const;
563
564         /**
565          * Gets the size of @c int number of bytes from the buffer at the current position, converts
566          * it to the corresponding @c int equivalent, and then increments the position. @n
567          * Provides a way for relative indexing and reading.
568          *
569          * @since 2.0
570          *
571          * @return              An error code
572          * @param[out]  value           The @c int value at the current position in the %ByteBuffer instance
573          * @exception   E_SUCCESS                       The method is successful.
574          * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow, or
575          *                                                                      the remaining bytes of this buffer are smaller than the size of @c int.
576          * @remarks             This method reads the next size of @c int number of bytes at the current position,
577          *                              composing them into an @c int value, and then increments the position by the size of @c int.
578          * @see                 SetInt()
579          */
580         result GetInt(int& value);
581
582         /**
583          * Gets the size of @c int number of bytes at the given index and converts it to the equivalent @c int value. @n
584          * Provides a way for absolute indexing and reading.
585          *
586          * @since 2.0
587          *
588          * @return              An error code
589          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
590          * @param[out]  value           The @c int value at the given index
591          * @exception   E_SUCCESS                       The method is successful.
592          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
593          *                                                                      the @c index is larger than the limit minus size of @c int or negative.
594          * @remarks             This method reads the size of @c int number of bytes at the given index,
595          *                              composing it into an @c int value.
596          * @see                 SetInt()
597          */
598         result GetInt(int index, int& value) const;
599
600         /**
601          * Gets the size of @c long number of bytes from the buffer at the current position, converts
602          * it to the corresponding @c long equivalent, and then increments the position. @n
603          * Provides a way for relative indexing and reading.
604          *
605          * @since 2.0
606          *
607          * @return              An error code
608          * @param[out]  value           The @c long value at the current position in the %ByteBuffer instance
609          * @exception   E_SUCCESS                       The method is successful.
610          * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow, or
611          *                                                                      the remaining bytes of this buffer are smaller than the size of @c long.
612          * @remarks             This method reads the next size of @c long number of bytes at the current position,
613          *                              composing it into a @c long value, and then increments the position by the size of @c long.
614          * @see                 SetLong()
615          */
616         result GetLong(long& value);
617
618         /**
619          * Gets the size of @c long number of bytes at the given index and converts it to equivalent @c long value. @n
620          * Provides a way for absolute indexing and reading.
621          *
622          * @since 2.0
623          *
624          * @return              An error code
625          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
626          * @param[out]  value           The @c long value at the given index
627          * @exception   E_SUCCESS                       The method is successful.
628          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the data structure, or
629          *                                                                      the @c index is larger than the limit minus size of @c long or less than @c 0.
630          * @remarks             This method reads the size of @c long number of bytes at the given index,
631          *                              composing it into a @c long value.
632          * @see                 SetLong()
633          */
634         result GetLong(int index, long& value) const;
635
636         /**
637          * Gets the size of @c long @c long number of bytes from the buffer at the current position, converts
638          * it to the corresponding @c long @c long equivalent, and then increments the position. @n
639          * Provides a way for relative indexing and reading.
640          *
641          * @since 2.0
642          *
643          * @return              An error code
644          * @param[out]  value           The @c long @c long value at the current position in the %ByteBuffer instance
645          * @exception   E_SUCCESS                       The method is successful.
646          * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow, or
647          *                                                                      the remaining bytes of this buffer are smaller than the size of @c long @c long.
648          * @remarks             This method reads the next size of @c long @c long number of bytes at the current position,
649          *                              composing it into a @c long @c long value, and then increments the position by the size of @c long @c long.
650          * @see                 SetLongLong()
651          */     
652         result GetLongLong(long long& value);
653
654         /**
655          * Gets the size of @c long @c long number of bytes at the given index and converts it to the equivalent @c long @c long value. @n
656          * Provides a way for absolute indexing and reading.
657          *
658          * @since 2.0
659          *
660          * @return              An error code
661          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
662          * @param[out]  value           The @c long @c long value at the given index
663          * @exception   E_SUCCESS                       The method is successful.
664          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
665          *                                                                      the @c index is larger than the limit minus size of @c long @c long or less than @c 0.
666          * @remarks             This method reads the size of @c long @c long number of bytes at the given index,
667          *                              composing it into a @c long @c long value.
668          * @see                 SetLongLong()
669          */
670         result GetLongLong(int index, long long& value) const;
671
672         /**
673          * @if OSPDEPREC
674          * Gets the size of @c wchar_t number of bytes from the buffer at the current position, converts
675          * it to the corresponding @c wchar_t equivalent, and then increments the position. @n
676          * Provides a way for relative indexing and reading.
677          *
678          * @brief       <i> [Deprecated] </i>
679          * @deprecated This method is deprecated as @c mchar type is changed to @c wchar_t type.
680          * Instead of using this method, use the GetWchar(wchar_t& value) method.
681          * @since 2.0
682          *
683          * @return              An error code
684          * @param[out]  value       The @c wchar_t value at the current position in the %ByteBuffer instance
685          * @exception   E_SUCCESS               The method is successful.
686          * @exception   E_UNDERFLOW             The operation (arithmetic/casting/conversion) has caused an underflow, or
687          *                                                              the remaining bytes of this buffer are smaller than the size of @c wchar_t.
688          * @remarks             This method reads the next size of @c wchar_t number of bytes at the current position,
689          *                              composing it into a @c wchar_t value, and then increments the position by the size of @c wchar_t.
690          * @see                 SetMchar()
691          * @endif
692          */
693         result GetMchar(wchar_t& value);
694
695         /**
696          * Gets the size of @c wchar_t number of bytes from the buffer at the current position, converts
697          * it to the corresponding @c wchar_t equivalent, and then increments the position. @n
698          * Provides a way for relative indexing and reading.
699          *
700          * @since 2.0
701          *
702          * @return      An error code
703          * @param[out]  value       The @c wchar_t value at the current position in the %ByteBuffer instance
704          * @exception   E_SUCCESS               The method is successful.
705          * @exception   E_UNDERFLOW          The operation (arithmetic/casting/conversion) has caused an underflow, or
706          *                                                              the remaining bytes of this buffer are smaller than the size of @c wchar_t.
707          * @remarks             This method reads the next size of @c wchar_t number of bytes at the current position,
708          *                              composing it into a @c wchar_t value, and then increments the position by the size of @c wchar_t.
709          * @see                 SetWchar()
710          */
711         result GetWchar(wchar_t& value);
712
713         /**
714          * @if OSPDEPREC
715          * Provides a way for absolute indexing and reading. @n
716          * It reads the size of @c wchar_t number of bytes at the given index and converts it to equivalent @c wchar_t value.
717          *
718          * @brief       <i> [Deprecated] </i>
719          * @deprecated This method is deprecated as @c mchar type is changed to @c wchar_t type.
720          * Instead of using this method, use the GetWchar(int index, wchar_t& value) method.
721          * @since 2.0
722          *
723          * @return              An error code
724          * @param[in]   index       The index of the current %ByteBuffer instance, from which the bytes are read
725          * @param[out]  value       The @c wchar_t value at the given index
726          * @exception   E_SUCCESS                       The method is successful.
727          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
728          *                                                                      the @c index is larger than the limit minus size of @c wchar_t or less than @c 0.
729          * @remarks             This method reads the size of @c wchar_t number of bytes at the given index,
730          *                              composing it into a @c wchar_t value.
731          * @see                 SetMchar()
732          * @endif
733          */
734         result GetMchar(int index, wchar_t& value) const;
735
736         /**
737          * Provides a way for absolute indexing and reading. @n
738          * It reads the size of @c wchar_t number of bytes at the given index and converts it to equivalent @c wchar_t value.
739          *
740          * @since 2.0
741          *
742          * @return              An error code
743          * @param[in]   index      The index of the current %ByteBuffer instance, from which the bytes are read
744          * @param[out]  value      The @c wchar_t value at the given index
745          * @exception   E_SUCCESS                       The method is successful.
746          * @exception   E_OUT_OF_RANGE                  The specified index is outside the bounds of the data structure, or
747          *                                                                      the @c index is larger than the limit minus size of @c wchar_t or less than @c 0.
748          * @remarks             This method reads the size of @c wchar_t number of bytes at the given index,
749          *                              composing it into a @c wchar_t value.
750          * @see                 SetWchar()
751          */
752         result GetWchar(int index, wchar_t& value) const;
753
754         /**
755          * Gets the size of @c short number of bytes from the buffer at the current position, converts
756          * it to the corresponding @c short equivalent, and then increments the position. @n
757          * Provides a way for relative indexing and reading.
758          *
759          * @since 2.0
760          *
761          * @return              An error code
762          * @param[out]  value           The @c short value at the current position in the %ByteBuffer instance
763          * @exception   E_SUCCESS                       The method is successful.
764          * @exception   E_UNDERFLOW                     The operation (arithmetic/casting/conversion) has caused an underflow, or
765          *                                                                      the remaining bytes of this buffer are smaller than the size of @c short.
766          * @remarks             This method reads the next size of @c short number of bytes at the current position,
767          *                              composing it into a @c short value, and then increments the position by the size of @c short.
768          * @see                 SetShort()
769          */
770         result GetShort(short& value);
771
772         /**
773          * Gets the size of @c short number of bytes at the given index and converts it to the equivalent @c short value. @n
774          * Provides a way for absolute indexing and reading.
775          *
776          * @since 2.0
777          *
778          * @return              An error code
779          * @param[in]   index           The index of the current %ByteBuffer instance, from which the bytes are read
780          * @param[out]  value           The @c short value at the given index
781          * @exception   E_SUCCESS                       The method is successful.
782          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
783          *                                                                      the @c index is larger than the limit minus size of @c short or less than @c 0.
784          * @remarks             This method reads the size of @c short number of bytes at the given index,
785          *                              composing it into a @c short value.
786          * @see                 SetShort()
787          */
788         result GetShort(int index, short& value) const;
789
790         /**
791          * Copies the remaining bytes of the input %ByteBuffer instance into the calling %ByteBuffer instance
792          * if the remaining part of the current instance is greater than or equal to the remaining part of the input instance. @n
793          * Otherwise, the number of bytes copied is equal to the number of remaining elements of the current instance.
794          *
795          * @since 2.0
796          *
797          * @return              An error code
798          * @param[in]   buffer          The source buffer from which bytes are read @n
799          *                                                      It must not be the calling %ByteBuffer instance.
800          * @exception   E_SUCCESS               The method is successful.
801          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
802          *                                                              
803          * @remarks             After the copy operation, the current (destination) buffer's position and the given
804          *                              (source) buffer's position are  incremented by the number of elements copied (the lesser of
805          *                              the number of elements remaining in the current buffer and the given buffer). @n
806          *                              If the remaining part of the current instance is greater than or equal to the remaining part of the input instance,
807          *                              the effect of this method is the same as the CopyFrom() method. But when the remaining part of the
808          *                              current instance is less, the CopyFrom() method returns E_OVERFLOW and does not transfer;
809          *                              whereas this method copies the number of remaining elements of the current instance.
810          * @see                 CopyFrom()
811          *
812          * The following example demonstrates how to use the %ReadFrom() method.
813          *
814          * @code
815          *
816          *      // Creates instances of %ByteBuffer to act as source and destination buffers
817          *      ByteBuffer srcBuf;
818          *      ByteBuffer destBuf;
819          *
820          *      // Declares an array of byte values
821          *      byte pArray[] = {'A','B','C','D','E','F','G','H','I','J'};
822          *
823          *      // Initializes the source array with capacity of ten elements.
824          *      srcBuf.Construct(10);
825          *
826          *      // Copies the 10 values from pArray starting at position 0 to srcBuf
827          *      // Now, srcBuf's position = 10
828          *      srcBuf.SetArray(pArray, 0, 10);
829          *
830          *      // Flips the buffer: The limit is set to the current position and
831          *      // then the position is set to zero
832          *      srcBuf.Flip();  // srcBuf's position = 0 and limit = 10
833          *
834          *      // Initializes the destination buffer with capacity of ten elements
835          *      destBuf.Construct(10);
836          *
837          *      // Sets the limit of destBuf to 5
838          *      destBuf.SetLimit(5);
839          *
840          *      // Reads from the srcBuf to the destBuf
841          *      // The destBuf's remaining is 5, smaller than the srcBuf's (10)
842          *      // Therefore, five elements are transferred
843          *      // srcBuf's position = 5, destBuf's position = 5
844          *      destBuf.ReadFrom(srcBuf);
845          *
846          *
847          * @endcode
848          *
849          * The following example has exactly the same effect as the above %ReadFrom() method.
850          *
851          * @code
852          *
853          *      int copyNum = (destBuf.GetRemaining() < srcBuf.GetRemaing())? destBuf.GetRemaining() : srcBuf.GetRemaining();
854          *      for (int i = 0; i < copyNum; i++)
855          *      {
856          *              byte b;
857          *
858          *              // Reads from the source buffer
859          *              srcBuf.GetByte(b); // The srcBuf position is incremented by 1
860          *
861          *              // Writes to the destination buffer
862          *              destBuf.SetByte(b);     // The destBuf position is incremented by 1
863          *
864          *      }
865          *
866          * @endcode
867          */
868         result ReadFrom(ByteBuffer& buffer);
869
870         /**
871          * Sets the @c byte values on the specified array to the current instance of %ByteBuffer.
872          *
873          * @since 2.0
874          *
875          * @return              An error code
876          * @param[in]   pArray          The array from which bytes are read
877          * @param[in]   index           The starting index of the array from where the first @c byte value is read
878          * @param[in]   length          The number of bytes to read from the given array
879          * @exception   E_SUCCESS               The method is successful.
880          * @exception   E_INVALID_ARG   A specified input parameter is invalid, or
881          *                                                              the @c pArray is @c null.
882          * @exception   E_OUT_OF_RANGE  The specified index is outside the bounds of the data structure, or
883          *                                                              the @c index or length is less than @c 0.
884          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
885          *                                                              the remaining bytes are smaller than @c length.
886          * @remarks             This method copies the specified number (@c length) of @c byte values into
887          *                              the calling object of buffer from the source array,
888          *                              starting from the current position, and at the given index in the array.
889          *                              After the copy operation, the position is incremented by @c length.
890          * @see                 GetArray()
891          */
892         result SetArray(const byte* pArray, int index, int length);
893
894         /**
895          * Sets the given @c byte value into the calling %ByteBuffer object
896          * at the current position, and then increments the position. @n
897          * Provides a way for relative indexing and writing.
898          *
899          * @since 2.0
900          *
901          * @return              An error code
902          * @param[in]   value           The @c byte value to write to the current instance of %ByteBuffer
903          * @exception   E_SUCCESS               The method is successful.
904          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
905          *                                                              the current position is not smaller than the limit.
906          * @see                 GetByte()
907          */
908         result SetByte(byte value);
909
910         /**
911          * Sets the given @c byte value into the calling %ByteBuffer object at the specified index. @n
912          * Provides a way for absolute indexing and writing.
913          *
914          * @since 2.0
915          *
916          * @return              An error code
917          * @param[in]   index           The index of the current instance of %ByteBuffer at which the byte is written
918          * @param[in]   value           The @c byte value to write
919          * @exception   E_SUCCESS                       The method is successful.
920          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
921          *                                                                      the @c index is not smaller than the limit or less than @c 0.
922          * @see                 GetByte()
923          */
924         result SetByte(int index, byte value);
925
926         /**
927          * Sets the given @c double value into the calling %ByteBuffer object
928          * at the current position, and then increments the position. @n
929          * Provides a way for relative indexing and writing.
930          *
931          * @since 2.0
932          *
933          * @return              An error code
934          * @param[in]   value           The @c double value to write
935          * @exception   E_SUCCESS               The method is successful.
936          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
937          *                                                              the remaining bytes of this buffer are smaller than the size of @c double.
938          * @remarks             This method writes the size of @c double number of bytes containing the given @c double value
939          *                              into the calling buffer, at the current position, and then increments the position by the size of @c double.
940          * @see                 GetDouble()
941          */
942         result SetDouble(double value);
943
944         /**
945          * Sets the given @c float value into the calling %ByteBuffer object
946          * at the current position, and then increments the position. @n
947          * Provides a way for relative indexing and writing.
948          *
949          * @since 2.0
950          *
951          * @return              An error code
952          * @param[in]   value           The @c float value to write
953          * @exception   E_SUCCESS               The method is successful.
954          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
955          *                                                              the remaining bytes of this buffer are smaller than the size of @c float.
956          * @remarks             This method writes the size of @c float number of bytes containing the given @c float value
957          *                              into this buffer at the current position, and then increments the position by the size of @c float.
958          * @see                 GetFloat()
959          */
960         result SetFloat(float value);
961
962         /**
963          * Sets the given @c int value into the calling %ByteBuffer instance at the current
964          * position, and then increments the position. @n
965          * Provides a way for relative indexing and writing.
966          *
967          * @since 2.0
968          *
969          * @return              An error code
970          * @param[in]   value   The @c int value to write
971          * @exception   E_SUCCESS               The method is successful.
972          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
973          *                                                              the remaining bytes of this buffer are smaller than the size of @c int.
974          * @remarks             This method writes the size of @c int number of bytes containing the given @c int value
975          *                              into this buffer at the current position, and then increments the position by the size of @c int.
976          * @see                 GetInt()
977          */
978         result SetInt(int value);
979
980         /**
981          * Sets the given @c long value into the calling %ByteBuffer instance at the current
982          * position, and then increments the position. @n
983          * Provides a way for relative indexing and writing.
984          *
985          * @since 2.0
986          *
987          * @return              An error code
988          * @param[in]   value           The @c long value to write
989          * @exception   E_SUCCESS               The method is successful.
990          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
991          *                                                              the remaining bytes of this buffer are smaller than size of @c long.
992          * @remarks             This method writes the size of @c long number of bytes containing the given @c long value
993          *                              into this buffer at the current position, and then increments the position by the size of @c long.
994          * @see                 GetLong()
995          */
996         result SetLong(long value);
997
998         /**
999          * Sets the given @c long @c long value into the calling %ByteBuffer object at the current
1000          * position, and then increments the position. @n
1001          * Provides a way for relative indexing and writing.
1002          *
1003          * @since 2.0
1004          *
1005          * @return              An error code
1006          * @param[in]   value           The @c long @c long value to write
1007          * @exception   E_SUCCESS               The method is successful.
1008          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
1009          *                                                              the remaining bytes of this buffer are smaller than the size of @c long @c long.
1010          * @remarks             This method writes the size of @c long @c long number of bytes containing the given @c long @c long value
1011          *                              into this buffer at the current position, and then increments the position by the size of @c long @c long.
1012          * @see                 GetLongLong()
1013          */
1014         result SetLongLong(long long value);
1015
1016         /**
1017          * @if OSPDEPREC
1018          * Sets the given @c wchar_t value into the calling %ByteBuffer object at the current
1019          * position, and then increments the position. @n
1020          * Provides a way for relative indexing and writing.
1021          *
1022          * @brief       <i> [Deprecated] </i>
1023          * @deprecated This method is deprecated as @c mchar type is changed to @c wchar_t type.
1024          * Instead of using this method, use the SetWchar(wchar_t value) method.
1025          * @since 2.0
1026          *
1027          * @return              An error code
1028          * @param[in]   value           The @c wchar_t value to write
1029          * @exception   E_SUCCESS               The method is successful.
1030          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
1031          *                                                              the remaining bytes of this buffer are smaller than size of @c wchar_t.
1032          * @remarks             This method writes the size of @c wchar_t number of bytes containing the given @c wchar_t value
1033          *                              into this buffer at the current position, and then increments the position by the size of @c wchar_t.
1034          * @see                 GetMchar()
1035          * @endif
1036          */
1037         result SetMchar(wchar_t value);
1038
1039         /**
1040          * Sets the given @c wchar_t value into the calling %ByteBuffer object at the current
1041          * position, and then increments the position. @n
1042          * Provides a way for relative indexing and writing.
1043          *
1044          * @since 2.0
1045          *
1046          * @return              An error code
1047          * @param[in]   value                   The @c wchar_t value to write
1048          * @exception   E_SUCCESS               The method is successful.
1049          * @exception   E_OVERFLOW      The operation (arithmetic/casting/conversion) has caused an overflow, or
1050          *                                                              the remaining bytes of this buffer are smaller than size of @c wchar_t.
1051          * @remarks             This method writes the size of @c wchar_t number of bytes containing the given @c wchar_t value
1052          *                              into this buffer at the current position, and then increments the position by the size of @c wchar_t.
1053          * @see                 GetWchar()
1054          */
1055         result SetWchar(wchar_t value);
1056
1057         /**
1058          * Sets the given @c short value into the current instance of %ByteBuffer at the current
1059          * position, and then increments the position. @n
1060          * Provides a way for relative indexing and writing.
1061          *
1062          * @since 2.0
1063          *
1064          * @return              An error code
1065          * @param[in]   value           The @c short value to write
1066          * @exception   E_SUCCESS               The method is successful.
1067          * @exception   E_OVERFLOW              The operation (arithmetic/casting/conversion) has caused an overflow, or
1068          *                                                              the remaining bytes of this buffer are smaller than the size of @c short.
1069          * @remarks             This method writes the size of @c short number of bytes containing the given @c short value
1070          *                              into this buffer at the current position, and then increments the position by the size of @c short.
1071          * @see                 GetShort()
1072          */
1073         result SetShort(short value);
1074
1075         /**
1076          * Sets a @c double value at the specified index of the current instance of %ByteBuffer. @n
1077          * Provides a way for absolute indexing and writing.
1078          *
1079          * @since 2.0
1080          *
1081          * @return              An error code
1082          * @param[in]   index           The index of current instance of %ByteBuffer at which the bytes are written
1083          * @param[in]   value           The @c double value to write
1084          * @exception   E_SUCCESS                       The method is successful.
1085          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1086          *                                                                      the @c index is larger than the limit minus the size of @c double or less than @c 0.
1087          * @remarks             This method writes the size of @c double number of bytes containing the given @c double value
1088          *                              into this buffer at the given index.
1089          * @see                 GetDouble()
1090          */
1091         result SetDouble(int index, double value);
1092
1093         /**
1094          *  Sets a @c float value at the specified index of the calling %ByteBuffer object. @n
1095          *  Provides a way for absolute indexing and writing.
1096          *
1097          * @since 2.0
1098          *
1099          * @return              An error code
1100          * @param[in]   index           The index of current instance of %ByteBuffer at which the bytes are written
1101          * @param[in]   value           The @c float value to write
1102          * @exception   E_SUCCESS                       The method is successful.
1103          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1104          *                                                                      the @c index is larger than the limit minus the size of @c float or less than @c 0.
1105          * @remarks             This method writes the size of @c float number of bytes containing the given @c float value
1106          *                              into this buffer at the given index.
1107          * @see                 GetFloat()
1108          */
1109         result SetFloat(int index, float value);
1110
1111         /**
1112          * Sets a @c int value at the specified index of the calling %ByteBuffer object. @n
1113          * Provides a way for absolute indexing and writing.
1114          *
1115          * @since 2.0
1116          *
1117          * @return              An error code
1118          * @param[in]   index           The index of current instance of %ByteBuffer at which the bytes are written
1119          * @param[in]   value           The @c int value to write
1120          * @exception   E_SUCCESS               The method is successful.
1121          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1122          *                                                                      the @c index is larger than the limit minus size of @c int or less than @c 0.
1123          * @remarks             This method writes the size of @c int number of bytes containing the given @c int value
1124          *                              into this buffer at the given index.
1125          * @see                 GetInt()
1126          */
1127         result SetInt(int index, int value);
1128
1129         /**
1130          * Sets a @c long value at the specified index of the calling %ByteBuffer object. @n
1131          * Provides a way for absolute indexing and writing.
1132          *
1133          * @since 2.0
1134          *
1135          * @return              An error code
1136          * @param[in]   index           The index at which the bytes are written
1137          * @param[in]   value           The @c long value to write
1138          * @exception   E_SUCCESS                       The method is successful.
1139          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1140          *                                                                      the @c index is larger than the limit minus the size of @c long or less than @c 0.
1141          * @remarks             This method writes size of @c long number of bytes containing the given @c long value
1142          *                              into this buffer at the given index.
1143          * @see                 GetLong()
1144          */
1145         result SetLong(int index, long value);
1146
1147         /**
1148          * Sets a @c long @c long value at the specified index of the calling %ByteBuffer object. @n
1149          * Provides a way for absolute indexing and writing.
1150          *
1151          * @since 2.0
1152          *
1153          * @return              An error code
1154          * @param[in]   index           The index at which the bytes will be written
1155          * @param[in]   value           The @c long @c long value to write
1156          * @exception   E_SUCCESS                       The method is successful.
1157          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1158          *                                                                      the @c index is larger than the limit minus the size of @c long @c long or less than @c 0.
1159          * @remarks             This method writes the size of @c long @c long number of bytes containing the given @c long @c long value
1160          *                              into this buffer at the given index.
1161          * @see                 GetLongLong()
1162          */
1163         result SetLongLong(int index, long long value);
1164
1165         /**
1166          * @if OSPDEPREC
1167          * Sets a @c wchar_t value at the specified index of the calling %ByteBuffer object. @n
1168          * Provides a way for absolute indexing and writing.
1169          *
1170          * @brief       <i> [Deprecated] </i>
1171          * @deprecated This method is deprecated as @c mchar type is changed to @c wchar_t type.
1172          * Instead of using this method, use the SetWchar(int index, wchar_t value) method.
1173          * @since 2.0
1174          *
1175          * @return              An error code
1176          * @param[in]   index           The index at which the bytes will be written
1177          * @param[in]   value           The @c wchar_t value to write
1178          * @exception   E_SUCCESS                       The method is successful.
1179          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1180          *                                                                      the @c index is larger than the limit minus the size of @c wchar_t or less than @c 0.
1181          * @remarks             This method writes the size of @c wchar_t number of bytes containing the given @c wchar_t value
1182          *                              into this buffer at the given index.
1183          * @see                 GetMchar()
1184          * @endif
1185          */
1186         result SetMchar(int index, wchar_t value);
1187
1188         /**
1189          * Sets a @c wchar_t value at the specified index of the calling %ByteBuffer object. @n
1190          * Provides a way for absolute indexing and writing.
1191          *
1192          * @since 2.0
1193          *
1194          * @return              An error code
1195          * @param[in]   index                   The index at which the bytes will be written
1196          * @param[in]   value                   The @c wchar_t value to write
1197          * @exception   E_SUCCESS                       The method is successful.
1198          * @exception   E_OUT_OF_RANGE                  The specified index is outside the bounds of the data structure, or
1199          *                                                                      the @c index is larger than the limit minus the size of @c wchar_t or less than @c 0.
1200          * @remarks             This method writes the size of @c wchar_t number of bytes containing the given @c wchar_t value
1201          *                              into this buffer at the given index.
1202          * @see                 GetWchar()
1203          */
1204         result SetWchar(int index, wchar_t value);
1205
1206         /**
1207          * Sets a @c short value at the specified index of the calling %ByteBuffer object. @n
1208          * Provides a way for absolute indexing and writing.
1209          *
1210          * @since 2.0
1211          *
1212          * @return              An error code
1213          * @param[in]   index           The index of at which the bytes are written
1214          * @param[in]   value           The @c short value to write
1215          * @exception   E_SUCCESS                       The method is successful.
1216          * @exception   E_OUT_OF_RANGE          The specified index is outside the bounds of the data structure, or
1217          *                                                                      the @c index is larger than the limit minus the size of @c short or less than @c 0.
1218          * @remarks             This method writes the size of @c short number of bytes containing the given @c short value
1219          *                              into this buffer at the given index.
1220          * @see                 GetShort()
1221          */
1222         result SetShort(int index, short value);
1223
1224         /**
1225          * Creates a new %ByteBuffer whose content is a shared portion of
1226          * the content of the calling %ByteBuffer object.
1227          *
1228          * @since 2.0
1229          *
1230          * @return              %ByteBuffer pointer to the current position of the calling object
1231          * @remarks             The content of the new buffer starts at the current position of the calling %ByteBuffer object.
1232          *                              The new buffer's position is zero, its capacity and limit are
1233          *                              the number of bytes remaining of the current instance of %ByteBuffer,
1234          *                              and its mark is undefined.
1235          */
1236         ByteBuffer* SliceN(void) const;
1237
1238         /**
1239          * Gets the pointer to the raw array of the calling buffer. @n
1240          * If the capacity is zero, it returns @c null.
1241          *
1242          * @since 2.0
1243          *
1244          * @return              A pointer to the raw array of the calling buffer
1245          */
1246         const byte* GetPointer(void) const;
1247
1248         /**
1249          * Gets the pointer to the raw array of the calling buffer. @n
1250          * If the capacity is zero, it returns @c null.
1251          *
1252          * @since 2.1
1253          *
1254          * @return              A pointer(non-const) to the raw array of the calling buffer
1255          */
1256         byte* GetPointer(void);
1257
1258         /**
1259          * Compares the input Object with the calling %ByteBuffer instance.
1260          *
1261          * @since 2.0
1262          *
1263          * @return              @c true if the input object equals the calling %ByteBuffer instance, @n
1264          *                              else @c false
1265          * @param[in]   obj     The object instance to compare with the calling object
1266          * @remarks             This method returns @c true only if the specified object is also an instance of
1267          *                              the %ByteBuffer class, the two buffers have the same number of remaining elements, and the two
1268          *                              sequences of remaining elements are equal (considered independent of their starting positions).
1269          * @see                 Tizen::Base::BufferBase::GetHashCode()
1270          */
1271         virtual bool Equals(const Tizen::Base::Object& obj) const;
1272
1273         /**
1274          *      Gets the hash value of the current instance.
1275          *
1276          *      @since 2.0
1277          *
1278          *      @return         The hash value of the current instance
1279          *      @remarks        The hash code of a buffer depends only upon its remaining elements.
1280          */
1281         virtual int GetHashCode(void) const;
1282
1283 private:
1284         /**
1285          * This copy constructor is intentionally declared as private to prohibit copying of objects by users.
1286          */
1287         ByteBuffer(const ByteBuffer& buffer)
1288                 :__pByteBufferImpl(null)
1289         {
1290                 Construct(buffer);
1291         }
1292
1293         /**
1294          * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
1295          */
1296         ByteBuffer& operator =(const ByteBuffer& buffer);
1297
1298         /**
1299          * Returns the size of byte(1).
1300          *
1301          * @return              The size of byte(1)
1302          */
1303         virtual int GetTypeSize(void) const;
1304
1305
1306         friend class _ByteBufferImpl;
1307         class _ByteBufferImpl * __pByteBufferImpl;
1308
1309 }; // ByteBuffer
1310
1311 }} // Tizen::Base
1312
1313 #endif // _FBASE_BYTE_BUFFER_H_