Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame^] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "name-components.h" |
| 22 | #include "ccn/ccn.h" |
| 23 | #include <iostream> |
| 24 | |
| 25 | using namespace std; |
| 26 | |
| 27 | namespace ns3 { |
| 28 | namespace NDNabstraction { |
| 29 | namespace Name { |
| 30 | |
| 31 | Components::Components () |
| 32 | { |
| 33 | // m_value = ccn_charbuf_create (); |
| 34 | // ccn_name_init(m_value); |
| 35 | } |
| 36 | |
| 37 | Components::Components (const string &s) |
| 38 | { |
| 39 | // m_value = ccn_charbuf_create (); |
| 40 | // ccn_name_init(m_value); |
| 41 | // (*this) (s); |
| 42 | m_prefix.push_back (s); |
| 43 | } |
| 44 | |
| 45 | Components::~Components () |
| 46 | { |
| 47 | // ccn_charbuf_destroy(&m_value); |
| 48 | } |
| 49 | |
| 50 | // const ccn_charbuf* |
| 51 | // Components::GetName () const |
| 52 | // { |
| 53 | // return m_value; |
| 54 | // } |
| 55 | |
| 56 | Components& |
| 57 | Components::operator () (const string &s) |
| 58 | { |
| 59 | // ccn_name_append_str (m_value,s.c_str()); |
| 60 | m_prefix.push_back (s); |
| 61 | return *this; |
| 62 | } |
| 63 | |
| 64 | // Components::operator const unsigned char* () |
| 65 | // { |
| 66 | // return m_value->buf; |
| 67 | // } |
| 68 | |
| 69 | void |
| 70 | Components::Print (std::ostream &os) const |
| 71 | { |
| 72 | for (const_iterator i=m_prefix.begin(); i!=m_prefix.end(); i++) |
| 73 | { |
| 74 | os << "/" << *i; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | std::ostream & |
| 79 | operator << (std::ostream &os, const Components &components) |
| 80 | { |
| 81 | components.Print (os); |
| 82 | return os; |
| 83 | } |
| 84 | |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |