blob: 6ca5af3028acf92a96adb9c286b9007ca04735a9 [file] [log] [blame]
Alexander Afanasyev2d600f72013-11-21 18:20:37 -08001.. _Name.Component:
2
3Name.Component Class
4====================
5
6A Name.Component is holds a read-only name component value
7
8:[C++]:
9
10 Namespace: ``ndn``
11
12Name.Component Constructor
13--------------------------
14
15Create a new Name.Component, copying the optional value.
16
17
18:[C++]:
19
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080020 .. code-block:: c++
21
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080022 Name::Component(
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080023 [const std::vector<uint8_t>& value]
24 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080025
26:Parameters:
27
28 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080029 (optional) The content byte array to copy.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080030
31Name.Component.toEscapedString Method
32-------------------------------------
33
34Convert this component value by escaping characters according to the NDN URI Scheme.
35
36:[C++]:
37
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080038 .. code-block:: c++
39
40 std::string toEscapedString() const ();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080041
42:Returns:
43
44 The escaped string.
45
46.. _Name:
47
48Name Class
49==========
50
51A 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
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080059Name Constructors
60-----------------
61
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080062Name Constructor (array of components)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080063^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080064
65Create a new Name with the optional components.
66
67:[C++]:
68
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080069 .. code-block:: c++
70
71 Name(
72 [const std::vector<Name::Component>& components]
73 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080074
75:[JavaScript]:
76
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080077 .. code-block:: javascript
78
79 var Name = function Name (
80 [components // Array<Uint8Array>]
81 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080082
83:[Python]:
84
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080085 .. code-block:: python
86
87 def __init__(self
88 [, components // Array<string>]
89 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080090
91:Parameters:
92
93 - ``components``
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080094 (optional) The array of :ref:`name components <Name.Component>`.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080095
96Name Constructor (from URI)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080097^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080098
99Parse the uri according to the NDN URI Scheme and create the Name with the components.
100
101:[C++]:
102
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800103 .. code-block:: c++
104
105 Name(
106 const char* uri
107 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800108
109:[JavaScript]:
110
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800111 .. code-block:: javascript
112
113 var Name = function Name (
114 uri // string
115 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800116
117:Parameters:
118
119 - ``uri``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800120 The URI in NDN URI Scheme.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800121
122Name.toUri Method
123-----------------
124
125Return the escaped name string according to the NDN URI Scheme.
126
127:[C++]:
128
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800129 .. code-block:: c++
130
131 std::string toUri() const ();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800132
133:[JavaScript]:
134
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800135 .. code-block:: javascript
136
137 // Returns string
138 Name.prototype.toUri = function();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800139
140:Returns:
141
142The escaped name string according to the NDN URI Scheme.
143
144Name.size Method
145----------------
146
147Get the number of components.
148
149:[C++]:
150
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800151 .. code-block:: c++
152
153 size_t getComponentCount() const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800154
155:Returns:
156
157 The number of components.
158
159Name.get Method
160---------------
161
162Get a Name Component by index number.
163
164:[C++]:
165
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800166 .. code-block:: c++
167
168 const Component& getComponent(
169 size_t i
170 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800171
172:Parameters:
173
174 - ``i``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800175 The index of the component to get, starting from 0.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800176
177:Returns:
178
179 The Name.Component.
180
181Name.getPrefix Method
182---------------------
183
184Get a new Name with the first nComponents components of this Name.
185
186:[C++]:
187
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800188 .. code-block:: c++
189
190 Name getPrefix(
191 size_t nComponents
192 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800193
194:[JavaScript]:
195
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800196 .. code-block:: javascript
197
198 // Returns Name
199 Name.prototype.getPrefix = function(
200 nComponents // Number
201 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800202
203:Parameters:
204
205 - nComponents
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800206 The number of prefix components. If larger than the number of components in this name, return a copy of this Name.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800207
208:Returns:
209
210 A new Name.
211
212Name.getSubName Method
213----------------------
214
215Get a new name, constructed as a subset of components.
216
217:[C++]:
218
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800219 .. code-block:: c++
220
221 Name getSubName(
222 size_t iStartComponent
223 [, size_t nComponents]
224 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800225
226:Parameters:
227
228 - ``iStartComponent``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800229 The index if the first component to get.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800230
231 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800232 (optional) The number of components starting at iStartComponent. If omitted, return components until the end of the name.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800233
234:Returns:
235
236 A new Name.
237
238Name.match Method
239-----------------
240
241Check if the N components of this name are the same as the first N components of the given name.
242
243:[C++]:
244
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800245 .. code-block:: c++
246
247 bool match(
248 const Name& name
249 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800250
251:[JavaScript]:
252
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800253 .. code-block:: javascript
254
255 // Returns boolean
256 Name.prototype.match = function(
257 name // Name
258 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800259
260:Parameters:
261
262 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800263 The Name to check.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800264
265 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800266 The number of components starting at iStartComponent. If omitted, return components until the end of the name.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800267
268:Returns:
269
270 true if this matches the given name, otherwise false. This always returns true if this name is empty.
271
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800272Name.append Methods
273-------------------
274
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800275Name.append Method (copy byte array)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800276^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800277
278Append a new component, copying from byte array.
279
280:[C++]:
281
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800282 .. code-block:: c++
283
284 Name& append(
285 const std::vector<uint8_t>& value
286 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800287
288:[JavaScript]:
289
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800290 .. code-block:: javascript
291
292 // Returns this Name
293 Name.prototype.append = function(
294 value // Array<number>|ArrayBuffer|Uint8Array
295 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800296
297:Parameters:
298
299 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800300 The component byte array to copy.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800301
302:Returns:
303
304 This name so that you can chain calls to append.
305
306Name.append Method (from Blob)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800307^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800308
309Append a new component, taking another pointer to the byte array in the Blob.
310
311:[C++]:
312
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800313 .. code-block:: c++
314
315 Name& append(
316 const Blob& value
317 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800318
319:Parameters:
320
321 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800322 The Blob with the pointer to the byte array.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800323
324:Returns:
325
326 This name so that you can chain calls to append.
327
328Name.append Method (from Component)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800329^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800330
331Append the component to this name.
332
333:[C++]:
334
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800335 .. code-block:: c++
336
337 Name& append(
338 const Name::Component& value
339 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800340
341:Parameters:
342
343 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800344 The Name.Component to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800345
346:Returns:
347
348 This name so that you can chain calls to append.
349
350Name.append Method (from Name)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800351^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800352
353Append the components of the given name to this name.
354
355:[C++]:
356
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800357 .. code-block:: c++
358
359 Name& append(
360 const Name& name
361 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800362
363:[JavaScript]:
364
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800365 .. code-block:: javascript
366
367 // Returns this Name
368 Name.prototype.append = function(
369 value // Name
370 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800371
372:Parameters:
373
374 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800375 The Name with components to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800376
377:Returns:
378
379 This name so that you can chain calls to append.
380
381Name.appendSegment Method
382-------------------------
383
384Append a component with the encoded segment number.
385
386:[C++]:
387
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800388 .. code-block:: c++
389
390 Name& appendSegment(
391 uint64_t segment
392 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800393
394:[JavaScript]:
395
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800396 .. code-block:: javascript
397
398 // Returns this Name
399 Name.prototype.appendSegment = function(
400 segment // Number
401 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800402
403:Parameters:
404
405 - ``segment``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800406 The integer segment number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800407
408:Returns:
409
410 This name so that you can chain calls to append.
411
412Name.appendVersion Method
413-------------------------
414
415Append a component with the encoded version number. Note that this encodes the exact value of version without converting from a time representation.
416
417:[C++]:
418
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800419 .. code-block:: c++
420
421 Name& appendVersion(
422 uint64_t version
423 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800424
425:Parameters:
426
427 - ``version``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800428 The version number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800429
430:Returns:
431
432 This name so that you can chain calls to append.
433
434Other Name getter and setter methods
435------------------------------------
436
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800437:[JavaScript]:
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800438
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800439 .. code-block:: javascript
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800440
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800441 // Returns a new Name
442 Name.prototype.cut = function(
443 minusComponents // number
444 )
445
446 // Returns number
447 Name.prototype.indexOfFileName = function()
448
449 // Returns Boolean
450 Name.prototype.equalsName = function(
451 name // Name
452 )