diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h index 077da8913e..ab1e909efc 100644 --- a/headers/os/app/Message.h +++ b/headers/os/app/Message.h @@ -1,5 +1,5 @@ /* - * Copyright 2005-2015 Haiku, Inc. All rights reserved. + * Copyright 2005-2017 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -461,6 +461,10 @@ public: rgb_color defaultValue) const; rgb_color GetColor(const char* name, int32 index, rgb_color defaultValue) const; + const void* GetPointer(const char* name, int32 index, + const void* defaultValue = NULL) const; + const void* GetPointer(const char* name, + const void* defaultValue = NULL) const; const char* GetString(const char* name, const char* defaultValue = NULL) const; const char* GetString(const char* name, int32 index, diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index eac16f4b33..01699b3ebd 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2015 Haiku, Inc. All rights reserved. + * Copyright 2005-2017 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -741,7 +741,7 @@ BMessage::_PrintToStream(const char* indent) const rgb_color* color = (rgb_color*)pointer; printf("rgb_color(%u, %u, %u, %u)\n", color->red, color->green, color->blue, color->alpha); - break; + break; } default: @@ -2592,6 +2592,32 @@ DEFINE_SET_GET_FUNCTIONS(rgb_color, Color, B_RGB_32_BIT_TYPE); #undef DEFINE_SET_GET_FUNCTION +const void* +BMessage::GetPointer(const char* name, const void* defaultValue) const +{ + return GetPointer(name, 0, defaultValue); +} + + +const void* +BMessage::GetPointer(const char* name, int32 index, + const void* defaultValue) const +{ + void* value; + if (FindPointer(name, index, &value) == B_OK) + return value; + + return defaultValue; +} + + +status_t +BMessage::SetPointer(const char* name, const void* value) +{ + return SetData(name, B_POINTER_TYPE, &value, sizeof(void*)); +} + + #define DEFINE_SET_GET_BY_REFERENCE_FUNCTIONS(type, typeName, typeCode) \ type \ BMessage::Get##typeName(const char* name, const type& defaultValue) const \