btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / debugger / types / ArrayIndexPath.h
blobb739ef447a5fec4eaf8c535cba302bf0b41fe44a
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef ARRAY_INDEX_PATH_H
6 #define ARRAY_INDEX_PATH_H
9 #include <Array.h>
11 #include "Types.h"
14 class BString;
17 class ArrayIndexPath {
18 public:
19 ArrayIndexPath();
20 ArrayIndexPath(const ArrayIndexPath& other);
21 ~ArrayIndexPath();
23 status_t SetTo(const char* path);
24 void Clear();
26 bool GetPathString(BString& path) const;
28 inline int32 CountIndices() const;
29 inline int64 IndexAt(int32 index) const;
30 inline bool AddIndex(int64 index);
31 inline void SetIndexAt(int32 at, int64 newIndex);
33 ArrayIndexPath& operator=(const ArrayIndexPath& other);
35 private:
36 typedef Array<int64> IndexArray;
38 private:
39 IndexArray fIndices;
43 int32
44 ArrayIndexPath::CountIndices() const
46 return fIndices.Count();
50 int64
51 ArrayIndexPath::IndexAt(int32 index) const
53 return index >= 0 && index < fIndices.Count()
54 ? fIndices.ElementAt(index) : -1;
58 bool
59 ArrayIndexPath::AddIndex(int64 index)
61 return fIndices.Add(index);
65 void
66 ArrayIndexPath::SetIndexAt(int32 at, int64 newIndex)
68 if (at >= 0 && at < fIndices.Count())
69 fIndices[at] = newIndex;
73 #endif // ARRAY_INDEX_PATH_H