blob: fb217b2f7128950115034cf7280ba02576e3e9ca [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
22 ndn::Name::Component(
23 [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
59Name Constructor (array of components)
60--------------------------------------
61
62Create a new Name with the optional components.
63
64:[C++]:
65
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080066 .. code-block:: c++
67
68 Name(
69 [const std::vector<Name::Component>& components]
70 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080071
72:[JavaScript]:
73
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080074 .. code-block:: javascript
75
76 var Name = function Name (
77 [components // Array<Uint8Array>]
78 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080079
80:[Python]:
81
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080082 .. code-block:: python
83
84 def __init__(self
85 [, components // Array<string>]
86 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080087
88:Parameters:
89
90 - ``components``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080091 (optional) The array of name components.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080092
93Name Constructor (from URI)
94---------------------------
95
96Parse the uri according to the NDN URI Scheme and create the Name with the components.
97
98:[C++]:
99
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800100 .. code-block:: c++
101
102 Name(
103 const char* uri
104 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800105
106:[JavaScript]:
107
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800108 .. code-block:: javascript
109
110 var Name = function Name (
111 uri // string
112 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800113
114:Parameters:
115
116 - ``uri``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800117 The URI in NDN URI Scheme.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800118
119Name.toUri Method
120-----------------
121
122Return the escaped name string according to the NDN URI Scheme.
123
124:[C++]:
125
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800126 .. code-block:: c++
127
128 std::string toUri() const ();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800129
130:[JavaScript]:
131
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800132 .. code-block:: javascript
133
134 // Returns string
135 Name.prototype.toUri = function();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800136
137:Returns:
138
139The escaped name string according to the NDN URI Scheme.
140
141Name.size Method
142----------------
143
144Get the number of components.
145
146:[C++]:
147
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800148 .. code-block:: c++
149
150 size_t getComponentCount() const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800151
152:Returns:
153
154 The number of components.
155
156Name.get Method
157---------------
158
159Get a Name Component by index number.
160
161:[C++]:
162
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800163 .. code-block:: c++
164
165 const Component& getComponent(
166 size_t i
167 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800168
169:Parameters:
170
171 - ``i``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800172 The index of the component to get, starting from 0.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800173
174:Returns:
175
176 The Name.Component.
177
178Name.getPrefix Method
179---------------------
180
181Get a new Name with the first nComponents components of this Name.
182
183:[C++]:
184
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800185 .. code-block:: c++
186
187 Name getPrefix(
188 size_t nComponents
189 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800190
191:[JavaScript]:
192
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800193 .. code-block:: javascript
194
195 // Returns Name
196 Name.prototype.getPrefix = function(
197 nComponents // Number
198 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800199
200:Parameters:
201
202 - nComponents
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800203 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 -0800204
205:Returns:
206
207 A new Name.
208
209Name.getSubName Method
210----------------------
211
212Get a new name, constructed as a subset of components.
213
214:[C++]:
215
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800216 .. code-block:: c++
217
218 Name getSubName(
219 size_t iStartComponent
220 [, size_t nComponents]
221 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800222
223:Parameters:
224
225 - ``iStartComponent``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800226 The index if the first component to get.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800227
228 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800229 (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 -0800230
231:Returns:
232
233 A new Name.
234
235Name.match Method
236-----------------
237
238Check if the N components of this name are the same as the first N components of the given name.
239
240:[C++]:
241
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800242 .. code-block:: c++
243
244 bool match(
245 const Name& name
246 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800247
248:[JavaScript]:
249
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800250 .. code-block:: javascript
251
252 // Returns boolean
253 Name.prototype.match = function(
254 name // Name
255 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800256
257:Parameters:
258
259 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800260 The Name to check.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800261
262 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800263 The number of components starting at iStartComponent. If omitted, return components until the end of the name.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800264
265:Returns:
266
267 true if this matches the given name, otherwise false. This always returns true if this name is empty.
268
269Name.append Method (copy byte array)
270------------------------------------
271
272Append a new component, copying from byte array.
273
274:[C++]:
275
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800276 .. code-block:: c++
277
278 Name& append(
279 const std::vector<uint8_t>& value
280 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800281
282:[JavaScript]:
283
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800284 .. code-block:: javascript
285
286 // Returns this Name
287 Name.prototype.append = function(
288 value // Array<number>|ArrayBuffer|Uint8Array
289 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800290
291:Parameters:
292
293 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800294 The component byte array to copy.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800295
296:Returns:
297
298 This name so that you can chain calls to append.
299
300Name.append Method (from Blob)
301------------------------------
302
303Append a new component, taking another pointer to the byte array in the Blob.
304
305:[C++]:
306
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800307 .. code-block:: c++
308
309 Name& append(
310 const Blob& value
311 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800312
313:Parameters:
314
315 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800316 The Blob with the pointer to the byte array.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800317
318:Returns:
319
320 This name so that you can chain calls to append.
321
322Name.append Method (from Component)
323-----------------------------------
324
325Append the component to this name.
326
327:[C++]:
328
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800329 .. code-block:: c++
330
331 Name& append(
332 const Name::Component& value
333 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800334
335:Parameters:
336
337 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800338 The Name.Component to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800339
340:Returns:
341
342 This name so that you can chain calls to append.
343
344Name.append Method (from Name)
345------------------------------
346
347Append the components of the given name to this name.
348
349:[C++]:
350
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800351 .. code-block:: c++
352
353 Name& append(
354 const Name& name
355 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800356
357:[JavaScript]:
358
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800359 .. code-block:: javascript
360
361 // Returns this Name
362 Name.prototype.append = function(
363 value // Name
364 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800365
366:Parameters:
367
368 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800369 The Name with components to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800370
371:Returns:
372
373 This name so that you can chain calls to append.
374
375Name.appendSegment Method
376-------------------------
377
378Append a component with the encoded segment number.
379
380:[C++]:
381
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800382 .. code-block:: c++
383
384 Name& appendSegment(
385 uint64_t segment
386 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800387
388:[JavaScript]:
389
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800390 .. code-block:: javascript
391
392 // Returns this Name
393 Name.prototype.appendSegment = function(
394 segment // Number
395 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800396
397:Parameters:
398
399 - ``segment``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800400 The integer segment number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800401
402:Returns:
403
404 This name so that you can chain calls to append.
405
406Name.appendVersion Method
407-------------------------
408
409Append 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
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800413 .. code-block:: c++
414
415 Name& appendVersion(
416 uint64_t version
417 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800418
419:Parameters:
420
421 - ``version``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800422 The version number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800423
424:Returns:
425
426 This name so that you can chain calls to append.
427
428Other Name getter and setter methods
429------------------------------------
430
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800431:[JavaScript]:
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800432
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800433 .. code-block:: javascript
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800434
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800435 // Returns a new Name
436 Name.prototype.cut = function(
437 minusComponents // number
438 )
439
440 // Returns number
441 Name.prototype.indexOfFileName = function()
442
443 // Returns Boolean
444 Name.prototype.equalsName = function(
445 name // Name
446 )