PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/strigi-0.7.7/libstreams/lib/signatureinputstream.h

#
C Header | 70 lines | 19 code | 5 blank | 46 comment | 0 complexity | 94c54a1c9b12e15c1cfd8f1cce6e2645 MD5 | raw file
Possible License(s): LGPL-2.0
  1. /* This file is part of Strigi Desktop Search
  2. *
  3. * Copyright (C) 2009 Jos van den Oever <jos@vandenoever.info>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef STRIGI_SIGNATUREINPUTSTREAM
  21. #define STRIGI_SIGNATUREINPUTSTREAM
  22. #include <strigi/strigiconfig.h>
  23. #include "streambase.h"
  24. namespace Strigi {
  25. /**
  26. * @brief Reads a stream and remembers the signature.
  27. *
  28. * This class stops reading data when either the end of the
  29. * underlying stream is reacher, or a given terminator is encountered
  30. * in the the stream.
  31. */
  32. class SignatureInputStream : public InputStream {
  33. private:
  34. class Private;
  35. Private* const p;
  36. public:
  37. /**
  38. * @brief Create a stream from an InputStream.
  39. *
  40. * @param i the underlying InputStream to read the data from
  41. * @param terminator the terminator indicating the end of this substream
  42. */
  43. SignatureInputStream(InputStream* i, int32_t signaturesize);
  44. ~SignatureInputStream();
  45. /**
  46. * @brief inherited from StreamBase
  47. **/
  48. int32_t read(const char*& start, int32_t min=0, int32_t max=0);
  49. /**
  50. * @brief inherited from StreamBase
  51. **/
  52. int64_t reset(int64_t pos);
  53. /**
  54. * @brief inherited from StreamBase
  55. **/
  56. int64_t skip(int64_t ntoskip);
  57. /**
  58. * @brief Return the signature of this stream.
  59. * The signature is only available once the end of the stream has been
  60. * reached. The signature can up up to @p signaturesize bytes long.
  61. **/
  62. std::string signature() const;
  63. };
  64. } //end namespace Strigi
  65. #endif