Alexander Afanasyev | 2d600f7 | 2013-11-21 18:20:37 -0800 | [diff] [blame] | 1 | .. _Data: |
| 2 | |
| 3 | Data Class |
| 4 | ========== |
| 5 | |
| 6 | :[C++]: |
| 7 | Namespace: ``ndn`` |
| 8 | |
| 9 | :[Python]: |
| 10 | Module: ``pyndn`` |
| 11 | |
| 12 | Data Constructor |
| 13 | ---------------- |
| 14 | |
| 15 | Create a new Data with the optional values. |
| 16 | |
| 17 | :[C++]: |
| 18 | |
| 19 | .. code-block:: c++ |
| 20 | |
| 21 | Data( |
| 22 | |
| 23 | [const Name& name] |
| 24 | |
| 25 | ); |
| 26 | |
| 27 | :[JavaScript]: |
| 28 | |
| 29 | .. code-block:: javascript |
| 30 | |
| 31 | var Data = function Data( |
| 32 | |
| 33 | [name // Name] |
| 34 | |
| 35 | ) |
| 36 | |
| 37 | :[Python]: |
| 38 | |
| 39 | .. code-block:: python |
| 40 | |
| 41 | def __init__(self |
| 42 | |
| 43 | [, name // Name] |
| 44 | |
| 45 | ) |
| 46 | |
| 47 | :Parameters: |
| 48 | |
| 49 | - ``name`` |
| 50 | (optional) The name for the data packet. |
| 51 | |
| 52 | Data.getContent Method |
| 53 | ---------------------- |
| 54 | |
| 55 | Get content of the Data packet. |
| 56 | |
| 57 | :[C++]: |
| 58 | |
| 59 | .. code-block:: c++ |
| 60 | |
| 61 | const Blob& getContent() const; |
| 62 | |
| 63 | :[JavaScript]: |
| 64 | |
| 65 | .. code-block:: javascript |
| 66 | |
| 67 | // Returns Blob |
| 68 | Data.prototype.getContent = function() |
| 69 | |
| 70 | :Returns: |
| 71 | |
| 72 | A pointer to the content byte array. |
| 73 | |
| 74 | Data.setContent Method |
| 75 | ---------------------- |
| 76 | |
| 77 | Set content to point to an existing byte array. |
| 78 | |
| 79 | :[C++]: |
| 80 | |
| 81 | .. code-block:: c++ |
| 82 | |
| 83 | void setContent( |
| 84 | |
| 85 | const Blob& content |
| 86 | |
| 87 | ); |
| 88 | |
| 89 | :Parameters: |
| 90 | |
| 91 | - ``content`` |
| 92 | The pointer to the byte array. |
| 93 | |
| 94 | Data.wireDecode Method |
| 95 | ---------------------- |
| 96 | |
| 97 | Decode the input using a particular wire format and update this Data. If wireFormat is the default wire format, also set the defaultWireEncoding field to the input. |
| 98 | |
| 99 | :[C++]: |
| 100 | |
| 101 | .. code-block:: c++ |
| 102 | |
| 103 | void wireDecode( |
| 104 | |
| 105 | const std::vector<uint8_t>& input |
| 106 | [, WireFormat& wireFormat] |
| 107 | |
| 108 | ); |
| 109 | |
| 110 | :[JavaScript]: |
| 111 | |
| 112 | .. code-block:: javascript |
| 113 | |
| 114 | ContentObject.prototype.decode = function( |
| 115 | |
| 116 | input // Uint8Array |
| 117 | [, wireFormat // WireFormat] |
| 118 | |
| 119 | ) |
| 120 | |
| 121 | :Parameters: |
| 122 | |
| 123 | - ``input`` |
| 124 | The input byte array to be decoded. |
| 125 | |
| 126 | - ``wireFormat`` |
| 127 | (optional) A WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat(). |
| 128 | |
| 129 | Data.wireEncode Method |
| 130 | ---------------------- |
| 131 | |
| 132 | Encode this Data for a particular wire format. If wireFormat is the default wire format, also set the defaultWireEncoding field to the encoded result. |
| 133 | |
| 134 | :[C++]: |
| 135 | |
| 136 | .. code-block:: c++ |
| 137 | |
| 138 | SignedBlob wireEncode( |
| 139 | |
| 140 | [WireFormat& wireFormat] |
| 141 | |
| 142 | ) const; |
| 143 | |
| 144 | :[JavaScript]: |
| 145 | |
| 146 | .. code-block:: javascript |
| 147 | |
| 148 | // Returns Uint8Array |
| 149 | ContentObject.prototype.encode = function( |
| 150 | |
| 151 | [wireFormat // WireFormat] |
| 152 | |
| 153 | ) |
| 154 | |
| 155 | :Parameters: |
| 156 | |
| 157 | - wireFormat |
| 158 | (optional) A WireFormat object used to encode the input. If omitted, use WireFormat getDefaultWireFormat (). |
| 159 | |
| 160 | :Returns: |
| 161 | |
| 162 | The encoded byte array as a SignedBlob. |