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