Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 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" |
Alexander Afanasyev | 2536e20 | 2011-08-12 14:13:10 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 23 | #include <iostream> |
| 24 | |
| 25 | using namespace std; |
| 26 | |
| 27 | namespace ns3 { |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 28 | namespace Name { |
| 29 | |
| 30 | Components::Components () |
| 31 | { |
| 32 | // m_value = ccn_charbuf_create (); |
| 33 | // ccn_name_init(m_value); |
| 34 | } |
| 35 | |
| 36 | Components::Components (const string &s) |
| 37 | { |
| 38 | // m_value = ccn_charbuf_create (); |
| 39 | // ccn_name_init(m_value); |
| 40 | // (*this) (s); |
| 41 | m_prefix.push_back (s); |
| 42 | } |
| 43 | |
| 44 | Components::~Components () |
| 45 | { |
| 46 | // ccn_charbuf_destroy(&m_value); |
| 47 | } |
| 48 | |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 49 | const std::list<std::string> & |
| 50 | Components::GetComponents () const |
| 51 | { |
| 52 | return m_prefix; |
| 53 | } |
| 54 | |
| 55 | |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 56 | // const ccn_charbuf* |
| 57 | // Components::GetName () const |
| 58 | // { |
| 59 | // return m_value; |
| 60 | // } |
| 61 | |
| 62 | Components& |
| 63 | Components::operator () (const string &s) |
| 64 | { |
| 65 | // ccn_name_append_str (m_value,s.c_str()); |
| 66 | m_prefix.push_back (s); |
| 67 | return *this; |
| 68 | } |
| 69 | |
| 70 | // Components::operator const unsigned char* () |
| 71 | // { |
| 72 | // return m_value->buf; |
| 73 | // } |
| 74 | |
| 75 | void |
| 76 | Components::Print (std::ostream &os) const |
| 77 | { |
| 78 | for (const_iterator i=m_prefix.begin(); i!=m_prefix.end(); i++) |
| 79 | { |
| 80 | os << "/" << *i; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | std::ostream & |
| 85 | operator << (std::ostream &os, const Components &components) |
| 86 | { |
| 87 | components.Print (os); |
| 88 | return os; |
| 89 | } |
| 90 | |
| 91 | } |
| 92 | } |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 93 | |