2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include "ArrayIndexPath.h"
14 static const char kIndexSeparator
= ';';
17 ArrayIndexPath::ArrayIndexPath()
22 ArrayIndexPath::ArrayIndexPath(const ArrayIndexPath
& other
)
24 fIndices(other
.fIndices
)
29 ArrayIndexPath::~ArrayIndexPath()
35 ArrayIndexPath::SetTo(const char* path
)
42 while (*path
!= '\0') {
44 int64 index
= strtoll(path
, &numberEnd
, 0);
45 if (numberEnd
== path
)
49 if (!fIndices
.Add(index
))
55 if (*path
!= kIndexSeparator
)
65 ArrayIndexPath::Clear()
72 ArrayIndexPath::GetPathString(BString
& path
) const
76 int32 count
= CountIndices();
77 for (int32 i
= 0; i
< count
; i
++) {
78 // append separator for all but the first index
80 int32 oldLength
= path
.Length();
81 if (path
.Append(kIndexSeparator
, 1).Length() != oldLength
+ 1)
86 int32 oldLength
= path
.Length();
87 if ((path
<< IndexAt(i
)).Length() == oldLength
)
96 ArrayIndexPath::operator=(const ArrayIndexPath
& other
)
98 fIndices
= other
.fIndices
;