Skip to content

Commit

Permalink
BMessage::SetString() was broken.
Browse files Browse the repository at this point in the history
* We cannot use the macro for this, unfortunately.
  • Loading branch information
axeld committed Feb 12, 2013
1 parent ab6114f commit d2239cb
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/kits/app/Message.cpp
Expand Up @@ -2564,7 +2564,6 @@ DEFINE_SET_GET_FUNCTIONS(uint64, UInt64, B_UINT64_TYPE);
DEFINE_SET_GET_FUNCTIONS(bool, Bool, B_BOOL_TYPE);
DEFINE_SET_GET_FUNCTIONS(float, Float, B_FLOAT_TYPE);
DEFINE_SET_GET_FUNCTIONS(double, Double, B_DOUBLE_TYPE);
DEFINE_SET_GET_FUNCTIONS(const char *, String, B_STRING_TYPE);

#undef DEFINE_SET_GET_FUNCTION

Expand Down Expand Up @@ -3136,13 +3135,39 @@ BMessage::HasFlat(const char *name, int32 index, const BFlattenable *object)
}


const char*
BMessage::GetString(const char *name, const char *defaultValue) const
{
return GetString(name, 0, defaultValue);
}


const char*
BMessage::GetString(const char *name, int32 index,
const char *defaultValue) const
{
const char* value;
if (FindString(name, index, &value) == B_OK)
return value;

return defaultValue;
}


status_t
BMessage::SetString(const char *name, const BString& value)
{
return SetData(name, B_STRING_TYPE, value.String(), value.Length() + 1);
}


status_t
BMessage::SetString(const char *name, const char* value)
{
return SetData(name, B_STRING_TYPE, value, strlen(value) + 1);
}


status_t
BMessage::SetData(const char* name, type_code type, const void* data,
ssize_t numBytes)
Expand Down

0 comments on commit d2239cb

Please sign in to comment.