1/* 2 * Copyright 2011-2018, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include "BMessageTypeHandler.h" 8 9#include <new> 10 11#include "BMessageValueNode.h" 12#include "Type.h" 13 14 15BMessageTypeHandler::~BMessageTypeHandler() 16{ 17} 18 19 20const char* 21BMessageTypeHandler::Name() const 22{ 23 return "Message content"; 24} 25 26 27float 28BMessageTypeHandler::SupportsType(Type* type) const 29{ 30 if (dynamic_cast<CompoundType*>(type) != NULL 31 && type->Name() == "BMessage") 32 return 1.0f; 33 34 return 0.0f; 35} 36 37 38status_t 39BMessageTypeHandler::CreateValueNode(ValueNodeChild* nodeChild, Type* type, 40 ValueNode*& _node) 41{ 42 if (SupportsType(type) == 0.0f) 43 return B_BAD_VALUE; 44 45 ValueNode* node = new(std::nothrow) BMessageValueNode(nodeChild, 46 type); 47 48 if (node == NULL) 49 return B_NO_MEMORY; 50 51 _node = node; 52 53 return B_OK; 54} 55