PageRenderTime 2ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/mordor/streams/singleplex.h

http://github.com/mozy/mordor
C Header | 48 lines | 37 code | 10 blank | 1 comment | 8 complexity | 205a333ac001063260f879fb55077c42 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. #ifndef __MORDOR_SINGLEPLEX_STREAM_H__
  2. #define __MORDOR_SINGLEPLEX_STREAM_H__
  3. // Copyright (c) 2009 - Mozy, Inc.
  4. #include "filter.h"
  5. namespace Mordor {
  6. class SingleplexStream : public FilterStream
  7. {
  8. public:
  9. enum Type {
  10. READ,
  11. WRITE
  12. };
  13. SingleplexStream(Stream::ptr parent, Type type, bool own = true);
  14. bool supportsRead() { return m_type == READ; }
  15. bool supportsWrite() { return m_type == WRITE; }
  16. bool supportsTruncate()
  17. { return m_type == WRITE && parent()->supportsTruncate(); }
  18. bool supportsFind()
  19. { return m_type == READ && parent()->supportsFind(); }
  20. bool supportsUnread()
  21. { return m_type == READ && parent()->supportsUnread(); }
  22. void close(CloseType type = BOTH);
  23. size_t read(Buffer &buffer, size_t length);
  24. size_t read(void *buffer, size_t length);
  25. size_t write(const Buffer &buffer, size_t length);
  26. size_t write(const void *buffer, size_t length);
  27. void truncate(long long size);
  28. void flush(bool flushParent = true);
  29. ptrdiff_t find(char delimiter, size_t sanitySize = ~0,
  30. bool throwIfNotFound = true);
  31. ptrdiff_t find(const std::string &delimiter,
  32. size_t sanitySize = ~0, bool throwIfNotFound = true);
  33. void unread(const Buffer &buffer, size_t length);
  34. private:
  35. Type m_type;
  36. };
  37. }
  38. #endif