PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/mordor/streams/null.h

http://github.com/mozy/mordor
C Header | 37 lines | 27 code | 9 blank | 1 comment | 0 complexity | 16012e4ac739e326f3b3451d43d4fea8 MD5 | raw file
 1#ifndef __MORDOR_NULL_STREAM_H__
 2#define __MORDOR_NULL_STREAM_H__
 3// Copyright (c) 2009 - Mozy, Inc.
 4
 5#include "stream.h"
 6#include "mordor/util.h"
 7
 8namespace Mordor {
 9
10class NullStream : public Stream
11{
12private:
13    NullStream() {}
14
15public:
16    static NullStream &get() { return s_nullStream; }
17    static Stream::ptr get_ptr() { return Stream::ptr(&s_nullStream, &nop<Stream *>); }
18
19    bool supportsRead() { return true; }
20    bool supportsWrite() { return true; }
21    bool supportsSeek() { return true; }
22    bool supportsSize() { return true; }
23
24    size_t read(Buffer &buffer, size_t length) { return 0; }
25    size_t read(void *buffer, size_t length) { return 0; }
26    size_t write(const Buffer &buffer, size_t length) { return length; }
27    size_t write(const void *buffer, size_t length) { return length; }
28    long long seek(long long offset, Anchor anchor = BEGIN) { return 0; }
29    long long size() { return 0; }
30
31private:
32    static NullStream s_nullStream;
33};
34
35}
36
37#endif