PageRenderTime 29ms CodeModel.GetById 15ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. #ifndef __MORDOR_NULL_STREAM_H__
  2. #define __MORDOR_NULL_STREAM_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include "stream.h"
  5. #include "mordor/util.h"
  6. namespace Mordor {
  7. class NullStream : public Stream
  8. {
  9. private:
  10. NullStream() {}
  11. public:
  12. static NullStream &get() { return s_nullStream; }
  13. static Stream::ptr get_ptr() { return Stream::ptr(&s_nullStream, &nop<Stream *>); }
  14. bool supportsRead() { return true; }
  15. bool supportsWrite() { return true; }
  16. bool supportsSeek() { return true; }
  17. bool supportsSize() { return true; }
  18. size_t read(Buffer &buffer, size_t length) { return 0; }
  19. size_t read(void *buffer, size_t length) { return 0; }
  20. size_t write(const Buffer &buffer, size_t length) { return length; }
  21. size_t write(const void *buffer, size_t length) { return length; }
  22. long long seek(long long offset, Anchor anchor = BEGIN) { return 0; }
  23. long long size() { return 0; }
  24. private:
  25. static NullStream s_nullStream;
  26. };
  27. }
  28. #endif