blob: cdb2a7e70a9b2d8872c3336e9570afaa171aa4eb [file] [log] [blame]
Alexander Afanasyevf278db32013-01-21 14:41:01 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013 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: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 */
21
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080022#ifndef CCNX_CONTENT_OBJECT_H
23#define CCNX_CONTENT_OBJECT_H
24
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080025#include "ccnx-wrapper.h"
Zhenkai Zhu974c5a62012-12-28 14:15:30 -080026#include "ccnx-common.h"
Zhenkai Zhucb2d0dd2013-01-03 14:10:48 -080027#include "ccnx-name.h"
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080028
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080029namespace Ccnx {
30
Alexander Afanasyevf278db32013-01-21 14:41:01 -080031struct MisformedContentObjectException : virtual boost::exception, virtual std::exception { };
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080032
Zhenkai Zhu0d8f5d52012-12-30 12:54:07 -080033class ParsedContentObject
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080034{
35public:
36 ParsedContentObject(const unsigned char *data, size_t len);
Alexander Afanasyevf278db32013-01-21 14:41:01 -080037 ParsedContentObject(const unsigned char *data, const ccn_parsed_ContentObject &pco);
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080038 ParsedContentObject(const Bytes &bytes);
39 ParsedContentObject(const ParsedContentObject &other);
40 virtual ~ParsedContentObject();
41
42 Bytes
Zhenkai Zhubad089c2012-12-28 10:28:27 -080043 content() const;
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080044
Alexander Afanasyevdbc06712013-01-08 18:30:28 -080045 BytesPtr
46 contentPtr() const;
Alexander Afanasyevf278db32013-01-21 14:41:01 -080047
Zhenkai Zhucb2d0dd2013-01-03 14:10:48 -080048 Name
Zhenkai Zhubad089c2012-12-28 10:28:27 -080049 name() const;
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080050
Alexander Afanasyev053e5ac2013-01-22 20:59:13 -080051 inline const Bytes &
52 buf () const;
53
Zhenkai Zhu9f2ef6f2013-01-04 21:46:08 -080054private:
55 void
56 init(const unsigned char *data, size_t len);
57
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080058protected:
Zhenkai Zhu90611802013-01-04 21:30:24 -080059 ccn_parsed_ContentObject m_pco;
60 ccn_indexbuf *m_comps;
61 Bytes m_bytes;
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080062};
63
Alexander Afanasyev053e5ac2013-01-22 20:59:13 -080064const Bytes &
65ParsedContentObject::buf () const
66{
67 return m_bytes;
68}
69
70
Zhenkai Zhu43eb2732012-12-28 00:48:26 -080071typedef boost::shared_ptr<ParsedContentObject> PcoPtr;
72
73}
74
75#endif // CCNX_CONTENT_OBJECT_H