PageRenderTime 102ms CodeModel.GetById 61ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/mordor/streams/transfer.h

http://github.com/mozy/mordor
C Header | 38 lines | 27 code | 7 blank | 4 comment | 0 complexity | c5a783ebe81d14caa600064514a1e014 MD5 | raw file
 1#ifndef __MORDOR_TRANSFER_STREAM_H__
 2#define __MORDOR_TRANSFER_STREAM_H__
 3// Copyright (c) 2009 - Mozy, Inc.
 4
 5#include "stream.h"
 6
 7namespace Mordor {
 8
 9enum ExactLength
10{
11    /// If toTransfer == ~0ull, use EOF, otherwise EXACT
12    INFER,
13    /// If toTransfer bytes can't be read, throw UnexpectedEofException
14    EXACT,
15    /// Transfer as many bytes as possible until EOF is hit
16    UNTILEOF
17};
18
19unsigned long long transferStream(Stream &src, Stream &dst,
20                                  unsigned long long toTransfer = ~0ull,
21                                  ExactLength exactLength = INFER);
22
23inline unsigned long long transferStream(Stream::ptr src, Stream &dst,
24                                         unsigned long long toTransfer = ~0ull,
25                                         ExactLength exactLength = INFER)
26{ return transferStream(*src.get(), dst, toTransfer, exactLength); }
27inline unsigned long long transferStream(Stream &src, Stream::ptr dst,
28                                         unsigned long long toTransfer = ~0ull,
29                                         ExactLength exactLength = INFER)
30{ return transferStream(src, *dst.get(), toTransfer, exactLength); }
31inline unsigned long long transferStream(Stream::ptr src, Stream::ptr dst,
32                                         unsigned long long toTransfer = ~0ull,
33                                         ExactLength exactLength = INFER)
34{ return transferStream(*src.get(), *dst.get(), toTransfer, exactLength); }
35
36}
37
38#endif