headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / debugger / util / ArchivingUtils.cpp
blob1f8e21ab1b99226e0ef95f02abd1d52b0ceb2329
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "ArchivingUtils.h"
9 #include <Message.h>
12 /*static*/ status_t
13 ArchivingUtils::ArchiveChild(BArchivable* object, BMessage& parentArchive,
14 const char* fieldName)
16 if (object == NULL)
17 return B_BAD_VALUE;
19 BMessage archive;
20 status_t error = object->Archive(&archive, true);
21 if (error != B_OK)
22 return error;
24 return parentArchive.AddMessage(fieldName, &archive);
28 /*static*/ BArchivable*
29 ArchivingUtils::UnarchiveChild(const BMessage& parentArchive,
30 const char* fieldName, int32 index)
32 BMessage archive;
33 if (parentArchive.FindMessage(fieldName, index, &archive) != B_OK)
34 return NULL;
36 return instantiate_object(&archive);