Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
ms_cache_stream.hpp
1/*
2##############################################################################
3# file: ms_cache_stream.hpp #
4# 'msparser' toolkit #
5# Used internally in Mascot Parser as well as being available externally #
6# #
7##############################################################################
8# COPYRIGHT NOTICE #
9# Copyright 1998-2013 Matrix Science Limited All Rights Reserved. #
10# #
11##############################################################################
12# $Archive:: $
13# $Author: villek@matrixscience.com $
14# $Date: 2018-07-30 16:23:53 +0100 $
15# $Revision: 1b450440f9c97e1e41d0fc6016a27d68951d4532 | MSPARSER_REL_3_0_0-2024-09-24-0-g93ebaeb4f4 $
16# $NoKeywords:: $
17##############################################################################
18*/
19
20#ifndef MS_CACHE_STREAM_HPP
21#define MS_CACHE_STREAM_HPP
22
23
24
25// Includes from the standard template library
26#include <string>
27#include <vector>
28
29#ifndef SWIG
30 // Helper class - don't use from outside library
31
32namespace matrix_science
33{
34 class ms_cache_file;
35 class ms_tinycdb;
36
37 class MS_MASCOTRESFILE_API ms_cache_stream
38 {
39 public:
40 ms_cache_stream();
41 virtual ~ms_cache_stream();
42
43 INT64 getId() const;
44 void setId(INT64 id);
45
46 void clear(); // clear the stream, free up storage
47 void reserve(size_t byteCount); // pre-allocate space for copying data into
48 unsigned getBytesAvailable() const; // number of bytes currently available for reading
49 bool isOverExhausted() const; // true is attempt has been made to read more data than the stream has avaialble
50
51 void add(int value); // 4 bytes
52 void add(unsigned value); // 4 bytes
53 void add(INT64 value); // 8 bytes
54 void add(UINT64 value); // 8 bytes
55 void add(bool value); // 4 bytes (yes, really)
56 void add(double value); // 8 bytes
57 void add(const char * value, size_t length); // 4 byte unsigned length plus n x char (1 byte each), NOT null terminated
58 void add(const char * value); // 4 byte unsigned length plus n x char (1 byte each), NOT null terminated
59 void add(const std::string & value); // 4 byte unsigned length plus n x char (1 byte each), NOT null terminated
60
61 int getInt32();
62 unsigned getUnsigned32();
63 INT64 getInt64();
64 UINT64 getUnsigned64();
65 bool getBool();
66 double getDouble();
67 std::string getString();
68
69 void addBytes(const void * bytes, size_t size); // add bytes to the end of the stream
70 void getBytes(void * bytes, size_t size); // copy bytes from the stream, extend read position
71
72 const char * getBuffer() const;
73 unsigned getBufferLength() const;
74
75 bool save(matrix_science::ms_tinycdb & cdbFile, const std::string & streamName) const;
76
77 private:
78 INT64 id_;
79 size_t readPosition_;
80 std::vector<char> buffer_;
81 bool isOverExhausted_;
82
83 friend class ms_cache_file;
84 };
85
86} // matrix_science
87
88#endif // SWIG
89
90#endif // MS_CACHE_STREAM_HPP
91
92/*------------------------------- End of File -------------------------------*/
Wrapper for the public domain tinycdb package http://www.corpit.ru/mjt/tinycdb.html by Michael Tokare...
Definition: ms_tinycdb.hpp:124