Alexander Afanasyev | 2d600f7 | 2013-11-21 18:20:37 -0800 | [diff] [blame^] | 1 | .. _Name.Component: |
| 2 | |
| 3 | Name.Component Class |
| 4 | ==================== |
| 5 | |
| 6 | A Name.Component is holds a read-only name component value |
| 7 | |
| 8 | :[C++]: |
| 9 | |
| 10 | Namespace: ``ndn`` |
| 11 | |
| 12 | Name.Component Constructor |
| 13 | -------------------------- |
| 14 | |
| 15 | Create a new Name.Component, copying the optional value. |
| 16 | |
| 17 | |
| 18 | :[C++]: |
| 19 | |
| 20 | .. code-block:: c++ |
| 21 | |
| 22 | ndn::Name::Component( |
| 23 | [const std::vector<uint8_t>& value] |
| 24 | ); |
| 25 | |
| 26 | :Parameters: |
| 27 | |
| 28 | - ``value`` |
| 29 | (optional) The content byte array to copy. |
| 30 | |
| 31 | Name.Component.toEscapedString Method |
| 32 | ------------------------------------- |
| 33 | |
| 34 | Convert this component value by escaping characters according to the NDN URI Scheme. |
| 35 | |
| 36 | :[C++]: |
| 37 | |
| 38 | .. code-block:: c++ |
| 39 | |
| 40 | std::string toEscapedString() const (); |
| 41 | |
| 42 | :Returns: |
| 43 | |
| 44 | The escaped string. |
| 45 | |
| 46 | .. _Name: |
| 47 | |
| 48 | Name Class |
| 49 | ========== |
| 50 | |
| 51 | A Name holds an array of Name.Component and represents an NDN name. |
| 52 | |
| 53 | :[C++]: |
| 54 | Namespace: ``ndn`` |
| 55 | |
| 56 | :[Python]: |
| 57 | Module: ``pyndn`` |
| 58 | |
| 59 | Name Constructor (array of components) |
| 60 | -------------------------------------- |
| 61 | |
| 62 | Create a new Name with the optional components. |
| 63 | |
| 64 | :[C++]: |
| 65 | |
| 66 | .. code-block:: c++ |
| 67 | |
| 68 | Name( |
| 69 | [const std::vector<Name::Component>& components] |
| 70 | ); |
| 71 | |
| 72 | :[JavaScript]: |
| 73 | |
| 74 | .. code-block:: javascript |
| 75 | |
| 76 | var Name = function Name ( |
| 77 | [components // Array<Uint8Array>] |
| 78 | ) |
| 79 | |
| 80 | :[Python]: |
| 81 | |
| 82 | .. code-block:: python |
| 83 | |
| 84 | def __init__(self |
| 85 | [, components // Array<string>] |
| 86 | ) |
| 87 | |
| 88 | :Parameters: |
| 89 | |
| 90 | - ``components`` |
| 91 | (optional) The array of name components. |
| 92 | |
| 93 | Name Constructor (from URI) |
| 94 | --------------------------- |
| 95 | |
| 96 | Parse the uri according to the NDN URI Scheme and create the Name with the components. |
| 97 | |
| 98 | :[C++]: |
| 99 | |
| 100 | .. code-block:: c++ |
| 101 | |
| 102 | Name( |
| 103 | const char* uri |
| 104 | ); |
| 105 | |
| 106 | :[JavaScript]: |
| 107 | |
| 108 | .. code-block:: javascript |
| 109 | |
| 110 | var Name = function Name ( |
| 111 | uri // string |
| 112 | ) |
| 113 | |
| 114 | :Parameters: |
| 115 | |
| 116 | - ``uri`` |
| 117 | The URI in NDN URI Scheme. |
| 118 | |
| 119 | Name.toUri Method |
| 120 | ----------------- |
| 121 | |
| 122 | Return the escaped name string according to the NDN URI Scheme. |
| 123 | |
| 124 | :[C++]: |
| 125 | |
| 126 | .. code-block:: c++ |
| 127 | |
| 128 | std::string toUri() const (); |
| 129 | |
| 130 | :[JavaScript]: |
| 131 | |
| 132 | .. code-block:: javascript |
| 133 | |
| 134 | // Returns string |
| 135 | Name.prototype.toUri = function(); |
| 136 | |
| 137 | :Returns: |
| 138 | |
| 139 | The escaped name string according to the NDN URI Scheme. |
| 140 | |
| 141 | Name.size Method |
| 142 | ---------------- |
| 143 | |
| 144 | Get the number of components. |
| 145 | |
| 146 | :[C++]: |
| 147 | |
| 148 | .. code-block:: c++ |
| 149 | |
| 150 | size_t getComponentCount() const; |
| 151 | |
| 152 | :Returns: |
| 153 | |
| 154 | The number of components. |
| 155 | |
| 156 | Name.get Method |
| 157 | --------------- |
| 158 | |
| 159 | Get a Name Component by index number. |
| 160 | |
| 161 | :[C++]: |
| 162 | |
| 163 | .. code-block:: c++ |
| 164 | |
| 165 | const Component& getComponent( |
| 166 | size_t i |
| 167 | ) const; |
| 168 | |
| 169 | :Parameters: |
| 170 | |
| 171 | - ``i`` |
| 172 | The index of the component to get, starting from 0. |
| 173 | |
| 174 | :Returns: |
| 175 | |
| 176 | The Name.Component. |
| 177 | |
| 178 | Name.getPrefix Method |
| 179 | --------------------- |
| 180 | |
| 181 | Get a new Name with the first nComponents components of this Name. |
| 182 | |
| 183 | :[C++]: |
| 184 | |
| 185 | .. code-block:: c++ |
| 186 | |
| 187 | Name getPrefix( |
| 188 | size_t nComponents |
| 189 | ) const; |
| 190 | |
| 191 | :[JavaScript]: |
| 192 | |
| 193 | .. code-block:: javascript |
| 194 | |
| 195 | // Returns Name |
| 196 | Name.prototype.getPrefix = function( |
| 197 | nComponents // Number |
| 198 | ); |
| 199 | |
| 200 | :Parameters: |
| 201 | |
| 202 | - nComponents |
| 203 | The number of prefix components. If larger than the number of components in this name, return a copy of this Name. |
| 204 | |
| 205 | :Returns: |
| 206 | |
| 207 | A new Name. |
| 208 | |
| 209 | Name.getSubName Method |
| 210 | ---------------------- |
| 211 | |
| 212 | Get a new name, constructed as a subset of components. |
| 213 | |
| 214 | :[C++]: |
| 215 | |
| 216 | .. code-block:: c++ |
| 217 | |
| 218 | Name getSubName( |
| 219 | size_t iStartComponent |
| 220 | [, size_t nComponents] |
| 221 | ) const; |
| 222 | |
| 223 | :Parameters: |
| 224 | |
| 225 | - ``iStartComponent`` |
| 226 | The index if the first component to get. |
| 227 | |
| 228 | - ``nComponents`` |
| 229 | (optional) The number of components starting at iStartComponent. If omitted, return components until the end of the name. |
| 230 | |
| 231 | :Returns: |
| 232 | |
| 233 | A new Name. |
| 234 | |
| 235 | Name.match Method |
| 236 | ----------------- |
| 237 | |
| 238 | Check if the N components of this name are the same as the first N components of the given name. |
| 239 | |
| 240 | :[C++]: |
| 241 | |
| 242 | .. code-block:: c++ |
| 243 | |
| 244 | bool match( |
| 245 | const Name& name |
| 246 | ) const; |
| 247 | |
| 248 | :[JavaScript]: |
| 249 | |
| 250 | .. code-block:: javascript |
| 251 | |
| 252 | // Returns boolean |
| 253 | Name.prototype.match = function( |
| 254 | name // Name |
| 255 | ); |
| 256 | |
| 257 | :Parameters: |
| 258 | |
| 259 | - ``name`` |
| 260 | The Name to check. |
| 261 | |
| 262 | - ``nComponents`` |
| 263 | The number of components starting at iStartComponent. If omitted, return components until the end of the name. |
| 264 | |
| 265 | :Returns: |
| 266 | |
| 267 | true if this matches the given name, otherwise false. This always returns true if this name is empty. |
| 268 | |
| 269 | Name.append Method (copy byte array) |
| 270 | ------------------------------------ |
| 271 | |
| 272 | Append a new component, copying from byte array. |
| 273 | |
| 274 | :[C++]: |
| 275 | |
| 276 | .. code-block:: c++ |
| 277 | |
| 278 | Name& append( |
| 279 | const std::vector<uint8_t>& value |
| 280 | ); |
| 281 | |
| 282 | :[JavaScript]: |
| 283 | |
| 284 | .. code-block:: javascript |
| 285 | |
| 286 | // Returns this Name |
| 287 | Name.prototype.append = function( |
| 288 | value // Array<number>|ArrayBuffer|Uint8Array |
| 289 | ) |
| 290 | |
| 291 | :Parameters: |
| 292 | |
| 293 | - ``value`` |
| 294 | The component byte array to copy. |
| 295 | |
| 296 | :Returns: |
| 297 | |
| 298 | This name so that you can chain calls to append. |
| 299 | |
| 300 | Name.append Method (from Blob) |
| 301 | ------------------------------ |
| 302 | |
| 303 | Append a new component, taking another pointer to the byte array in the Blob. |
| 304 | |
| 305 | :[C++]: |
| 306 | |
| 307 | .. code-block:: c++ |
| 308 | |
| 309 | Name& append( |
| 310 | const Blob& value |
| 311 | ); |
| 312 | |
| 313 | :Parameters: |
| 314 | |
| 315 | - ``value`` |
| 316 | The Blob with the pointer to the byte array. |
| 317 | |
| 318 | :Returns: |
| 319 | |
| 320 | This name so that you can chain calls to append. |
| 321 | |
| 322 | Name.append Method (from Component) |
| 323 | ----------------------------------- |
| 324 | |
| 325 | Append the component to this name. |
| 326 | |
| 327 | :[C++]: |
| 328 | |
| 329 | .. code-block:: c++ |
| 330 | |
| 331 | Name& append( |
| 332 | const Name::Component& value |
| 333 | ); |
| 334 | |
| 335 | :Parameters: |
| 336 | |
| 337 | - ``value`` |
| 338 | The Name.Component to append. |
| 339 | |
| 340 | :Returns: |
| 341 | |
| 342 | This name so that you can chain calls to append. |
| 343 | |
| 344 | Name.append Method (from Name) |
| 345 | ------------------------------ |
| 346 | |
| 347 | Append the components of the given name to this name. |
| 348 | |
| 349 | :[C++]: |
| 350 | |
| 351 | .. code-block:: c++ |
| 352 | |
| 353 | Name& append( |
| 354 | const Name& name |
| 355 | ); |
| 356 | |
| 357 | :[JavaScript]: |
| 358 | |
| 359 | .. code-block:: javascript |
| 360 | |
| 361 | // Returns this Name |
| 362 | Name.prototype.append = function( |
| 363 | value // Name |
| 364 | ) |
| 365 | |
| 366 | :Parameters: |
| 367 | |
| 368 | - ``name`` |
| 369 | The Name with components to append. |
| 370 | |
| 371 | :Returns: |
| 372 | |
| 373 | This name so that you can chain calls to append. |
| 374 | |
| 375 | Name.appendSegment Method |
| 376 | ------------------------- |
| 377 | |
| 378 | Append a component with the encoded segment number. |
| 379 | |
| 380 | :[C++]: |
| 381 | |
| 382 | .. code-block:: c++ |
| 383 | |
| 384 | Name& appendSegment( |
| 385 | uint64_t segment |
| 386 | ); |
| 387 | |
| 388 | :[JavaScript]: |
| 389 | |
| 390 | .. code-block:: javascript |
| 391 | |
| 392 | // Returns this Name |
| 393 | Name.prototype.appendSegment = function( |
| 394 | segment // Number |
| 395 | ) |
| 396 | |
| 397 | :Parameters: |
| 398 | |
| 399 | - ``segment`` |
| 400 | The integer segment number to be encoded. |
| 401 | |
| 402 | :Returns: |
| 403 | |
| 404 | This name so that you can chain calls to append. |
| 405 | |
| 406 | Name.appendVersion Method |
| 407 | ------------------------- |
| 408 | |
| 409 | Append a component with the encoded version number. Note that this encodes the exact value of version without converting from a time representation. |
| 410 | |
| 411 | :[C++]: |
| 412 | |
| 413 | .. code-block:: c++ |
| 414 | |
| 415 | Name& appendVersion( |
| 416 | uint64_t version |
| 417 | ); |
| 418 | |
| 419 | :Parameters: |
| 420 | |
| 421 | - ``version`` |
| 422 | The version number to be encoded. |
| 423 | |
| 424 | :Returns: |
| 425 | |
| 426 | This name so that you can chain calls to append. |
| 427 | |
| 428 | Other Name getter and setter methods |
| 429 | ------------------------------------ |
| 430 | |
| 431 | .. code-block:: javascript |
| 432 | |
| 433 | // Returns a new Name |
| 434 | Name.prototype.cut = function( |
| 435 | minusComponents // number |
| 436 | ) |
| 437 | |
| 438 | // Returns number |
| 439 | Name.prototype.indexOfFileName = function() |
| 440 | |
| 441 | // Returns Boolean |
| 442 | Name.prototype.equalsName = function( |
| 443 | name // Name |
| 444 | ) |