blob: 0302ea15d9e6e3bdb475b707cf63884df1e61ccf [file] [log] [blame]
Alexander Afanasyev2d600f72013-11-21 18:20:37 -08001.. _Name:
2
3Name Class
4==========
5
6A Name holds an array of Name.Component and represents an NDN name.
7
8:[C++]:
9 Namespace: ``ndn``
10
11:[Python]:
12 Module: ``pyndn``
13
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080014Name Constructors
15-----------------
16
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080017Name Constructor (array of components)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080018^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080019
20Create a new Name with the optional components.
21
22:[C++]:
23
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080024 .. code-block:: c++
25
26 Name(
27 [const std::vector<Name::Component>& components]
28 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080029
30:[JavaScript]:
31
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080032 .. code-block:: javascript
33
34 var Name = function Name (
35 [components // Array<Uint8Array>]
36 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080037
38:[Python]:
39
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080040 .. code-block:: python
41
42 def __init__(self
43 [, components // Array<string>]
44 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080045
46:Parameters:
47
48 - ``components``
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080049 (optional) The array of :ref:`name components <Name.Component>`.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080050
51Name Constructor (from URI)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -080052^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080053
54Parse the uri according to the NDN URI Scheme and create the Name with the components.
55
56:[C++]:
57
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080058 .. code-block:: c++
59
60 Name(
61 const char* uri
62 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080063
64:[JavaScript]:
65
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080066 .. code-block:: javascript
67
68 var Name = function Name (
69 uri // string
70 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080071
72:Parameters:
73
74 - ``uri``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080075 The URI in NDN URI Scheme.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080076
77Name.toUri Method
78-----------------
79
80Return the escaped name string according to the NDN URI Scheme.
81
82:[C++]:
83
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080084 .. code-block:: c++
85
86 std::string toUri() const ();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080087
88:[JavaScript]:
89
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -080090 .. code-block:: javascript
91
92 // Returns string
93 Name.prototype.toUri = function();
Alexander Afanasyev2d600f72013-11-21 18:20:37 -080094
95:Returns:
96
97The escaped name string according to the NDN URI Scheme.
98
99Name.size Method
100----------------
101
102Get the number of components.
103
104:[C++]:
105
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800106 .. code-block:: c++
107
108 size_t getComponentCount() const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800109
110:Returns:
111
112 The number of components.
113
114Name.get Method
115---------------
116
117Get a Name Component by index number.
118
119:[C++]:
120
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800121 .. code-block:: c++
122
123 const Component& getComponent(
124 size_t i
125 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800126
127:Parameters:
128
129 - ``i``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800130 The index of the component to get, starting from 0.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800131
132:Returns:
133
134 The Name.Component.
135
136Name.getPrefix Method
137---------------------
138
139Get a new Name with the first nComponents components of this Name.
140
141:[C++]:
142
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800143 .. code-block:: c++
144
145 Name getPrefix(
146 size_t nComponents
147 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800148
149:[JavaScript]:
150
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800151 .. code-block:: javascript
152
153 // Returns Name
154 Name.prototype.getPrefix = function(
155 nComponents // Number
156 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800157
158:Parameters:
159
160 - nComponents
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800161 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 -0800162
163:Returns:
164
165 A new Name.
166
167Name.getSubName Method
168----------------------
169
170Get a new name, constructed as a subset of components.
171
172:[C++]:
173
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800174 .. code-block:: c++
175
176 Name getSubName(
177 size_t iStartComponent
178 [, size_t nComponents]
179 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800180
181:Parameters:
182
183 - ``iStartComponent``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800184 The index if the first component to get.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800185
186 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800187 (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 -0800188
189:Returns:
190
191 A new Name.
192
193Name.match Method
194-----------------
195
196Check if the N components of this name are the same as the first N components of the given name.
197
198:[C++]:
199
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800200 .. code-block:: c++
201
202 bool match(
203 const Name& name
204 ) const;
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800205
206:[JavaScript]:
207
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800208 .. code-block:: javascript
209
210 // Returns boolean
211 Name.prototype.match = function(
212 name // Name
213 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800214
215:Parameters:
216
217 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800218 The Name to check.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800219
220 - ``nComponents``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800221 The number of components starting at iStartComponent. If omitted, return components until the end of the name.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800222
223:Returns:
224
225 true if this matches the given name, otherwise false. This always returns true if this name is empty.
226
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800227Name.append Methods
228-------------------
229
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800230Name.append Method (copy byte array)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800231^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800232
233Append a new component, copying from byte array.
234
235:[C++]:
236
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800237 .. code-block:: c++
238
239 Name& append(
240 const std::vector<uint8_t>& value
241 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800242
243:[JavaScript]:
244
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800245 .. code-block:: javascript
246
247 // Returns this Name
248 Name.prototype.append = function(
249 value // Array<number>|ArrayBuffer|Uint8Array
250 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800251
252:Parameters:
253
254 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800255 The component byte array to copy.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800256
257:Returns:
258
259 This name so that you can chain calls to append.
260
261Name.append Method (from Blob)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800262^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800263
264Append a new component, taking another pointer to the byte array in the Blob.
265
266:[C++]:
267
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800268 .. code-block:: c++
269
270 Name& append(
271 const Blob& value
272 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800273
274:Parameters:
275
276 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800277 The Blob with the pointer to the byte array.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800278
279:Returns:
280
281 This name so that you can chain calls to append.
282
283Name.append Method (from Component)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800284^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800285
286Append the component to this name.
287
288:[C++]:
289
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800290 .. code-block:: c++
291
292 Name& append(
293 const Name::Component& value
294 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800295
296:Parameters:
297
298 - ``value``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800299 The Name.Component to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800300
301:Returns:
302
303 This name so that you can chain calls to append.
304
305Name.append Method (from Name)
Alexander Afanasyev06e798c2013-11-26 19:10:29 -0800306^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800307
308Append the components of the given name to this name.
309
310:[C++]:
311
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800312 .. code-block:: c++
313
314 Name& append(
315 const Name& name
316 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800317
318:[JavaScript]:
319
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800320 .. code-block:: javascript
321
322 // Returns this Name
323 Name.prototype.append = function(
324 value // Name
325 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800326
327:Parameters:
328
329 - ``name``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800330 The Name with components to append.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800331
332:Returns:
333
334 This name so that you can chain calls to append.
335
336Name.appendSegment Method
337-------------------------
338
339Append a component with the encoded segment number.
340
341:[C++]:
342
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800343 .. code-block:: c++
344
345 Name& appendSegment(
346 uint64_t segment
347 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800348
349:[JavaScript]:
350
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800351 .. code-block:: javascript
352
353 // Returns this Name
354 Name.prototype.appendSegment = function(
355 segment // Number
356 )
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800357
358:Parameters:
359
360 - ``segment``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800361 The integer segment number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800362
363:Returns:
364
365 This name so that you can chain calls to append.
366
367Name.appendVersion Method
368-------------------------
369
370Append a component with the encoded version number. Note that this encodes the exact value of version without converting from a time representation.
371
372:[C++]:
373
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800374 .. code-block:: c++
375
376 Name& appendVersion(
377 uint64_t version
378 );
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800379
380:Parameters:
381
382 - ``version``
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800383 The version number to be encoded.
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800384
385:Returns:
386
387 This name so that you can chain calls to append.
388
389Other Name getter and setter methods
390------------------------------------
391
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800392:[JavaScript]:
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800393
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800394 .. code-block:: javascript
Alexander Afanasyev2d600f72013-11-21 18:20:37 -0800395
Alexander Afanasyev1efe4a32013-11-21 18:46:34 -0800396 // Returns a new Name
397 Name.prototype.cut = function(
398 minusComponents // number
399 )
400
401 // Returns number
402 Name.prototype.indexOfFileName = function()
403
404 // Returns Boolean
405 Name.prototype.equalsName = function(
406 name // Name
407 )