btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / package / hpkg / Stacker.h
blobf874cd4091c60ba7d78ddb0795cc512476248cd6
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _PACKAGE__HPKG__PRIVATE__STACKER_H_
6 #define _PACKAGE__HPKG__PRIVATE__STACKER_H_
9 namespace BPackageKit {
11 namespace BHPKG {
13 namespace BPrivate {
16 template<typename Type>
17 class Stacker {
18 public:
19 Stacker(Type*& location, Type* element)
21 fLocation(&location),
22 fPreviousElement(location)
24 *fLocation = element;
27 Stacker(Type** location, Type* element)
29 fLocation(location),
30 fPreviousElement(*location)
32 *fLocation = element;
35 ~Stacker()
37 if (fLocation != NULL)
38 *fLocation = fPreviousElement;
41 private:
42 Type** fLocation;
43 Type* fPreviousElement;
47 } // namespace BPrivate
49 } // namespace BHPKG
51 } // namespace BPackageKit
54 #endif // _PACKAGE__HPKG__PRIVATE__STACKER_H_