Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Author: Jeff Thompson |
| 3 | * |
| 4 | * BSD license, See the LICENSE file for more information. |
| 5 | */ |
| 6 | |
Jeff Thompson | e606351 | 2013-07-01 15:11:28 -0700 | [diff] [blame] | 7 | #include <sstream> |
Jeff Thompson | b468c31 | 2013-07-01 17:50:14 -0700 | [diff] [blame] | 8 | #include "c/Name.h" |
Jeff Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 9 | #include "Name.hpp" |
| 10 | |
| 11 | using namespace std; |
| 12 | |
| 13 | namespace ndn { |
| 14 | |
Jeff Thompson | 4881511 | 2013-06-28 18:22:48 -0700 | [diff] [blame] | 15 | Name::Name() |
| 16 | { |
| 17 | } |
| 18 | |
Jeff Thompson | b468c31 | 2013-07-01 17:50:14 -0700 | [diff] [blame] | 19 | void 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 Thompson | e606351 | 2013-07-01 15:11:28 -0700 | [diff] [blame] | 26 | std::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 Thompson | 9c41dfe | 2013-06-27 12:10:25 -0700 | [diff] [blame] | 39 | } |