]> git.donarmstrong.com Git - bamtools.git/blob - src/api/internal/io/ByteArray_p.h
Updated file headers (filename, license, description, etc)
[bamtools.git] / src / api / internal / io / ByteArray_p.h
1 // ***************************************************************************
2 // ByteArray_p.h (c) 2011 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 November 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides a dynamic, variable-length byte buffer
8 // ***************************************************************************
9
10 #ifndef BYTEARRAY_P_H
11 #define BYTEARRAY_P_H
12
13 //  -------------
14 //  W A R N I N G
15 //  -------------
16 //
17 // This file is not part of the BamTools API.  It exists purely as an
18 // implementation detail. This header file may change from version to version
19 // without notice, or even be removed.
20 //
21 // We mean it.
22
23 #include "api/api_global.h"
24 #include <string>
25 #include <vector>
26
27 namespace BamTools {
28 namespace Internal {
29
30 // provides a wrapper around a byte vector
31 class ByteArray {
32
33     // ctors & dtor
34     public:
35         ByteArray(void);
36         ByteArray(const std::string& value);
37         ByteArray(const std::vector<char>& value);
38         ByteArray(const char* value, size_t n);
39         ByteArray(const ByteArray& other);
40         ~ByteArray(void);
41
42         ByteArray& operator=(const ByteArray& other);
43
44     // ByteArray interface
45     public:
46
47         // data access
48         const char* ConstData(void) const;
49         char* Data(void);
50         const char& operator[](size_t i) const;
51         char& operator[](size_t i);
52
53         // byte array manipulation
54         void Clear(void);
55         size_t IndexOf(const char c, const size_t from = 0, const size_t to = 0) const;
56         ByteArray& Remove(size_t from, size_t n);
57         void Resize(size_t n);
58         size_t Size(void) const;
59         void Squeeze(void);
60
61     // data members
62     private:
63         std::vector<char> m_data;
64 };
65
66 } // namespace Internal
67 } // namespace BamTools
68
69 #endif // BYTEARRAY_P_H