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