NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Typedefs
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
Enumerations
+
Enumerator
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
u
v
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
w
+
Typedefs
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
+
Enumerator
a
d
e
f
i
k
l
n
p
r
s
u
w
+
Related Functions
b
c
d
e
f
g
i
k
l
m
n
o
p
s
v
+
Files
File List
+
File Members
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
p
r
s
u
v
w
+
Functions
c
f
h
m
r
s
u
w
+
Variables
a
c
d
g
k
l
n
p
r
s
Typedefs
+
Macros
b
d
e
f
i
l
m
n
p
r
s
u
v
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
stream-source.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
#include "
stream-source.hpp
"
23
#include <vector>
24
25
namespace
ndn
{
26
namespace
security
{
27
namespace
transform {
28
29
const
std::size_t
StreamSource::DEFAULT_BUFFER_LEN
= 1024;
30
31
StreamSource::StreamSource
(std::istream& is,
size_t
bufferSize)
32
:
Source
()
33
, m_is(is)
34
, m_bufferSize(bufferSize)
35
{
36
BOOST_ASSERT(bufferSize > 0);
37
}
38
39
void
40
StreamSource::doPump()
41
{
42
BOOST_ASSERT(
m_next
!=
nullptr
);
43
44
std::vector<uint8_t> buffer(m_bufferSize);
45
size_t
dataOffset = 0;
46
size_t
dataLen = 0;
47
48
while
(dataLen > 0 || !m_is.eof()) {
49
if
(dataLen > 0) {
50
// we have some leftover, handle them first
51
size_t
nBytesWritten =
m_next
->write(&buffer[dataOffset], dataLen);
52
53
dataOffset += nBytesWritten;
54
dataLen -= nBytesWritten;
55
}
56
else
if
(!m_is) {
57
BOOST_THROW_EXCEPTION(
Error
(
getIndex
(),
"Input stream in bad state"
));
58
}
59
else
if
(m_is.good()) {
60
m_is.read(reinterpret_cast<char*>(&buffer.front()), buffer.size());
61
dataOffset = 0;
62
dataLen = m_is.gcount();
63
}
64
}
65
m_next
->end();
66
}
67
68
}
// namespace transform
69
}
// namespace security
70
}
// namespace ndn
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
stream-source.hpp
ndn::security::transform::StreamSource::StreamSource
StreamSource(std::istream &is, size_t bufLen=DEFAULT_BUFFER_LEN)
Construst a source using is as input.
Definition:
stream-source.cpp:31
ndn::security::transform::Upstream::m_next
unique_ptr< Downstream > m_next
Definition:
transform-base.hpp:179
ndn::security::transform::Source::getIndex
size_t getIndex() const
Get the source module index (should always be 0).
Definition:
transform-base.hpp:319
ndn::security::transform::Error
Base class of transformation error.
Definition:
transform-base.hpp:47
ndn::security::transform::Source
Abstraction of the transformation source module.
Definition:
transform-base.hpp:288
ndn::security::transform::StreamSource::DEFAULT_BUFFER_LEN
static const std::size_t DEFAULT_BUFFER_LEN
Definition:
stream-source.hpp:56
security
ndnSIM
ndn-cxx
src
security
transform
stream-source.cpp
Generated on Wed Jan 11 2017 18:17:14 for ndnSIM by
1.8.13