diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h index 2920a1a3a2..50e092063d 100644 --- a/headers/os/app/Message.h +++ b/headers/os/app/Message.h @@ -24,6 +24,7 @@ class BBlockCache; class BMessenger; class BHandler; class BString; +class BStringList; struct entry_ref; @@ -125,6 +126,7 @@ class BMessage { status_t AddSize(const char* name, BSize aSize); status_t AddString(const char *name, const char *aString); status_t AddString(const char *name, const BString &aString); + status_t AddStrings(const char *name, const BStringList &list); status_t AddInt8(const char *name, int8 value); status_t AddUInt8(const char *name, uint8 value); status_t AddInt16(const char *name, int16 value); @@ -170,6 +172,7 @@ class BMessage { status_t FindString(const char *name, int32 index, const char **string) const; status_t FindString(const char *name, BString *string) const; status_t FindString(const char *name, int32 index, BString *string) const; + status_t FindStrings(const char *name, BStringList *list) const; status_t FindInt8(const char *name, int8 *value) const; status_t FindInt8(const char *name, int32 index, int8 *value) const; status_t FindUInt8(const char *name, uint8 *value) const; diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index a4af4651c1..9837ed30d8 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -2531,6 +2532,20 @@ BMessage::AddString(const char *name, const BString &string) } +status_t +BMessage::AddStrings(const char *name, const BStringList &list) +{ + int32 count = list.CountStrings(); + for (int32 i = 0; i < count; i++) { + status_t error = AddString(name, list.StringAt(i)); + if (error != B_OK) + return error; + } + + return B_OK; +} + + status_t BMessage::AddPointer(const char *name, const void *pointer) { @@ -2691,6 +2706,36 @@ BMessage::FindString(const char *name, int32 index, BString *string) const } +status_t +BMessage::FindStrings(const char *name, BStringList *list) const +{ + if (list == NULL) + return B_BAD_VALUE; + + list->MakeEmpty(); + + // get the number of items + type_code type; + int32 count; + if (GetInfo(name, &type, &count) != B_OK) + return B_NAME_NOT_FOUND; + + if (type != B_STRING_TYPE) + return B_BAD_DATA; + + for (int32 i = 0; i < count; i++) { + BString string; + status_t error = FindString(name, i, &string); + if (error != B_OK) + return error; + if (!list->Add(string)) + return B_NO_MEMORY; + } + + return B_OK; +} + + status_t BMessage::FindPointer(const char *name, void **pointer) const {