blob: 5a6280182ef3e2cbdaaa183b3f29d75affc1fa6f [file] [log] [blame]
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07001/*
2 * Author: Jeff Thompson
3 *
4 * BSD license, See the LICENSE file for more information.
5 */
6
Jeff Thompsone6063512013-07-01 15:11:28 -07007#include <sstream>
Jeff Thompsonb468c312013-07-01 17:50:14 -07008#include "c/Name.h"
Jeff Thompson9c41dfe2013-06-27 12:10:25 -07009#include "Name.hpp"
10
11using namespace std;
12
13namespace ndn {
14
Jeff Thompson48815112013-06-28 18:22:48 -070015Name::Name()
16{
17}
18
Jeff Thompsonb468c312013-07-01 17:50:14 -070019void Name::set(struct ndn_Name &nameStruct)
20{
21 clear();
22 for (int i = 0; i < nameStruct.nComponents; ++i)
23 addComponent(nameStruct.components[i].value, nameStruct.components[i].valueLength);
24}
25
Jeff Thompsone6063512013-07-01 15:11:28 -070026std::string Name::to_uri()
27{
28 // TODO: implement fully.
29 ostringstream output;
30 for (int i = 0; i < components_.size(); ++i) {
31 output << "/";
32 for (int j = 0; j < components_[i].size(); ++j)
33 output << components_[i][j];
34 }
35
36 return output.str();
37}
38
Jeff Thompson9c41dfe2013-06-27 12:10:25 -070039}