blob: 7dde99f26f90b3edf256226f4182875694b2e798 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -07002/*
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 Afanasyev2536e202011-08-12 14:13:10 -070022
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070023#include <iostream>
24
25using namespace std;
26
27namespace ns3 {
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070028
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070029CcnxNameComponents::CcnxNameComponents ()
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070030{
31 // m_value = ccn_charbuf_create ();
32 // ccn_name_init(m_value);
33}
34
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070035CcnxNameComponents::CcnxNameComponents (const string &s)
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070036{
37 // m_value = ccn_charbuf_create ();
38 // ccn_name_init(m_value);
39 // (*this) (s);
40 m_prefix.push_back (s);
41}
42
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070043CcnxNameComponents::~CcnxNameComponents ()
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070044{
45 // ccn_charbuf_destroy(&m_value);
46}
47
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070048const std::list<std::string> &
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070049CcnxNameComponents::GetComponents () const
Alexander Afanasyev2a5df202011-08-15 22:39:05 -070050{
51 return m_prefix;
52}
53
54
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070055// const ccn_charbuf*
56// Components::GetName () const
57// {
58// return m_value;
59// }
60
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070061CcnxNameComponents&
62CcnxNameComponents::operator () (const string &s)
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070063{
64 // ccn_name_append_str (m_value,s.c_str());
65 m_prefix.push_back (s);
66 return *this;
67}
68
69// Components::operator const unsigned char* ()
70// {
71// return m_value->buf;
72// }
73
74void
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070075CcnxNameComponents::Print (std::ostream &os) const
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070076{
77 for (const_iterator i=m_prefix.begin(); i!=m_prefix.end(); i++)
78 {
79 os << "/" << *i;
80 }
81}
82
83std::ostream &
Ilya Moiseenko2bd1bc32011-08-23 16:01:35 -070084operator << (std::ostream &os, const CcnxNameComponents &components)
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070085{
86 components.Print (os);
87 return os;
88}
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070089}
Alexander Afanasyev3a6ea5c2011-08-11 18:15:49 -070090