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