OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006,2007 INRIA | 3 * Copyright (c) 2005,2006,2007 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 */ | 469 */ |
470 Buffer::Iterator Begin (void) const; | 470 Buffer::Iterator Begin (void) const; |
471 /** | 471 /** |
472 * \return an Iterator which points to the | 472 * \return an Iterator which points to the |
473 * end of this Buffer. | 473 * end of this Buffer. |
474 */ | 474 */ |
475 Buffer::Iterator End (void) const; | 475 Buffer::Iterator End (void) const; |
476 | 476 |
477 Buffer CreateFullCopy (void) const; | 477 Buffer CreateFullCopy (void) const; |
478 | 478 |
| 479 /** |
| 480 * \return the number of bytes required for serialization· |
| 481 */ |
| 482 uint32_t GetSerializedSize (void) const; |
| 483 |
| 484 /** |
| 485 * \return zero if buffer not large enough |
| 486 * \param buffer points to serialization buffer |
| 487 * \param maxSize max number of bytes to write |
| 488 * |
| 489 * This buffer's contents are serialized into the raw· |
| 490 * character buffer parameter. Note: The zero length· |
| 491 * data is not copied entirely. Only the length of· |
| 492 * zero byte data is serialized. |
| 493 */ |
| 494 uint32_t Serialize (uint8_t* buffer, uint32_t maxSize) const; |
| 495 |
| 496 /** |
| 497 * \return zero if a complete buffer is not deserialized |
| 498 * \param buffer points to buffer for deserialization |
| 499 * \param size number of bytes to deserialize |
| 500 * |
| 501 * The raw character buffer is deserialized and all the· |
| 502 * data is placed into this buffer. |
| 503 */ |
| 504 uint32_t Deserialize (uint8_t* buffer, uint32_t size); |
| 505 ·· |
479 int32_t GetCurrentStartOffset (void) const; | 506 int32_t GetCurrentStartOffset (void) const; |
480 int32_t GetCurrentEndOffset (void) const; | 507 int32_t GetCurrentEndOffset (void) const; |
481 | 508 |
482 /**· | 509 /**· |
483 * Copy the specified amount of data from the buffer to the given output strea
m. | 510 * Copy the specified amount of data from the buffer to the given output strea
m. |
484 *· | 511 *· |
485 * @param os the output stream | 512 * @param os the output stream |
486 * @param size the maximum amount of bytes to copy. If zero, nothing is copied
. | 513 * @param size the maximum amount of bytes to copy. If zero, nothing is copied
. |
487 */ | 514 */ |
488 void CopyData (std::ostream *os, uint32_t size) const; | 515 void CopyData (std::ostream *os, uint32_t size) const; |
489 | 516 |
490 uint32_t CopyData (uint8_t *buffer, uint32_t size) const; | 517 uint32_t CopyData (uint8_t *buffer, uint32_t size) const; |
491 | 518 |
492 Buffer (Buffer const &o); | 519 Buffer (Buffer const &o); |
493 Buffer &operator = (Buffer const &o); | 520 Buffer &operator = (Buffer const &o); |
494 Buffer (); | 521 Buffer (); |
495 Buffer (uint32_t dataSize); | 522 Buffer (uint32_t dataSize); |
| 523 Buffer (uint32_t dataSize, bool initialize); |
496 ~Buffer (); | 524 ~Buffer (); |
497 private: | 525 private: |
498 | 526 |
499 void TransformIntoRealBuffer (void) const; | 527 void TransformIntoRealBuffer (void) const; |
500 bool CheckInternalState (void) const; | 528 bool CheckInternalState (void) const; |
501 void Initialize (uint32_t zeroSize); | 529 void Initialize (uint32_t zeroSize); |
502 uint32_t GetInternalSize (void) const; | 530 uint32_t GetInternalSize (void) const; |
503 uint32_t GetInternalEnd (void) const; | 531 uint32_t GetInternalEnd (void) const; |
504 static void Recycle (struct BufferData *data); | 532 static void Recycle (struct BufferData *data); |
505 static struct BufferData *Create (uint32_t size); | 533 static struct BufferData *Create (uint32_t size); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 uint8_t data = m_data[m_current - (m_zeroEnd-m_zeroStart)]; | 630 uint8_t data = m_data[m_current - (m_zeroEnd-m_zeroStart)]; |
603 m_current++; | 631 m_current++; |
604 return data; | 632 return data; |
605 } | 633 } |
606 } | 634 } |
607 | 635 |
608 | 636 |
609 } // namespace ns3 | 637 } // namespace ns3 |
610 | 638 |
611 #endif /* BUFFER_H */ | 639 #endif /* BUFFER_H */ |
OLD | NEW |